k94314517
2024-06-20 15ef66d5eb25490cb4684c32598ca25f54cd9c4b
git ch
已修改9个文件
547 ■■■■ 文件已修改
server/company/src/main/java/com/doumee/api/business/ApplyChangeController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/Constants.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/DateUtil.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/UnionApply.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/InsuranceApplyService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java 286 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/company/src/main/java/com/doumee/api/business/ApplyChangeController.java
@@ -13,6 +13,7 @@
import com.doumee.dao.business.model.ApplyChange;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import com.doumee.service.business.ApplyChangeService;
import com.doumee.service.business.InsuranceApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
@@ -37,6 +38,9 @@
    @Autowired
    private ApplyChangeService applyChangeService;
    @Autowired
    private InsuranceApplyService insuranceApplyService;
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -386,7 +386,7 @@
        if(StringUtils.isBlank(idCard)){
            return 2;
        }
        Pattern pattern = Pattern.compile("\\d{17}[\\d|x]"); // 定义身份证号码格式的正则表达式
        Pattern pattern = Pattern.compile("\\d{17}[\\d|x|X]"); // 定义身份证号码格式的正则表达式
        Matcher matcher = pattern.matcher(idCard);
        Integer sex = 0;
        if (matcher.matches()) {
@@ -401,6 +401,7 @@
        }
        return sex;
    }
    /**
     * 状态 0已保存、1待审核、2审核通过、3退回修改、4审核驳回、5待服务机构确认、6服务机构拒绝、7已分配服务机构、8诊断中
@@ -759,9 +760,9 @@
    }
    public static void main(String[] args) {
        System.out.println(IdcardUtil.isValidCard("340621199310134818"));
        System.out.println(IdcardUtil.isValidCard("341621199310134818"));
        System.out.println(Constants.getSexByIdCard("41052119910310001X"));
//        System.out.println(IdcardUtil.isValidCard("340621199310134818"));
//        System.out.println(IdcardUtil.isValidCard("341621199310134818"));
//        System.out.println("{\"companyName\":\"应宝科技\",\"endtime\":\"2024-03-01 17:19:00\",\"erpId\":\"4D40185D5BC74A13821BE46EAF8B4179\",\"erpWithVisitDTOList\":[],\"faceImg\":\"20240304/1709518170325_742.jpg\",\"idcardNo\":\"342501199609300535\",\"idcardType\":0,\"name\":\"黄晋\",\"phone\":\"17756328697\",\"reason\":\"探险\",\"receptMemberId\":\"E7E514BD7DE3F27CE0530B630A0AEAE0\",\"starttime\":\"2024-03-01 13:18:00\"}");
    }
@@ -2379,4 +2380,5 @@
        }
    }
}
server/service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -3150,7 +3150,8 @@
    }
    public static void main(String[] args) {
    public static void main(String[] args) throws Exception{
        System.out.println(DateUtil.getPlusTime(new Date()));;
    }
    /**
server/service/src/main/java/com/doumee/dao/business/model/UnionApply.java
@@ -132,6 +132,10 @@
    @TableField(exist = false)
    private Integer serviceDays;
    @ApiModelProperty(value = "只查询待处理的申请单:1=加减保;2=换厂")
    @TableField(exist = false)
    private Integer hasApplying;
    @ApiModelProperty(value = "投保人数")
    @TableField(exist = false)
    private Integer insureNum;
server/service/src/main/java/com/doumee/service/business/InsuranceApplyService.java
@@ -7,9 +7,11 @@
import com.doumee.dao.business.dto.InsuranceApplyQueryDTO;
import com.doumee.dao.business.dto.SmsCheckDTO;
import com.doumee.dao.business.model.InsuranceApply;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import com.jzq.common.bean.sign.NotifyDataReq;
import java.util.Date;
import java.util.List;
/**
@@ -27,6 +29,7 @@
     */
    Integer create(InsuranceApply insuranceApply);
    Integer updateData(InsuranceApply insuranceApply);
    void checkMemberSolution(Integer solutionId,String idCode,String memberName,Date startTime,Date endTime);
    /**
     * 主键删除
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -25,12 +25,14 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doumee.service.business.InsuranceApplyService;
import com.doumee.service.business.SmsEmailService;
import com.doumee.service.business.third.SignService;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -349,7 +351,6 @@
        info = info.replace("${param}",param.getCheckInfo());
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), info,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  1;
    }
@@ -578,7 +579,182 @@
//                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到方案最新版本信息");
//            }
//        }
        for (ApplyChagneDetail detail : detailList) {
        List<ApplyChagneDetail> addList = detailList.stream().filter(f->Constants.equalsInteger(f.getType(),Constants.ZERO)).collect(Collectors.toList());
        List<ApplyChagneDetail> reduceList = detailList.stream().filter(f->Constants.equalsInteger(f.getType(),Constants.ONE)).collect(Collectors.toList());
        //减保业务
        for (ApplyChagneDetail detail:reduceList) {
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
            }
            //减保操作
            //查询员工是在主单下 是否存在生效中的数据
            ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda()
                    .eq(ApplyDetail::getApplyId, update.getApplyId())
                    .eq(ApplyDetail::getMemberId, detail.getMemberId())
                    .orderByDesc(ApplyDetail::getCreateDate)
                    .last("limit 1"));
            if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()) {
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】原保单信息有误,当前申请不支持减保处理!");
            }
            if(!(oldModel.getStartTime().getTime()<update.getDelValidTime().getTime()&& oldModel.getEndTime().getTime()>=update.getDelValidTime().getTime())){
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,用户【" + detail.getMemberName() + "】减保日期未在保单记录日期中!");
            }
            Date delValidTime = oldModel.getStartTime().compareTo(update.getDelValidTime())!=0?
                    DateUtil.getMontageDate(update.getDelValidTime(), 3):
                    DateUtil.getMontageDate(update.getDelValidTime(), 2);
            BigDecimal sumFee = Objects.isNull(insuranceApply.getServerCost())?
                    solutions.getPrice():
                    solutions.getPrice().add(insuranceApply.getServerCost());
            // 减保后 总费用
            BigDecimal updateFee =  Constants.reduceFee(
                    solutions,
                    sumFee
                    ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),oldModel.getStartTime(),delValidTime
            ) ;
            //当审批时间 大于 申请的时间时 计算实际减少金额 因为已扣金额会大于 应扣金额
            BigDecimal updateCurrentFee = BigDecimal.ZERO;
            if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),oldModel.getStartTime()) > 0) {
                //// 2024年5月8日17:37:23 修改 计算产生费用
                updateCurrentFee = Constants.produceFee(solutions,sumFee,insuranceApply.getStartTime(),insuranceApply.getEndTime(),
                        oldModel.getStartTime()
                );
            }
            UpdateWrapper<ApplyDetail> updateWrapper = new UpdateWrapper<ApplyDetail>();
            updateWrapper.lambda()
                    .setSql(" fee = " + updateFee)
                    .setSql(" current_fee = " + updateCurrentFee)
                    .set(ApplyDetail::getEndTime, delValidTime)
                    .set(ApplyDetail::getEditor, update.getEditor())
                    .set(ApplyDetail::getEditDate, update.getEditDate())
                    .eq(ApplyDetail::getId, oldModel.getId());
            if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
                    && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
                if(delValidTime.getTime()<=oldModel.getStartTime().getTime()){
                    updateFee  = BigDecimal.ZERO;
                    updateWrapper.lambda().set(ApplyDetail::getFee,updateFee)
                            .set(ApplyDetail::getChangeStatus,Constants.TWO);
                }else{
                    //标记数据已被替换
                    updateWrapper.lambda().set(ApplyDetail::getReduceMoney,solutions.getPrice().multiply(new BigDecimal(-1)))
                            .set(ApplyDetail::getChangeStatus,Constants.ONE);
                }
                detail.setApplyDetailId(oldModel.getId());
            }
            applyDetailJoinMapper.update(null, updateWrapper);
            totalFee = totalFee.add(updateFee).subtract(oldModel.getFee());
            currentFee = currentFee.add(updateCurrentFee);
            //修改 员工投保明细记录 历史数据
            memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
                    .setSql(" fee = " + updateFee)
                    .set(MemberInsurance::getEndTime, delValidTime)
                    .eq(MemberInsurance::getRelationId, oldModel.getId())
            );
            //修改业务明细行数据实际批单日期
            applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                    .set(ApplyChagneDetail::getFee,updateFee.subtract(oldModel.getFee()))
                    .set( ApplyChagneDetail::getEndTime, delValidTime)
                    .eq(ApplyChagneDetail::getId,detail.getId())
            );
            member.setApplyId(update.getApplyId());
            member.setDuId(detail.getDuId());
            member.setWorktypeId(detail.getWorktypeId());
            member.setStartTime(detail.getStartTime());
            member.setEndTime(detail.getEndTime());
            memberMapper.updateById(member);
        }
        //加保业务
        for (int i = 0; i < addList.size(); i++) {
            ApplyChagneDetail detail  = addList.get(i);
            Member member = memberMapper.selectById(detail.getMemberId());
            if (Objects.isNull(member)) {
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到员工数据");
            }
            //查询人员信息是否存在相同的方案下是否存在 冲突数据
            InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
                    member.getIdcardNo(),member.getName(),detail.getStartTime(),detail.getEndTime(),
                    applyDetailJoinMapper);
            //查询加保人员是否存在 冲突的 保单明细数据
            if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
                    .lambda()
                    .eq(ApplyDetail::getApplyId,update.getApplyId())
                    .eq(ApplyDetail::getIdcardNo,detail.getIdcardNo())
                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(),1))
                    .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(detail.getEndTime(),2))
            )>Constants.ZERO){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + detail.getMemberName() + "】存在日期冲突的数据");
            }
            //加保
            ApplyDetail add = new ApplyDetail();
            add.setApplyId(update.getApplyId());
            add.setValidCode(update.getValidCode());
            add.setFee(detail.getFee());
            add.setIsdeleted(Constants.ZERO);
            add.setCreator(update.getEditor());
            add.setCreateDate(update.getEditDate());
            add.setMemberId(detail.getMemberId());
            add.setMemberName(detail.getMemberName());
            add.setWorktypeId(detail.getWorktypeId());
            add.setIsdeleted(Constants.ZERO);
            add.setIdcardNo(detail.getIdcardNo());
            add.setSex(Constants.getSexByIdCard(detail.getIdcardNo()));
            add.setMemberName(detail.getMemberName());
            add.setRemark(detail.getRemark());
            add.setDuId(detail.getDuId());
            add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
            add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
            add.setFee(Constants.addFee(solutions,solutions.getPrice(),insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),update.getApplyStartTime(),insuranceApply.getEndTime()));
            add.setChangeStatus(Constants.ZERO);
            if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
                    && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
                add.setReduceId(reduceList.get(i).getId());
            }
            if(new Date().compareTo(DateUtil.getMontageDate(detail.getStartTime(), 2))>=0){
                //2024年5月8日17:37:23 修改 计算产生费用
                add.setCurrentFee(
                        Constants.produceFee(solutions,add.getFee(),add.getStartTime(),add.getEndTime(),add.getStartTime())
                );
            }else{
                add.setCurrentFee(BigDecimal.ZERO);
            }
            applyDetailJoinMapper.insert(add);
            totalFee = totalFee.add(add.getFee());
            currentFee = currentFee.add(add.getCurrentFee());
            MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId(),solutions.getId());
            memberInsurance.setStartTime(add.getStartTime());
            memberInsurance.setEndTime(add.getEndTime());
            memberInsurance.setRelationType(Constants.ONE);
            memberInsuranceList.add(memberInsurance);
            applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                    .set(ApplyChagneDetail::getFee,add.getFee())
                    .set(ApplyChagneDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(), 1))
                    .eq(ApplyChagneDetail::getId,detail.getId())
            );
            member.setApplyId(update.getApplyId());
            member.setDuId(detail.getDuId());
            member.setWorktypeId(detail.getWorktypeId());
            member.setStartTime(detail.getStartTime());
            member.setEndTime(detail.getEndTime());
            memberMapper.updateById(member);
        }
        /*for (ApplyChagneDetail detail : detailList) {
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
@@ -639,9 +815,6 @@
                        .eq(ApplyChagneDetail::getId,detail.getId())
                );
//                if(1==1){
//                    throw new BusinessException(ResponseStatus.SERVER_ERROR);
//                }
            } else {
                    //减保操作
@@ -680,15 +853,30 @@
                        );
                    }
                    applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                    UpdateWrapper<ApplyDetail> updateWrapper = new UpdateWrapper<ApplyDetail>();
                    updateWrapper.lambda()
                            .setSql(" fee = " + updateFee)
                            .setSql(" current_fee = " + updateCurrentFee)
                            .set(ApplyDetail::getEndTime, delValidTime)
                            .set(ApplyDetail::getEditor, update.getEditor())
                            .set(ApplyDetail::getEditDate, update.getEditDate())
                            .eq(ApplyDetail::getId, oldModel.getId());
                            .eq(ApplyDetail::getId, oldModel.getId())
                    );
                    if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
                            && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
                        if(delValidTime.getTime()<=oldModel.getStartTime().getTime()){
                            updateFee  = BigDecimal.ZERO;
                            updateWrapper.lambda().set(ApplyDetail::getFee,updateFee)
                                    .set(ApplyDetail::getChangeStatus,Constants.TWO);
                        }else{
                            //标记数据已被替换
                            updateWrapper.lambda().set(ApplyDetail::getReduceMoney,solutions.getPrice().multiply(new BigDecimal(-1)))
                                    .set(ApplyDetail::getChangeStatus,Constants.ONE);
                        }
                    }
                    applyDetailJoinMapper.update(null, updateWrapper);
                    totalFee = totalFee.add(updateFee).subtract(oldModel.getFee());
                    currentFee = currentFee.add(updateCurrentFee);
@@ -714,7 +902,8 @@
            member.setEndTime(detail.getEndTime());
            memberMapper.updateById(member);
        }
        }*/
        if (memberInsuranceList != null && memberInsuranceList.size() > 0) {
            memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
        }
