jiangping
2024-06-21 69c2b50ded530c6bc003c6ddbeaca786d7823270
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -681,7 +681,7 @@
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到员工数据");
            }
            //查询人员信息是否存在相同的方案下是否存在 冲突数据
            InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
            InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getBaseId(),
                    member.getIdcardNo(),member.getName(),detail.getStartTime(),detail.getEndTime(),
                    applyDetailJoinMapper);
@@ -690,6 +690,13 @@
                    .lambda()
                    .eq(ApplyDetail::getApplyId,update.getApplyId())
                    .eq(ApplyDetail::getIdcardNo,detail.getIdcardNo())
//                    .apply(" ( " +
//                            " '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(update.getApplyStartTime(),1))+"'  <= t.start_time AND t.start_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(detail.getEndTime(),2))+"' " +
//                            " or " +
//                            "  ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(update.getApplyStartTime(),1))+"' < t.end_time AND t.end_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(detail.getEndTime(),2))+"' )  " +
//                            " or " +
//                            " ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(update.getApplyStartTime(),1))+"' > t.start_time AND '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(detail.getEndTime(),2))+"' < t.end_time )" +
//                            " ) " )
                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(),1))
                    .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(detail.getEndTime(),2))
            )>Constants.ZERO){
@@ -717,7 +724,7 @@
            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())){
                    && Constants.equalsInteger(solutions.getTimeUnit(),solutions.getInsureCycleUnit()) && i < reduceList.size()){
                add.setReduceId(reduceList.get(i).getId());
            }
            if(new Date().compareTo(DateUtil.getMontageDate(detail.getStartTime(), 2))>=0){
@@ -1044,10 +1051,10 @@
        if (DateUtil.compareDate(insuranceApply.getEndTime(),new Date()) >= Constants.ZERO ) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "保单已过保,无法进行该操作");
        }
        if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) >= Constants.ZERO) {
            //如果保单尚未生效,设置期望生效日期为保单生效开始时间
            applyChange.setValidTime(insuranceApply.getStartTime());
        }
//        if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) >= Constants.ZERO) {
//            //如果保单尚未生效,设置期望生效日期为保单生效开始时间
//            applyChange.setValidTime(insuranceApply.getStartTime());
//        }
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案");
@@ -1159,9 +1166,9 @@
        ) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "保单已过保,无法进行该操作");
        }
        if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) > Constants.ZERO) {
            applyChange.setValidTime(insuranceApply.getStartTime());
        }
//        if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) > Constants.ZERO) {
//            applyChange.setValidTime(insuranceApply.getStartTime());
//        }
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到保险方案");
@@ -1236,7 +1243,7 @@
            );
        }else{
            //如果保单未生或者没有配置生效天数,设置期望生效日期为保单生效开始时间
            applyChange.setApplyStartTime(applyChange.getValidTime());
            applyChange.setApplyStartTime(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()?applyChange.getValidTime():insuranceApply.getStartTime());
        }
        if(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()
                &&Objects.nonNull(solutions.getDelValidDays())){
@@ -1244,7 +1251,7 @@
                    DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
            );
        }else{
            applyChange.setDelValidTime(applyChange.getValidTime());
            applyChange.setDelValidTime(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()?applyChange.getValidTime():insuranceApply.getStartTime());
        }
        //仅支持替换  保证加减保日期为同一天
        if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
@@ -1490,7 +1497,7 @@
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "加保人员【" + applyChagneDetail.getMemberName() + "】必填项缺失");
            }
            //查询人员信息是否存在相同的方案下是否存在 冲突数据
            InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getId(),
            InsuranceApplyServiceImpl.checkStaticMemberSolution(solutions.getBaseId(),
                    applyChagneDetail.getMemberIdcardNo(),applyChagneDetail.getMemberName(),insuranceApply.getStartTime(),insuranceApply.getEndTime(),
                    applyDetailJoinMapper);
@@ -1499,9 +1506,15 @@
                    .lambda()
                    .eq(ApplyDetail::getApplyId,applyChange.getApplyId())
                    .eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo())
//                    .apply(" ( " +
//                            " '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))+"'  <= t.start_time AND t.start_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2))+"' " +
//                            " or " +
//                            "  ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))+"' < t.end_time AND t.end_time < '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2))+"' )  " +
//                            " or " +
//                            " ( '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))+"' > t.start_time AND '"+DateUtil.getLongDateTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2))+"' < t.end_time )" +
//                            " ) " )
                    .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))
                            .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(insuranceApply.getEndTime(),2))
                    //.ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),3))
            )>Constants.ZERO){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前保单下,加保人员【" + applyChagneDetail.getMemberName() + "】存在日期冲突的数据");
            }
@@ -2118,6 +2131,7 @@
                .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
                .selectAs(Solutions::getType,ApplyChange::getSolutionType)
                .selectAs(Solutions::getId,ApplyChange::getSolutionsId)
                .selectAs(Solutions::getDelOnlyReplace,ApplyChange::getDelOnlyReplace)
                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0  )",ApplyChange::getAddNum)
                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1  )",ApplyChange::getDelNum)
                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2  )",ApplyChange::getChangeNum)