nidapeng
2024-03-29 ff95e73d12418ee4b1e400eaceac3d4d623f85b6
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -16,6 +16,7 @@
import com.doumee.dao.business.dto.CountCyclePriceDTO;
import com.doumee.dao.business.dto.InsuranceApplyOptDTO;
import com.doumee.dao.business.dto.InsuranceApplyQueryDTO;
import com.doumee.dao.business.dto.SmsCheckDTO;
import com.doumee.dao.business.join.*;
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.CountCyclePriceVO;
@@ -514,7 +515,7 @@
        InsuranceApply update = new InsuranceApply();
        update.setEditDate(new Date());
        update.setEditor(model.getCreator());
        update.setStatus(Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey());
        update.setStatus(Constants.InsuranceApplyStatus.WTB_COMPANY_APPLY_SIGNATURE.getKey());
        update.setCheckDate(update.getEditDate());
        update.setCheckInfo("企业完成签署方案确认书");
        update.setCheckUserId(model.getCreator());
@@ -533,6 +534,49 @@
        f.setInfo("企业完成签署方案确认书");
        f.setName("方案确认书.pdf");
        multifileMapper.insert(f);
        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.WTB_FINISH_FAQRS;
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null
                ,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  f;
    }
    /**
     * 委托保  企业签署投保申请书
     * @param model
     * @param fileurl
     * @param fullUrl
     * @return
     */
    public Multifile   uploadTBSQSSignedFileDo(InsuranceApply model,String fileurl,String fullUrl) {
        InsuranceApply update = new InsuranceApply();
        update.setEditDate(new Date());
        update.setEditor(model.getCreator());
        update.setUnionApplyTbdStatus(Constants.TWO);
        update.setCheckDate(update.getEditDate());
        update.setCheckInfo("委托保企业完成签署投保申请书");
        update.setCheckUserId(model.getCreator());
        update.setId(model.getId());
        insuranceApplyMapper.updateById(update);
        Multifile f = new Multifile();
        f.setIsdeleted(Constants.ZERO);
        f.setCreator(model.getCreator());
        f.setObjId(update.getId());
        f.setCreateDate(update.getEditDate());
        f.setObjType(Constants.MultiFile.COMPANY_TBD_SIGNED_PDF.getKey());
        f.setType(Constants.TWO);
        f.setFileurl(fileurl);
        f.setFileurlFull(fullUrl);
        f.setInfo("委托保企业完成签署投保申请书");
        f.setName("投保申请书.pdf");
        multifileMapper.insert(f);
        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.SIGNATURE;
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null
                ,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  f;
    }
@@ -566,6 +610,12 @@
        f.setInfo("企业完成签署人员名单");
        f.setName("人员名单.pdf");
        multifileMapper.insert(f);
        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.WTB_FINISH_MEMBER_LIST;
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null
                ,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  f;
    }
    
@@ -608,6 +658,7 @@
        f.setInfo("企业申请表签署文件");
        f.setName("签章申请表.pdf");
        multifileMapper.insert(f);
        Constants.ApplyLogType applyLogType =Constants.equalsInteger(Constants.ZERO,model.getType())? Constants.ApplyLogType.CA_JIAJIAN_APPLY_SIGN: Constants.ApplyLogType.CA_CHANGUNIT_APPLY_SIGN;
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
@@ -640,6 +691,10 @@
        f.setInfo("企业完成签署人员名单");
        f.setName("签章人员名单.pdf");
        multifileMapper.insert(f);
        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_WTB_FINISH_MEMBER_LIST;
        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return f;
    }
@@ -737,10 +792,10 @@
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    return;
                    continue;
                }
                uploadSignedFileDo(model,fileUrl,path+fileUrl);
                return;
//                return;
            }
        }
        //委托保 企业签署投保确认书
@@ -765,10 +820,10 @@
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    return;
                    continue;
                }
                uploadFAQRSSignedFileDo(model,fileUrl,path+fileUrl);
                return;