@@ -911,6 +1100,12 @@
            }else{
                applyChange.setDelValidTime(applyChange.getValidTime());
            }
            //仅支持替换  保证加减保日期为同一天
            if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
                applyChange.setApplyStartTime(
                        applyChange.getDelValidTime()
                );
            }
        }else{
            applyChange.setApplyStartTime(applyChange.getValidTime());
        }
@@ -1010,9 +1205,35 @@
        )>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "存在进行中的加减保/换厂申请");
        };
        if(applyChange.getType().equals(Constants.ZERO)){
            if(Objects.nonNull(solutions.getAddValidDays())){
                applyChange.setApplyStartTime(
                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
                );
            }else{
                applyChange.setApplyStartTime(applyChange.getValidTime());
            }
            if(Objects.nonNull(solutions.getDelValidDays())){
                applyChange.setDelValidTime(
                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
                );
            }else{
                applyChange.setDelValidTime(applyChange.getValidTime());
            }
            //仅支持替换  保证加减保日期为同一天
            if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
                applyChange.setApplyStartTime(
                        applyChange.getDelValidTime()
                );
            }
        }else{
            applyChange.setApplyStartTime(applyChange.getValidTime());
        }
        applyChange.setEditDate(new Date());
        applyChange.setEditor(loginUserInfo.getId());
        applyChange.setApplyStartTime(applyChange.getValidTime());
        applyChange.setStatus(Constants.ZERO);
        //删除历史数据
        applyChagneDetailJoinMapper.delete(new QueryWrapper<ApplyChagneDetail>().lambda().eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
@@ -1037,10 +1258,13 @@
    }
    public BigDecimal dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){
        if(Objects.nonNull(solutions.getDelOnlyReplace())&& solutions.getDelOnlyReplace().equals(Constants.ONE)){
            if(applyChange.getDelDetailList().size() > applyChange.getAddDetailList().size()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案仅支持替换(减保人数不得大于加保人数)");
    public BigDecimal dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply
            ,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){
        if(Constants.equalsInteger(applyChange.getType(),Constants.ZERO)){
            if(Objects.nonNull(solutions.getDelOnlyReplace())&& solutions.getDelOnlyReplace().equals(Constants.ONE)){
                if(applyChange.getDelDetailList().size() > applyChange.getAddDetailList().size()){
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案仅支持替换(减保人数不得大于加保人数)");
                }
            }
        }
        //查询保险方案下的所有派遣单位
@@ -1069,7 +1293,9 @@
        ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO = new ApplyChangeCyclePriceDTO();
        applyChangeCyclePriceDTO.setApplyId(insuranceApply.getId());
        //减保数据
        List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
        //加保数据
        List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
@@ -1084,22 +1310,16 @@
                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"对不起,人员录入数据存在相同数据!");
            }
            //加保明细数据 计算金额  根据批单时间 计算
//            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),1));
//            CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
//            BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
            BigDecimal sumPrice = Objects.isNull(insuranceApply.getServerCost())?solutions.getPrice():solutions.getPrice().add(insuranceApply.getServerCost());
            BigDecimal detailFee = Constants.addFee(solutions,
                    sumPrice
                    ,insuranceApply.getStartTime(),insuranceApply.getFinalEndTime(),
                    applyChange.getApplyStartTime(),insuranceApply.getEndTime());
            this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo,detailFee);
            this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo,detailFee,delDetailList.size());
            fee = addDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add);
        }
        //减保数据
        List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
        if (CollectionUtils.isNotEmpty(delDetailList)) {
            //验证是否存在重复数据
            List<String> idcarNo = delDetailList.stream().map(m->m.getIdcardNo()).collect(Collectors.toList());
@@ -1113,6 +1333,7 @@
            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo, BigDecimal.ZERO,
                    DateUtil.getMontageDate(applyChange.getDelValidTime(),3));
            fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
