k94314517
2024-03-29 0c9a7d863d46138a574ed3aa966f9a2e1b6a2d91
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -514,7 +514,7 @@
        InsuranceApply update = new InsuranceApply();
        update.setEditDate(new Date());
        update.setEditor(model.getCreator());
        update.setStatus(Constants.InsuranceApplyStatus.COMPANY_APPLY_SIGNATURE.getKey());
        update.setStatus(Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey());
        update.setCheckDate(update.getEditDate());
        update.setCheckInfo("企业完成签署方案确认书");
        update.setCheckUserId(model.getCreator());
@@ -547,7 +547,7 @@
        InsuranceApply update = new InsuranceApply();
        update.setEditDate(new Date());
        update.setEditor(model.getCreator());
        update.setStatus(Constants.InsuranceApplyStatus.COMPANY_MEMBER_LIST_SIGNATURE.getKey());
        update.setStatus(Constants.InsuranceApplyStatus.WTB_COMPANY_MEMBER_LIST_SIGNATURE.getKey());
        update.setCheckDate(update.getEditDate());
        update.setCheckInfo("企业完成签署人员名单");
        update.setCheckUserId(model.getCreator());
@@ -752,7 +752,7 @@
                        .selectAs(Company::getName,InsuranceApply::getCompanyName)
                        .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                        .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD.getKey())
                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey())
                        .eq(Solutions::getType,Constants.ONE)
                        .isNotNull(InsuranceApply::getSignQrsNo));
        if(applyList !=null && applyList.size()>0 ){
@@ -781,7 +781,7 @@
                        .selectAs(Company::getName,InsuranceApply::getCompanyName)
                        .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                        .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.COMPANY_APPLY_SIGNATURE.getKey())
                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_COMPANY_APPLY_SIGNATURE.getKey())
                        .eq(Solutions::getType,Constants.ONE)
                        .isNotNull(InsuranceApply::getSignMemberListNo));
        if(applyList !=null && applyList.size()>0 ){
@@ -956,7 +956,7 @@
                            .eq(Solutions::getType,Constants.ONE)
                            .eq(InsuranceApply::getSignMemberListNo,data.getApplyNo())
                            .last("limit 1" ));
            if(modelMemberList != null && Constants.equalsInteger(modelMemberList.getStatus(),Constants.InsuranceApplyStatus.COMPANY_APPLY_SIGNATURE.getKey())){
            if(modelMemberList != null && Constants.equalsInteger(modelMemberList.getStatus(),Constants.InsuranceApplyStatus.WTB_COMPANY_APPLY_SIGNATURE.getKey())){
                //完成签署已完成操作
                String link = signService.linkFile(data.getApplyNo());
                String fileUrl = uploadSignFile(link);
@@ -1129,6 +1129,7 @@
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer check(InsuranceApply insuranceApply) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(insuranceApply.getId() == null){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
@@ -1137,31 +1138,35 @@
        if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(!Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.UPLOAD.getKey())){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
        }
        Solutions solutions = solutionsMapper.selectById(model.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        if(solutions.getType().equals(Constants.ZERO)){
            if(!Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.UPLOAD.getKey())){
                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
            }
        }else{
            if(!user.getType().equals(Constants.TWO)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非商户端无法进行该操作");
            }
            if(!Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.WTB_RETURN.getKey())){
                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
            }
        }
        Constants.ApplyLogType applyLogType = null;
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        InsuranceApply update = new InsuranceApply();
        update.setEditDate(new Date());
        update.setEditor(user.getId());
        update.setCheckDate(update.getEditDate());
        update.setCheckInfo(insuranceApply.getCheckInfo());
        update.setCheckUserId(user.getId());
        update.setId(model.getId());
        Constants.NoticeType noticeType = Constants.NoticeType.ONE;
        update.setId(model.getId());
        if(insuranceApply.getDealBackApply() ==1){
            //如果是不通过
            applyLogType = Constants.ApplyLogType.PLATFORM_RETURN ;
            update.setStatus(Constants.InsuranceApplyStatus.PLATFORM_RETURN.getKey());
            noticeType = Constants.NoticeType.FOUR;
        }else{
            applyLogType = Constants.ApplyLogType.PLATFORM_CHECK_PASS;
            update.setStatus(Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey());
@@ -1173,10 +1178,7 @@
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey())
                .ne(Notices::getType,Constants.NoticeType.SIX.getStatus())
                .eq(Notices::getObjId,model.getId()));