//                return;
            }
        }
@@ -794,12 +849,44 @@
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    return;
                    continue;
                }
                uploadApplyMemberListSignedFileDo(model,fileUrl,path+fileUrl);
                return;
//                return;
            }
        }
        //委托保企业签署投保申请单
        applyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class,
                new MPJLambdaWrapper<InsuranceApply>()
                        .selectAll(InsuranceApply.class)
                        .selectAs(Solutions::getName,InsuranceApply::getSolutionsName)
                        .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail)
                        .selectAs(Company::getName,InsuranceApply::getCompanyName)
                        .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                        .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                        .eq(InsuranceApply::getUnionApplyTbdStatus,Constants.ONE)
                        .eq(Solutions::getType,Constants.ONE)
                        .isNotNull(InsuranceApply::getApplyTbdNo));
        if(applyList !=null && applyList.size()>0 ){
            for(InsuranceApply model : applyList){
                String status = signService.linkFileStatus(model.getApplyTbdNo());
                if(!StringUtils.equals(status,"3")){
                    continue;
                }
                String link = signService.linkFile(model.getApplyTbdNo());
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    continue;
                }
                uploadTBSQSSignedFileDo(model,fileUrl,path+fileUrl);
//                return;
            }
        }
        List<ApplyChange> chagneList = applyChangeMapper.selectJoinList(ApplyChange.class,
                new MPJLambdaWrapper<ApplyChange>()
@@ -824,10 +911,10 @@
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    return;
                    continue;
                }
                uploadChangeSignedFileDo(model,fileUrl,path+fileUrl);
                return;
//                return;
            }
        }
@@ -854,10 +941,10 @@
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    return;
                    continue;
                }
                uploadChangeMemberListSignedFileDo(model,fileUrl,path+fileUrl);
                return;
//                return;
            }
        }
@@ -881,12 +968,16 @@
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    return;
                    continue;
                }
                uploadUnionApplySignedFileDo(model,fileUrl,path+fileUrl);
                return;
//                return;
            }
        }
    }
    @Override
@@ -933,7 +1024,7 @@
                            .eq(Solutions::getType,Constants.ONE)
                            .eq(InsuranceApply::getSignQrsNo,data.getApplyNo())
                            .last("limit 1" ));
            if(modelTBQRS != null && Constants.equalsInteger(modelTBQRS.getStatus(),Constants.InsuranceApplyStatus.UPLOAD.getKey())){
            if(modelTBQRS != null && Constants.equalsInteger(modelTBQRS.getStatus(),Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey())){
                //完成签署已完成操作
                String link = signService.linkFile(data.getApplyNo());
                String fileUrl = uploadSignFile(link);
@@ -944,6 +1035,9 @@
                uploadFAQRSSignedFileDo(modelTBQRS,fileUrl,path+fileUrl);
                return;
            }
            //委托保 企业签署人员名单
            InsuranceApply modelMemberList = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,
                    new MPJLambdaWrapper<InsuranceApply>()
@@ -965,6 +1059,31 @@
                    return;
                }
                uploadApplyMemberListSignedFileDo(modelMemberList,fileUrl,path+fileUrl);
                return;
            }
            //委托保 投保申请书签署
            InsuranceApply modelTBQSQ = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,
                    new MPJLambdaWrapper<InsuranceApply>()
                            .selectAll(InsuranceApply.class)
                            .selectAs(Solutions::getName,InsuranceApply::getSolutionsName)
                            .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail)
                            .selectAs(Company::getName,InsuranceApply::getCompanyName)
                            .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                            .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                            .eq(Solutions::getType,Constants.ONE)
                            .eq(InsuranceApply::getApplyTbdNo,data.getApplyNo())
                            .last("limit 1" ));
            if(modelTBQRS != null && Constants.equalsInteger(modelTBQSQ.getUnionApplyTbdStatus(),Constants.ONE)){
                //完成签署已完成操作
                String link = signService.linkFile(data.getApplyNo());
                String fileUrl = uploadSignFile(link);
                if(StringUtils.isBlank(fileUrl)){
                    //如果下载失败,清除合同,下次签章重新生成新合同
                    return;
                }
                uploadTBSQSSignedFileDo(modelTBQSQ,fileUrl,path+fileUrl);
                return;
            }