//            fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getReduceMoney).reduce(BigDecimal.ZERO,BigDecimal::add));
        }
       
@@ -1206,6 +1427,9 @@
            if (applyChange.getValidTime().compareTo(applyDetail.getEndTime()) > 0) {
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "减保人员【" + applyChagneDetail.getMemberName() + "】保单保障日期至:【" + applyDetail.getEndTime() + "】无法通过本次申请");
            }
            if(!Constants.equalsInteger(applyDetail.getChangeStatus(),Constants.ZERO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"减保人员【" + applyChagneDetail.getMemberName() + "】保单信息异常,数据已被减保无法再次减保");
            }
            applyChagneDetail.setPrice(applyDetail.getPrice());
            applyChagneDetail.setCreateDate(new Date());
            applyChagneDetail.setCreator(loginUserInfo.getId());
@@ -1258,14 +1482,20 @@
     */
    public void addChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> addDetailList,
                                List<DuWorktype> duWorktypeList,List<DuSolution> duSolutionList,
                                InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee){
        for (ApplyChagneDetail applyChagneDetail : addDetailList) {
                                InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee,Integer delSize){
        for (int i = 0; i < addDetailList.size(); i++) {
            ApplyChagneDetail applyChagneDetail = addDetailList.get(i);
            if (    Objects.isNull(applyChagneDetail.getDuId())
                    || Objects.isNull(applyChagneDetail.getWorktypeId())
                    || StringUtils.isBlank(applyChagneDetail.getIdcardNo())
            ) {
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失");
            }
            //查询人员信息是否存在相同的方案下是否存在 冲突数据
            InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
                    applyChagneDetail.getMemberIdcardNo(),applyChagneDetail.getMemberName(),insuranceApply.getStartTime(),insuranceApply.getEndTime(),
                    applyDetailJoinMapper);
            //查询加保人员是否存在 冲突的 保单明细数据
            if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
                    .lambda()
@@ -1380,7 +1610,13 @@
                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "【" + applyChagneDetail.getMemberName() + "】员工工种信息未查询到!");
            }
            applyChagneDetail.setMemberId(member.getId());
            applyChagneDetail.setFee(detailFee);
            //如果是减保业务为仅替换 且 方案的扣费周期和总周期相等 则处理减保费用
            if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
                    && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit()) && delSize> i){
                applyChagneDetail.setFee(BigDecimal.ZERO);
            }else{
                applyChagneDetail.setFee(detailFee);
            }
            applyChagneDetailJoinMapper.insert(applyChagneDetail);
        }
    }
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -308,6 +308,10 @@
        if(CollectionUtils.isNotEmpty(applyDetailList)){
            List<MemberInsurance> memberInsuranceList = new ArrayList<>();
            for (ApplyDetail applyDetail:applyDetailList) {
                //查询人员信息是否存在相同的方案下是否存在 冲突数据
                this.checkMemberSolution(applyDetail.getSolutionId(),applyDetail.getIdcardNo(),applyDetail.getMemberName(),update.getStartTime(),update.getEndTime());
                MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId());
                memberInsurance.setRelationType(Constants.ZERO);
                memberInsuranceList.add(memberInsurance);
@@ -1944,6 +1948,8 @@
                    member.setWorktypeId(applyDetail.getWorktypeId());
                    addMemberList.add(member);
                }
                //查询人员信息是否存在相同的方案下是否存在 冲突数据
                this.checkMemberSolution(solutions.getId(),member.getIdcardNo(),member.getName(),insuranceApply.getStartTime(),insuranceApply.getEndTime());
            }
            if(CollectionUtils.isNotEmpty(addMemberList)){
                memberJoinMapper.insertBatchSomeColumn(addMemberList);
@@ -1959,6 +1965,7 @@
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,投保员工信息数据缺失,请按照要求填写员工的有效信息!");
                }
                applyDetail.setChangeStatus(Constants.ZERO);
                applyDetail.setCreateDate(new Date());
                applyDetail.setCreator(loginUserInfo.getId());
                applyDetail.setIsdeleted(Constants.ZERO);
