111
k94314517
2024-01-20 94fc07774a552edc838ab68dc72a89eed8888665
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -23,7 +23,6 @@
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.swagger.models.auth.In;
import jdk.internal.jline.internal.Log;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -144,7 +143,7 @@
            }
            applyDetail.setIdcardNo(member.getIdcardNo());
            applyDetail.setSex(member.getSex());
            applyDetail.setFee(this.countDetailFee(solutions,insuranceApply.getApplyEndTime(),insuranceApply.getApplyStartTime()));
            applyDetail.setFee(Constants.countDetailFee(solutions,insuranceApply.getApplyEndTime(),insuranceApply.getApplyStartTime()));
            //验证派遣单位信息是否存在
            if(duSolutionList.stream().filter(d->d.getDispatchUnitId().equals(applyDetail.getDuId())).collect(Collectors.toList()).size()<=Constants.ZERO){
                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工派遣单位未查询到!");
@@ -177,14 +176,14 @@
    public BigDecimal countDetailFee(Solutions solutions ,Date startDate,Date endDate){
        //查询保险实际周期
        Integer cycle = DateUtil.calculateBetween(endDate,startDate,solutions.getDataType());
        if(cycle==-1){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"日期信息错误!");
        }
        return solutions.getPrice().multiply(new BigDecimal(cycle));
    }
//    public BigDecimal countDetailFee(Solutions solutions ,Date startDate,Date endDate){
//        //查询保险实际周期
//        Integer cycle = DateUtil.calculateBetween(endDate,startDate,solutions.getDataType());
//        if(cycle==-1){
//            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"日期信息错误!");
//        }
//        return solutions.getPrice().multiply(new BigDecimal(cycle));
//    }
//    public static void main(String[] args) {
//        Date date1 = DateUtil.StringToDate("2023-03-01 00:00:00");
@@ -277,6 +276,13 @@
        if (pageWrap.getModel().getStartTimeE() != null) {
            queryWrapper.le(InsuranceApply::getStartTime, Utils.Date.getEnd(pageWrap.getModel().getStartTimeE()));
        }
        if (pageWrap.getModel().getCreateTimeS() != null) {
            queryWrapper.ge(InsuranceApply::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateTimeS()));
        }
        if (pageWrap.getModel().getCreateTimeE() != null) {
            queryWrapper.le(InsuranceApply::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateTimeE()));
        }
        if (pageWrap.getModel().getCode() != null) {
            queryWrapper.eq(InsuranceApply::getCode, pageWrap.getModel().getCode());
        }
@@ -313,6 +319,21 @@
        insuranceApply.setInsureNum(applyDetailMapper.selectCount(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,insuranceApply.getId())
                .eq(ApplyDetail::getIsdeleted,Constants.ZERO)));
        //设置在保时长(天数)
        if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())){
            //如果当前时间大于结束日期 则使用结束日期对比开始日期
            if(DateUtil.compareDate(new Date(),insuranceApply.getEndTime())>=Constants.ZERO){
                insuranceApply.setServiceDays(DateUtil.daysBetweenDates(insuranceApply.getEndTime(),insuranceApply.getStartTime()));
            }else if(DateUtil.compareDate(insuranceApply.getStartTime(),new Date())>=Constants.ZERO){
                //未开始
                insuranceApply.setServiceDays(Constants.ZERO);
            }else{
                insuranceApply.setServiceDays(DateUtil.daysBetweenDates(new Date(),insuranceApply.getStartTime()));
            }
        }
        //查询操作记录
        List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
                new MPJLambdaWrapper<ApplyLog>()
@@ -331,7 +352,7 @@
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public void applyReturn(InsuranceApplyOptDTO insuranceApplyOptDTO){
    public void applyOpt(InsuranceApplyOptDTO insuranceApplyOptDTO){
        if(Objects.isNull(insuranceApplyOptDTO)
            ||Objects.isNull(insuranceApplyOptDTO.getApplyId())
            ||StringUtils.isBlank(insuranceApplyOptDTO.getOptIllustration())){
@@ -348,23 +369,35 @@
        if(insuranceApply.getIsdeleted().equals(Constants.ONE)){
            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"数据已删除,无法进行该操作");
        }
        if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.COMPANY_APPLY_RETURN.getKey())){
            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"退回申请中,请勿重复操作");
        Constants.InsuranceApplyStatus insuranceApplyStatus =  Constants.InsuranceApplyStatus.COMPANY_APPLY_RETURN;
        if(insuranceApplyOptDTO.getOptType().equals(Constants.ONE)){
            if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.COMPANY_APPLY_RETURN.getKey())){
                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"退回申请中,请勿重复操作");
            }
            if(!(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD.getKey())
                    ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.WAIT_SIGNATURE.getKey())
                    ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.SIGNATURE.getKey()))){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态非可申请退回!");
            }
        }else if(insuranceApplyOptDTO.getOptType().equals(Constants.TWO)){
            insuranceApplyStatus =  Constants.InsuranceApplyStatus.CLOSE;
            if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.CLOSE.getKey())){
                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"已关闭,请勿重复操作");
            }
            if(!(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.PLATFORM_AGREE.getKey())
                    ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.PLATFORM_RETURN.getKey()))){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态非可申请退回!");
            }
        }
        if(!(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD.getKey())
            ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.WAIT_SIGNATURE.getKey())
            ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.SIGNATURE.getKey()))){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态非可申请退回!");
        }
        insuranceApply.setStatus(insuranceApplyStatus.getKey());
        insuranceApply.setCheckDate(new Date());
        insuranceApply.setCheckInfo(insuranceApplyOptDTO.getOptIllustration());
        insuranceApply.setCheckUserId(loginUserInfo.getId());
        insuranceApplyMapper.updateById(insuranceApply);
        //存储日志数据
        this.saveApplyLog(insuranceApply,Constants.InsuranceApplyStatus.COMPANY_APPLY_RETURN,null);
        this.saveApplyLog(insuranceApply,insuranceApplyStatus,null);
    }
}