@@ -1527,13 +1646,37 @@
        QueryWrapper<InsuranceApply> wrapper = new QueryWrapper<>(insuranceApply);
        return insuranceApplyMapper.selectList(wrapper);
    }
    public List<Integer> getCollectStatus(Integer collectStatus){
        if(collectStatus ==null){
            return  new ArrayList<>();
        }
        List<Integer> statusList = Constants.InsuranceApplyStatus.getKesByStatus(collectStatus);
        if(collectStatus.equals(Constants.ApplyCollectStatus.DCD)){
            statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBDCD.getKey()));
        }else if(collectStatus.equals(Constants.ApplyCollectStatus.DSP)){
            statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBDSH.getKey()));
        }else if(collectStatus.equals(Constants.ApplyCollectStatus.BZZ)){
            statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBBZZ.getKey()));
        }else if(collectStatus.equals(Constants.ApplyCollectStatus.YTH)){
            statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBYTH.getKey()));
        }else if(collectStatus.equals(Constants.ApplyCollectStatus.YGB)){
            statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBYGB.getKey()));
        }else if(collectStatus.equals(Constants.ApplyCollectStatus.DQYQZ)){
            statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBDQS.getKey()));
        }
        return statusList;
    }
  
    @Override
    public PageData<InsuranceApply> findPage(PageWrap<InsuranceApplyQueryDTO> pageWrap) {
        IPage<InsuranceApply> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        MPJLambdaWrapper<InsuranceApply> queryWrapper = new MPJLambdaWrapper<>();
        Utils.MP.blankToNull(pageWrap.getModel());
        List<Integer> statusList = Constants.InsuranceApplyStatus.getKesByStatus(pageWrap.getModel().getStatusCollect());
        List<Integer> statusList = this.getCollectStatus(pageWrap.getModel().getStatusCollect());
        queryWrapper.selectAll(InsuranceApply.class);
        queryWrapper.selectAs(Company::getName,InsuranceApply::getCompanyName);
        queryWrapper.selectAs(Solutions::getName,InsuranceApply::getSolutionsName);
@@ -1811,11 +1954,14 @@
    private void initImgData(InsuranceApply model) {
        List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda()
                .eq(Multifile::getObjId,Constants.equalsInteger(model.getSolutionType(),Constants.ZERO)? model.getId():model.getUnionApplyId())
                .eq(Multifile::getObjId, model.getId())
                .in(Multifile::getObjType,Arrays.asList(new Integer[]{Constants.MultiFile.BD_APPLY_PDF.getKey()
                        ,Constants.MultiFile.BD_SIGNED_PDF.getKey()
                        ,Constants.MultiFile.WTB_CONFIRMATION_LATTER.getKey()
                        ,Constants.MultiFile.MEMBER_LIST_LATTER.getKey()
                        ,Constants.MultiFile.BD_DONE_PDF.getKey()}))
                .eq(Multifile::getIsdeleted,Constants.ZERO));
                .eq(Multifile::getIsdeleted,Constants.ZERO)
                .orderByAsc(Multifile::getId));
        if(multifiles!=null){
            String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
                    +systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode();
@@ -1833,6 +1979,12 @@
                }else if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.BD_DONE_PDF.getKey())){
                    //最終保险单
                    model.setBaoxiandanFile(f);
                }else if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.MEMBER_LIST_LATTER.getKey())){
                    //申请单
                    model.setShenqingdanFile(f);
                }else if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.WTB_CONFIRMATION_LATTER.getKey())){
                    //签署后确认书
                    model.setFanganFile(f);
                }