@@ -2029,6 +2036,75 @@
        }
    }
    /**
     * 查询 会员信息在方案下是否存在冲突数据
     * @param solutionId
     * @param startTime
     * @param endTime
     */
    @Override
    public void checkMemberSolution(Integer solutionId,String idCode,String memberName,Date startTime,Date endTime){
        try {
            List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,
                    new MPJLambdaWrapper<ApplyDetail>()
                            .selectAll(ApplyDetail.class)
                            .selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode)
                            .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
                            .eq(ApplyDetail::getIdcardNo,idCode)
                            .eq(InsuranceApply::getSolutionId,solutionId)
                            .notIn(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD
                                    ,Constants.InsuranceApplyStatus.PLATFORM_RETURN
                                    ,Constants.InsuranceApplyStatus.FAIL_RETURN
                                    ,Constants.InsuranceApplyStatus.CLOSE
                                    ,Constants.InsuranceApplyStatus.WTB_RETURN
                                    ,Constants.InsuranceApplyStatus.WTB_CLOSED )
                            .apply(" ( " +
                                    " '"+DateUtil.getPlusTime(startTime)+"'  <= t.start_time AND t.start_time < '"+DateUtil.getPlusTime(endTime)+"' " +
                                    " or " +
                                    "  ( '"+DateUtil.getPlusTime(startTime)+"' < t.end_time AND t.end_time < '"+DateUtil.getPlusTime(endTime)+"' )  " +
                                    " or " +
                                    " ( '"+DateUtil.getPlusTime(startTime)+"' > t.start_time AND '"+DateUtil.getPlusTime(endTime)+"' < t.end_time )" +
                                    " ) " ));
            if(applyDetailList.size() >Constants.ZERO){
                ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO);
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该用户【"+memberName+" "+idCode+"】在保单【"+applyDetail.getApplyCode()+"】下已存在与本次提报冲突的日期");
            };
        }catch (Exception e){
        }
    }
    public static void checkStaticMemberSolution(Integer solutionId,String idCode,String memberName,Date startTime,Date endTime,ApplyDetailJoinMapper applyDetailJoinMapper){
        try {
            List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,
                    new MPJLambdaWrapper<ApplyDetail>()
                            .selectAll(ApplyDetail.class)
                            .selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode)
                            .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
                            .eq(ApplyDetail::getIdcardNo,idCode)
                            .eq(InsuranceApply::getSolutionId,solutionId)
                            .notIn(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD
                                    ,Constants.InsuranceApplyStatus.PLATFORM_RETURN
                                    ,Constants.InsuranceApplyStatus.FAIL_RETURN
                                    ,Constants.InsuranceApplyStatus.CLOSE
                                    ,Constants.InsuranceApplyStatus.WTB_RETURN
                                    ,Constants.InsuranceApplyStatus.WTB_CLOSED )
                            .apply(" ( " +
                                    " '"+DateUtil.getPlusTime(startTime)+"'  <= t.start_time AND t.start_time < '"+DateUtil.getPlusTime(endTime)+"' " +
                                    " or " +
                                    "  ( '"+DateUtil.getPlusTime(startTime)+"' < t.end_time AND t.end_time < '"+DateUtil.getPlusTime(endTime)+"' )  " +
                                    " or " +
                                    " ( '"+DateUtil.getPlusTime(startTime)+"' > t.start_time AND '"+DateUtil.getPlusTime(endTime)+"' < t.end_time )" +
                                    " ) " ));
            if(applyDetailList.size() >Constants.ZERO){
                ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO);
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该用户【"+memberName+" "+idCode+"】在保单【"+applyDetail.getApplyCode()+"】下已存在与本次提报冲突的日期");
            };
        }catch (Exception e){
        }
    }
    @Override
    public void deleteById(Integer id) {
@@ -2124,7 +2200,7 @@
        queryWrapper.selectAs(Solutions::getTimeUnit,InsuranceApply::getTimeUnit);
        queryWrapper.select(" DATEDIFF( t.END_TIME ,now()  ) AS loseEfficacyDays  ");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id   ) as insureNum");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum");
        if(!Objects.isNull(pageWrap.getModel())&&!Objects.isNull(pageWrap.getModel().getType())){
            queryWrapper.select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney");
            queryWrapper.select(" ( select td.CREATE_DATE from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status = 1 and td.INSURANCE_APPLY_ID = t.id order by td.CREATE_DATE desc limit 1 ) as taxesLast ");
@@ -2251,6 +2327,7 @@
        queryWrapper.selectAs(Solutions::getName,InsuranceApply::getSolutionsName);
        queryWrapper.selectAs(Solutions::getType,InsuranceApply::getSolutionType);
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id ) as insureNum");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum");
        queryWrapper.select(" ( select max(ac.APPLY_START_TIME) from apply_change ac  where ac.apply_id = t.id and ac.status = 2 ) as lastChangeDate");
        queryWrapper.select(" ( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ) as taxesMoney ");
        queryWrapper.select(" ( select td.CREATE_DATE from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id order by td.CREATE_DATE desc limit 1 ) as taxesLast ");
