jiangping
2024-06-18 2d513a9f0e1ebb83e529973e9e79befdaea7d740
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -881,10 +881,10 @@
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到企业分配保险方案信息");
        }
        //申请时间必须处于保单的时间范围内
        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChange.getValidTime()) >= Constants.ZERO
                && DateUtil.compareDate( applyChange.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
        }
//        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChange.getValidTime()) >= Constants.ZERO
//                && DateUtil.compareDate( applyChange.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
//        }
        //查询保单下是否存在进行中的加减保/换厂单据
        if(applyChangeMapper.selectCount(new QueryWrapper<ApplyChange>().lambda()
                .eq(ApplyChange::getApplyId,insuranceApply.getId())
@@ -1002,10 +1002,10 @@
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到企业分配保险方案信息");
        }
        //申请时间必须处于保单的时间范围内
        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChange.getValidTime()) >= Constants.ZERO
                && DateUtil.compareDate( applyChange.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
        }
//        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChange.getValidTime()) >= Constants.ZERO
//                && DateUtil.compareDate( applyChange.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
//        }
        //查询保单下是否存在进行中的加减保/换厂单据
        if(applyChangeMapper.selectCount(new QueryWrapper<ApplyChange>().lambda()
                .eq(ApplyChange::getApplyId,insuranceApply.getId())
@@ -1042,8 +1042,11 @@
    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(), "该保险方案仅支持替换(减保人数不得大于加保人数)");
            }
        }
        //查询保险方案下的所有派遣单位
        List<DuSolution>  duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class,new MPJLambdaWrapper<DuSolution>()
                .selectAll(DuSolution.class)
@@ -1057,7 +1060,6 @@
        if(!CollectionUtils.isNotEmpty(duSolutionList)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"数据异常:保险方案下未查询到派遣单位");
        }
        //查询所有派遣单位下的工种
        List<Integer> duSolutionIdList = duSolutionList.stream().map(i->i.getId()).collect(Collectors.toList());
        List<DuWorktype> duWorktypeList = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda()
@@ -1070,17 +1072,15 @@
        ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO = new ApplyChangeCyclePriceDTO();
        applyChangeCyclePriceDTO.setApplyId(insuranceApply.getId());
        //加保数据
        List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
        Integer addDetailSize  = 0 ;
        if (CollectionUtils.isNotEmpty(addDetailList)) {
            addDetailSize = addDetailList.size();
            if(Objects.isNull(solutions.getCanAdd()) || solutions.getCanAdd().equals(Constants.ZERO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案无法进行加保");
            }
//            if(companySolution.getCanAdd().equals(Constants.ZERO)){
//                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该企业分配保险方案无法进行加保");
//            }
            //验证是否存在重复数据
            List<String> idcarNo = addDetailList.stream().map(m->m.getIdcardNo()).collect(Collectors.toList());
            Set<String> set = new HashSet<>(idcarNo);
@@ -1104,9 +1104,7 @@
        //减保数据
        List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
        Integer delDetailSize  = 0 ;
        if (CollectionUtils.isNotEmpty(delDetailList)) {
            delDetailSize  = delDetailList.size() ;
            //验证是否存在重复数据
            List<String> idcarNo = delDetailList.stream().map(m->m.getIdcardNo()).collect(Collectors.toList());
            Set<String> set = new HashSet<>(idcarNo);
@@ -1121,11 +1119,7 @@
            fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
        }
        if(Objects.nonNull(solutions.getDelOnlyReplace())&& solutions.getDelOnlyReplace().equals(Constants.ONE)){
            if(delDetailSize > addDetailSize){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该保险方案仅支持替换(减保人数不得大于加保人数)");
            }
        }
        //换厂业务
        List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList();
@@ -1222,7 +1216,7 @@
            applyChagneDetail.setIsdeleted(Constants.ZERO);
            applyChagneDetail.setApplyChangeId(applyChange.getId());
            applyChagneDetail.setType(Constants.ONE);
            applyChagneDetail.setApplyDetailId(applyDetail.getId());
            applyChagneDetail.setStartTime(applyDetail.getStartTime());
            applyChagneDetail.setEndTime(endTime);
@@ -1235,6 +1229,7 @@
            //查询减保日期
//            Integer delDays = DateUtil.daysBetweenDates(applyDetail.getEndTime(),endTime);
//            ;
            //查询周期数量
            applyChagneDetail.setFee(
                    Constants.reduceFee(solutions,
                                    Objects.isNull(insuranceApply.getServerCost())?
@@ -2144,10 +2139,10 @@
        }
        //根据批单日期 和 结束日期 计算金额
        //验证批单日期是否在当前日期后 且 在保单结束日期前 申请时间必须处于保单的时间范围内
        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChangeCyclePriceDTO.getValidTime()) >= Constants.ZERO
                && DateUtil.compareDate( applyChangeCyclePriceDTO.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
        }
//        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChangeCyclePriceDTO.getValidTime()) >= Constants.ZERO
//                && DateUtil.compareDate( applyChangeCyclePriceDTO.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "申请日期未处于保单日期内,无法进行该操作");
//        }
        BigDecimal sumPrice = Objects.isNull(insuranceApply.getServerCost())?solutions.getPrice():solutions.getPrice().add(insuranceApply.getServerCost());
        CountCyclePriceVO returnCountCyclePriceVO = new CountCyclePriceVO();
        returnCountCyclePriceVO.setCyclePrice(Constants.addFee(solutions,