//        Notices notices = new Notices(noticeObjectType,Constants.ONE,model.getId(),solutions.getName(),model.getCompanyId(),noticeType);
//        noticesMapper.insert(notices);
                .eq(Notices::getObjId,model.getId()));
        String info =applyLogType.getInfo();
        if(StringUtils.isNotBlank(update.getCheckInfo())){
            info = info.replace("${param}", update.getCheckInfo());
@@ -1220,6 +1222,9 @@
            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"员工信息存在重复信息");
        }
        Constants.InsuranceApplyStatus insuranceApplyStatus = Constants.InsuranceApplyStatus.UPLOAD;
        if(solutions.getType().equals(Constants.ONE)){
            insuranceApplyStatus = Constants.InsuranceApplyStatus.WTB_UPLOAD;
        }
        insuranceApply.setCreateDate(new Date());
        insuranceApply.setCreator(loginUserInfo.getId());
        insuranceApply.setEditor(loginUserInfo.getId());
@@ -2083,7 +2088,7 @@
        Constants.ApplyLogType applyLogType = null;
        String info = "";
        //如果是驳回,只能可驳回已签章状态下的退回申请状态进行操作
        if(!Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.UPLOAD.getKey())){
        if(!Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey())){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
        }
        Company company = user.getCompany();
@@ -2120,6 +2125,8 @@
        return  link;
    }
    @Override
    public  InsuranceApply  queryApplyDetail(Integer applyId){
        InsuranceApply model = findDetail(applyId);
@@ -2154,7 +2161,7 @@
        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getIsdeleted())){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(!Constants.equalsInteger(Constants.ZERO,model.getStatus())){
        if(!Constants.equalsInteger(Constants.InsuranceApplyStatus.WTB_COMPANY_APPLY_SIGNATURE.getKey(),model.getStatus())){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该申请状态已流转,当前不支持签章操作!");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
@@ -2193,6 +2200,76 @@
    }
    /**
     * 委托保 投保申请签署
     * @param id
     * @return
     */
    @Override
    public  String getSignWTBTBDLink(Integer id) {
        if(id == null ){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        MPJLambdaWrapper wrapper=  new MPJLambdaWrapper<InsuranceApply>()
                .selectAll(InsuranceApply.class)
                .selectAs(Solutions::getSignKeyword,InsuranceApply::getSignKeyword)
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .eq(InsuranceApply::getId,id)
                .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);
        }
        Solutions solutions = solutionsMapper.selectById(model.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        if(solutions.getType().equals(Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,非委托保方案保单!");
        }
        if(!model.getUnionApplyTbdStatus().equals(Constants.ONE)){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,商户未上传或已签署");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        Constants.ApplyLogType applyLogType = null;
        String info = "";
        //如果是驳回,只能可驳回已签章状态下的退回申请状态进行操作
        if(!Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey())){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
        }
        Company company = user.getCompany();
        if(debugModel){
            company = companyMapper.selectById(model.getCompanyId());
        }
        if(company== null || StringUtils.isBlank( company.getEmail()) || !Constants.equalsInteger(company.getSignStatus(),Constants.THREE)){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,企业尚未具备在线签章条件,请联系平台管理员确认~");
        }
        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::getIsdeleted,Constants.ZERO).last("limit 1"));
        if(f == null || StringUtils.isBlank(f.getFileurl())){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取确认书文件失败,请联系商户确认投保申请书是否正确!");
        }
        String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode()+f.getFileurl();
        String notifyUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode();
        notifyUrl = notifyUrl.replace("${type}","0").replace("${id}",model.getId().toString());
        String applyNo = signService.applySign(company.getName(),url,company.getName(),company.getCode(),company.getEmail(),model.getSignKeyword(),company.getSignId(),notifyUrl);
        if(StringUtils.isBlank(applyNo) ){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取在线签章地址失败,请稍后重试!");
        }
        String link = signService.signLink(applyNo,company.getName(),company.getCode());
        if(StringUtils.isBlank(link) ){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,获取在线签章地址失败,请稍后重试!");
        }
        InsuranceApply update= new InsuranceApply();
        update.setId(model.getId());
        update.setEditor(user.getId());
        update.setEditDate(new Date());
        update.setApplyTbdNo(applyNo);
        insuranceApplyMapper.updateById(update);
        return  link;
    }
}