@@ -2396,7 +2473,7 @@
                .selectAs(Company::getName,InsuranceApply::getCompanyName)
                .select(" ( select max(ac.APPLY_START_TIME) from apply_change ac  where ac.apply_id = t.id and ac.status = 2 ) as lastChangeDate")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id ) as insureNum")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .select(" t3.name as shopName")
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
@@ -2520,7 +2597,7 @@
                .selectAs(Solutions::getName,InsuranceApply::getSolutionsName)
                .selectAs(Solutions::getType,InsuranceApply::getSolutionType)
                .selectAs(Company::getName,InsuranceApply::getCompanyName)
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                .eq(InsuranceApply::getId,model.getId())
@@ -2713,6 +2790,7 @@
                BigDecimal sumAmount = BigDecimal.ZERO;
                List<ApplyDetail> applyDetailList = applyDetailMapper
                        .selectList(new QueryWrapper<ApplyDetail>().lambda()
                                .eq(ApplyDetail::getChangeStatus,Constants.ZERO)
                                .eq(ApplyDetail::getApplyId,insuranceApply.getId()));
                if(CollectionUtils.isNotEmpty(applyDetailList)){
                    for (ApplyDetail applyDetail: applyDetailList) {
server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
@@ -157,11 +157,13 @@
                .selectAs(Solutions::getSpecialAgreement,UnionApply::getSpecialAgreement)
                .selectAs(Solutions::getSpecialInfo,UnionApply::getSpecialInfo);
        queryWrapper.select("(select count(distinct(b.MEMBER_ID)) from apply_detail b where b.isdeleted=0 and b.union_apply_id=t.id) as insureNum ");
        queryWrapper.select("(select count(distinct(b.MEMBER_ID)) from apply_detail b where b.isdeleted=0   and b.END_TIME > now() and b.union_apply_id=t.id) as guaranteeNum ");
        queryWrapper.select(" ( select count(DISTINCT(b.MEMBER_ID)) from apply_detail b inner join insurance_apply a on b.apply_id = a.id  and a.status in ( 5 , 27 )  where b.union_apply_id=t.id and b.END_TIME > now() ) as guaranteeNum");
        if(pageWrap.getModel().getQueryFlag() == 1){
            queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
                    "and a.status = "+Constants.ApplyChangeStatus.CHECHED_PASSED.getKey()+" and a.type = 0  ) as addApplyNum ");
        }else  if(pageWrap.getModel().getQueryFlag() ==2){
            queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id=t.id " +
                    "and a.status = "+Constants.ApplyChangeStatus.CHECHED_PASSED.getKey()+" and a.type = 1  ) as changeApplyNum ");
@@ -177,11 +179,26 @@
        if(Constants.equalsInteger(user.getType(),Constants.TWO)){
            queryWrapper.eq(UnionApply::getCompanyId, user.getCompanyId());
        }
        if (pageWrap.getModel().getId() != null) {
            queryWrapper.eq(UnionApply::getId, pageWrap.getModel().getId());
        }
        if (pageWrap.getModel().getSolutionId() != null) {
            queryWrapper.eq(UnionApply::getSolutionId, pageWrap.getModel().getSolutionId());
        }
        if (pageWrap.getModel().getHasApplying() != null) {
            if(Constants.equalsInteger(pageWrap.getModel().getHasApplying() ,Constants.ONE)){
                queryWrapper.exists(
                        " ( select 1  from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id= t.id " +
                                "        and a.status = "+Constants.ApplyChangeStatus.CHECHED_PASSED.getKey()+" and a.type = 0  ) "
                );
            }else if(Constants.equalsInteger(pageWrap.getModel().getHasApplying() ,Constants.TWO)){
                queryWrapper.exists(
                        " ( select 1  from apply_change a inner join insurance_apply b on a.apply_id = b.id  where b.union_apply_id= t.id " +
                                "        and a.status = "+Constants.ApplyChangeStatus.CHECHED_PASSED.getKey()+" and a.type = 1   ) "
                );
            }
        }
        if (pageWrap.getModel().getCreator() != null) {
            queryWrapper.eq(UnionApply::getCreator, pageWrap.getModel().getCreator());
@@ -318,7 +335,7 @@
                        .selectAs(Solutions::getName,UnionApply::getSolutionName)
                        .selectAs(Company::getName,UnionApply::getCompanyName)
                        .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.UNION_APPLY_ID = t.id ) as insureNum")
                        .select("(select count(distinct(b.MEMBER_ID)) from apply_detail b where b.isdeleted=0   and b.END_TIME > now() and b.union_apply_id=t.id) as guaranteeNum ")
                .select(" ( select count(DISTINCT(b.MEMBER_ID)) from apply_detail b inner join insurance_apply a on b.apply_id = a.id  and a.status in ( 5 , 27 )  where b.union_apply_id=t.id and b.END_TIME > now() ) as guaranteeNum")
                        .select(" ( select group_concat(DISTINCT(cd.name)) from insurance_apply ad left join company cd on ad.company_id = cd.id where ad.UNION_APPLY_ID = t.id ) as companyNames")
                        .leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId)
                        .leftJoin(Company.class,Company::getId,UnionApply::getCompanyId)
