jiangping
2024-06-20 49c7ea314c2070a2090fee2c77acbd21435f0455
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -1088,30 +1088,10 @@
        applyChange.setIsdeleted(Constants.ZERO);
        //根据申请日期 处理加减保的 实际生效日期
        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()
                );
            }
            initJJBValidTime(applyChange,insuranceApply,solutions);
        }else{
            applyChange.setApplyStartTime(applyChange.getValidTime());
        }
        applyChange.setStatus(Constants.ZERO);
        applyChangeMapper.insert(applyChange);
@@ -1180,7 +1160,6 @@
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "保单已过保,无法进行该操作");
        }
        if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) > Constants.ZERO) {
            //如果保单尚未生效,设置期望生效日期为保单生效开始时间
            applyChange.setValidTime(insuranceApply.getStartTime());
        }
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
@@ -1217,27 +1196,8 @@
        };
        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()
                );
            }
            //处理期望生效日期
            initJJBValidTime(applyChange,insuranceApply,solutions);
        }else{
            applyChange.setApplyStartTime(applyChange.getValidTime());
        }
@@ -1267,6 +1227,34 @@
        return applyChange.getId();
    }
    private void initJJBValidTime(ApplyChange applyChange, InsuranceApply insuranceApply, Solutions solutions) {
        if( applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()
                && Objects.nonNull(solutions.getAddValidDays())){
            //如果保单已生效,按照t+n的规则
            applyChange.setApplyStartTime(
                    DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
            );
        }else{
            //如果保单未生或者没有配置生效天数,设置期望生效日期为保单生效开始时间
            applyChange.setApplyStartTime(applyChange.getValidTime());
        }
        if(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()
                &&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()
            );
        }
    }
    public BigDecimal dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply
            ,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){