//                if(model.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())){
@@ -2058,21 +2210,26 @@
    /**
     * 委托宝 投保确认书
     * @param id
     * @param smsCheckDTO
     * @return
     */
    @Override
    public  String getSignTBQRSLink(Integer id) {
        if(id == null ){
    public  String getSignTBQRSLink(SmsCheckDTO smsCheckDTO) {
        if(Objects.isNull(smsCheckDTO)
            || Objects.isNull(smsCheckDTO.getBusinessId())
                || StringUtils.isBlank(smsCheckDTO.getCode())
        ){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        if(!debugModel){
            smsEmailService.validateCode(smsCheckDTO.getCode());
        }
        MPJLambdaWrapper wrapper=  new MPJLambdaWrapper<InsuranceApply>()
                .selectAll(InsuranceApply.class)
                .selectAs(Solutions::getSignKeyword,InsuranceApply::getSignKeyword)
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .eq(InsuranceApply::getId,id)
                .eq(InsuranceApply::getId,smsCheckDTO.getBusinessId())
                .last("limit 1");
        InsuranceApply model = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,wrapper);
        if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -2081,7 +2238,7 @@
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        if(solutions.getType().equals(Constants.ZERO)){
        if(Constants.equalsInteger(solutions.getType(),(Constants.ZERO))){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,非委托保方案保单!");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
@@ -2153,8 +2310,18 @@
     * 人员名单签章
     */
    @Override
    public String getMemberListOnlineSignLink(Integer applyId) {
        InsuranceApply model = this.queryApplyDetail(applyId);
    public String getMemberListOnlineSignLink(SmsCheckDTO smsCheckDTO) {
        if(Objects.isNull(smsCheckDTO)
                || Objects.isNull(smsCheckDTO.getBusinessId())
                || StringUtils.isBlank(smsCheckDTO.getCode())
        ){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        //验证 验证码
        if(!debugModel){
            smsEmailService.validateCode(smsCheckDTO.getCode());
        }
        InsuranceApply model = this.queryApplyDetail(smsCheckDTO.getBusinessId());
        if(Objects.isNull(model)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询保单信息");
        }
@@ -2202,19 +2369,26 @@
    /**
     * 委托保 投保申请签署
     * @param id
     * @param smsCheckDTO
     * @return
     */
    @Override
    public  String getSignWTBTBDLink(Integer id) {
        if(id == null ){
    public  String getSignWTBTBDLink(SmsCheckDTO smsCheckDTO) {
        if(Objects.isNull(smsCheckDTO)
                || Objects.isNull(smsCheckDTO.getBusinessId())
                || StringUtils.isBlank(smsCheckDTO.getCode())
        ){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        //验证 验证码
        if(!debugModel){
            smsEmailService.validateCode(smsCheckDTO.getCode());
        }
        MPJLambdaWrapper wrapper=  new MPJLambdaWrapper<InsuranceApply>()
                .selectAll(InsuranceApply.class)
                .selectAs(Solutions::getSignKeyword,InsuranceApply::getSignKeyword)
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .eq(InsuranceApply::getId,id)
                .eq(InsuranceApply::getId,smsCheckDTO.getBusinessId())
                .last("limit 1");
        InsuranceApply model = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,wrapper);
@@ -2247,7 +2421,7 @@
        }
        Multifile f = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda()
                .eq(Multifile::getObjId,model.getId())
                .eq(Multifile::getObjType,Constants.MultiFile.COMPANY_TBD_SIGNED_PDF.getKey())
                .eq(Multifile::getObjType,Constants.MultiFile.COMPANY_TBD_SIGNED.getKey())
                .eq(Multifile::getIsdeleted,Constants.ZERO).last("limit 1"));
        if(f == null || StringUtils.isBlank(f.getFileurl())){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取确认书文件失败,请联系商户确认投保申请书是否正确!");