@@ -460,8 +477,11 @@
        Integer maxDays = DateUtil.calculateBetween(saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate(),0);
        List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda()
        List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,new MPJLambdaWrapper<ApplyDetail>()
                .select(ApplyDetail::getId,ApplyDetail::getPrice,ApplyDetail::getStartTime,ApplyDetail::getEndTime,ApplyDetail::getFee)
                .selectAs(Member::getIdcardNo,ApplyDetail::getIdcardNo)
                .selectAs(Member::getName,ApplyDetail::getMemberName)
                .leftJoin(Member.class,Member::getId,ApplyDetail::getMemberId)
                .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds())
                .eq(ApplyDetail::getIsdeleted,Constants.ZERO));
        if(applyDetailList.size()==0){
@@ -469,14 +489,16 @@
        }
        BigDecimal fee = BigDecimal.ZERO;
        for (ApplyDetail applyDetail:applyDetailList) {
            //查询人员信息是否存在相同的方案下是否存在 冲突数据
            InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
                    applyDetail.getIdcardNo(),applyDetail.getMemberName(),unionApply.getStartTime(),unionApply.getEndTime(),
                    applyDetailJoinMapper);
            fee =fee.add(
                    Constants.reduceFee(solutions,solutions.getPrice(),applyDetail.getStartTime(),applyDetail.getEndTime(),saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate())
            );
        }
        unionApply.setFee(fee);
//        unionApply.setFee(applyDetailList.stream()
//                .map(i->Constants.formatBigdecimal(i.getPrice()).multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
        unionApplyMapper.insert(unionApply);
@@ -856,6 +878,12 @@
                List<MemberInsurance> memberInsuranceList = new ArrayList<>();
                for (ApplyDetail applyDetail:applyDetailList.stream()
                        .filter(m->Constants.equalsInteger(m.getApplyId(),(insuranceApply.getId()))).collect(Collectors.toList())) {
                    //查询人员信息是否存在相同的方案下是否存在 冲突数据
                    InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
                            applyDetail.getIdcardNo(),applyDetail.getMemberName(),unionApply.getStartTime(),unionApply.getEndTime(),
                            applyDetailJoinMapper);
                    applyDetail.setPrice(price);
                    applyDetail.setFee(price.multiply(new BigDecimal(maxDays)).add(serverCost));
                    applyDetail.setStartTime(unionApplyBXDDTO.getStartTime());
server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
@@ -176,6 +176,7 @@
                            .ne(ApplyChagneDetail::getType,Constants.TWO)
                            .eq(ApplyChagneDetail::getUnionChangeId,unionChange.getId()));
            BigDecimal fee = applyChangeList.stream().map(m->m.getFee()).reduce(BigDecimal.ZERO,BigDecimal::add);
//            fee = fee.add(applyChangeList.stream().map(m->Objects.nonNull(m.getReduceMoney())?m.getReduceMoney():BigDecimal.ZERO).reduce(BigDecimal.ZERO,BigDecimal::add));
//            for (ApplyChagneDetail applyChagneDetail:applyChangeList) {
//                Integer maxDays = DateUtil.calculateBetween(unionChange.getApplyStartTime(),applyChagneDetail.getEndTime(),0);
//                if(applyChagneDetail.getType().equals(Constants.ONE)){
@@ -796,7 +797,6 @@
                                .eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
                this.dealApplyChangeDetail(applyChange,allList,solutions);
                applyChangeJoinMapper.updateById(applyChange);
                //存储批单完成信息
                Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_APPROVE;
                String info = "";
@@ -827,9 +827,9 @@
                ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
        applyLogMapper.insert(log);
//        if(true){
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED);
//        }
        if(true){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED);
        }
    }
@@ -841,19 +841,36 @@
        bigDecimalVO.setTotalFee(BigDecimal.ZERO);
        bigDecimalVO.setCurrentFee(BigDecimal.ZERO);
        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId());
        for (ApplyChagneDetail detail:applyChagneDetailList) {
        List<ApplyChagneDetail> addList = applyChagneDetailList.stream().filter(f->Constants.equalsInteger(f.getType(),Constants.ZERO)).collect(Collectors.toList());
        List<ApplyChagneDetail> reduceList = applyChagneDetailList.stream().filter(f->Constants.equalsInteger(f.getType(),Constants.ONE)).collect(Collectors.toList());
        List<ApplyChagneDetail> changeList = applyChagneDetailList.stream().filter(f->Constants.equalsInteger(f.getType(),Constants.TWO)).collect(Collectors.toList());
        for (ApplyChagneDetail detail:reduceList) {
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
            }
            if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) {
               this.addChangeDetailData(applyChange,detail,insuranceApply,solutions,bigDecimalVO);
            }else if(Constants.equalsInteger(detail.getType(),Constants.ONE)){
                this.reduceChangeDetailData(applyChange,detail,insuranceApply,solutions,bigDecimalVO);
            }else{
                this.otherChangeDetailData(applyChange,detail,insuranceApply);
            }
            this.reduceChangeDetailData(applyChange,detail,insuranceApply,solutions,bigDecimalVO);
        }
        for (int i = 0; i < addList.size(); i++) {
            ApplyChagneDetail detail = addList.get(i);
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
            }
            this.addChangeDetailData(applyChange,detail,insuranceApply,solutions,bigDecimalVO,reduceList,i);
        }
        for (ApplyChagneDetail detail:changeList) {
            Member member = memberMapper.selectById(detail.getMemberId());
            if(Objects.isNull(member)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到员工数据");
            }
            this.otherChangeDetailData(applyChange,detail,insuranceApply);
        }
        //如果保单金额发生编码,更新总保单金额
        insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
                .setSql(bigDecimalVO.getTotalFee().compareTo(new BigDecimal(0)) != 0," fee = ifnull(fee,0)+" + bigDecimalVO.getTotalFee())
@@ -872,17 +889,12 @@
     * @param detail
     */
    public void addChangeDetailData(ApplyChange applyChange, ApplyChagneDetail detail,InsuranceApply insuranceApply,Solutions solutions
            , BigDecimalVO bigDecimalVO){
        //查询加保人员是否存在 冲突的 保单明细数据
        if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>()
                .lambda()
                .eq(ApplyDetail::getApplyId,applyChange.getApplyId())
                .eq(ApplyDetail::getIdcardNo,detail.getIdcardNo())
                .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))
                .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(detail.getEndTime(),2))
        )>Constants.ZERO){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + detail.getMemberName() + "】存在日期冲突的数据");
        }
            , BigDecimalVO bigDecimalVO,List<ApplyChagneDetail> reduceList,Integer i){
        //查询人员信息是否存在相同的方案下是否存在 冲突数据
        InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
                detail.getIdcardNo(),detail.getMemberName(),DateUtil.getMontageDate(applyChange.getApplyStartTime(),1),DateUtil.getMontageDate(detail.getEndTime(),2),
                applyDetailJoinMapper);
        //加保
        ApplyDetail add = new ApplyDetail();
        BigDecimal fee = Objects.isNull(insuranceApply.getServerCost())?
@@ -916,17 +928,23 @@
        add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
        add.setRemark(detail.getRemark());
        add.setUnionApplyId(insuranceApply.getUnionApplyId());
        add.setChangeStatus(Constants.ZERO);
        if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
                && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())  && i < reduceList.size() ){
            add.setReduceId(reduceList.get(i).getApplyDetailId());
        }
        applyDetailJoinMapper.insert(add);
        detail.setFee(add.getFee());
        detail.setFee(Objects.isNull(add.getReduceId())?add.getFee():BigDecimal.ZERO);
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(add.getFee()));
        //如果不是替换业务的加保数据 则添加实际产生费用
        if(Objects.isNull(add.getReduceId())){
            bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(add.getCurrentFee()));
        }
        applyChagneDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                .set(ApplyChagneDetail::getFee,add.getFee())
                .set(ApplyChagneDetail::getFee,detail.getFee())
                .set(ApplyChagneDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1))
                .eq(ApplyChagneDetail::getId,detail.getId())
        );
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(add.getFee()));
        bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(add.getCurrentFee()));
        MemberInsurance memberInsurance = new MemberInsurance(detail, applyChange, applyChange.getEditor(), add.getId(),applyChange.getSolutionsId());
        memberInsurance.setStartTime(add.getStartTime());
        memberInsurance.setEndTime(add.getEndTime());
@@ -985,19 +1003,37 @@
                pullFee = reduceFee;
            }
        }
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(reduceFee).subtract(oldModel.getFee()));
        bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(pullFee).subtract(oldModel.getCurrentFee()));
        applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                .setSql(" fee =  " + reduceFee)
                .setSql(" current_fee =  " + pullFee)
        UpdateWrapper<ApplyDetail> updateWrapper = new UpdateWrapper<ApplyDetail>();
        updateWrapper.lambda()
                .setSql(" fee = " + reduceFee)
                .setSql(" current_fee = " + pullFee)
                .set(ApplyDetail::getEndTime, reduceDate)
                .set(ApplyDetail::getEditor, applyChange.getEditor())
                .set(ApplyDetail::getEditDate, applyChange.getEditDate())
                .eq(ApplyDetail::getId, oldModel.getId())
        );
                .eq(ApplyDetail::getId, oldModel.getId());
        BigDecimal reduceMoney = BigDecimal.ZERO;
        if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)
                && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit())){
            if(reduceDate.getTime()<=oldModel.getStartTime().getTime()){
                reduceFee  = BigDecimal.ZERO;
                updateWrapper.lambda().set(ApplyDetail::getFee,reduceFee)
                        .set(ApplyDetail::getChangeStatus,Constants.TWO);
            }else{
                reduceMoney = solutions.getPrice().multiply(new BigDecimal(-1));
                //标记数据已被替换
                updateWrapper.lambda().set(ApplyDetail::getReduceMoney,reduceMoney)
                        .set(ApplyDetail::getChangeStatus,Constants.ONE);
            }
            detail.setApplyDetailId(oldModel.getId());
        }
        bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(reduceFee).subtract(oldModel.getFee()).add(reduceMoney));
        bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(pullFee).subtract(oldModel.getCurrentFee()));
//        //如果减保的数据 已经结束 则此数据要去掉 减除的实际差值 reduceMoney
//        if(System.currentTimeMillis()>detail.getEndTime().getTime()){
//            bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(reduceMoney));
//        }
        applyDetailJoinMapper.update(null, updateWrapper);
        //修改 员工投保明细记录 历史数据
        memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
                .setSql(" fee = " + reduceFee)
@@ -1021,6 +1057,7 @@
                .set(ApplyChagneDetail::getEndTime,reduceDate)
                .eq(ApplyChagneDetail::getId,detail.getId())
        );
        detail.setApplyDetailId(oldModel.getId());
    }
    public void otherChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,InsuranceApply insuranceApply){