| | |
| | | |
| | | |
| | | @Override |
| | | public void merge(SaveUnionApplyDTO saveUnionApplyDTO){ |
| | | public Integer merge(SaveUnionApplyDTO saveUnionApplyDTO){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(user.getType().equals(Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非商户用户,无法进行该操作"); |
| | |
| | | || Objects.isNull(saveUnionApplyDTO.getApplyIds()) |
| | | || Objects.isNull(saveUnionApplyDTO.getStartDate()) |
| | | || Objects.isNull(saveUnionApplyDTO.getEndDate()) |
| | | || Objects.isNull(saveUnionApplyDTO.getBaseSolutionId()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | |
| | | .selectAs(InsuranceApply::getSolutionBaseId,Solutions::getBaseId) |
| | | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) |
| | | .eq(InsuranceApply::getIsdeleted, Constants.ZERO) |
| | | .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey()) |
| | | .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.COMPANY_MEMBER_LIST_SIGNATURE.getKey()) |
| | | .eq(Solutions::getBaseId,saveUnionApplyDTO.getBaseSolutionId()) |
| | | .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds()) |
| | | .isNull(InsuranceApply::getUnionApplyId) |
| | |
| | | Integer maxDays = DateUtil.calculateBetween(saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate(),0); |
| | | List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().select(ApplyDetail::getPrice) |
| | | .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds())); |
| | | //unionApply.setFee(insuranceApplyList.stream().map(i->i.getFee()).reduce(BigDecimal.ZERO,BigDecimal::add)); |
| | | unionApply.setFee(applyDetailList.stream().map(i->i.getPrice().multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add)); |
| | | unionApplyMapper.insert(unionApply); |
| | | |
| | |
| | | applyDetailJoinMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda() |
| | | .set(ApplyDetail::getUnionApplyId,unionApply.getId()) |
| | | .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds())); |
| | | |
| | | return unionApply.getId(); |
| | | |
| | | } |
| | | |
| | |
| | | if(unionApply.getStatus().equals(Constants.UnionApplyStatus.FINISH.getKey())){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"对不起,合并单业务已完结,您无法进行该操作!"); |
| | | } |
| | | if(unionApply.getStatus().equals(Constants.UnionApplyStatus.CLOSE.getKey())){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"对不起,合并单业务已关闭"); |
| | | } |
| | | //合并单状态处于待投保 |
| | | if(unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey()) |
| | | || unionApply.getStatus().equals(Constants.UnionApplyStatus.WAIT_SIGNATURE.getKey())){ |
| | |
| | | .set(InsuranceApply::getCheckUserId,user.getId()) |
| | | .eq(InsuranceApply::getUnionApplyId,unionApply.getId())); |
| | | |
| | | |
| | | applyDetailJoinMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda() |
| | | .set(ApplyDetail::getUnionApplyId,null) |
| | | .eq(ApplyDetail::getUnionApplyId,unionApply.getId())); |
| | | |
| | | |
| | | unionApplyMapper.update(null,new UpdateWrapper<UnionApply>().lambda() |
| | | .set(UnionApply::getCheckDate,new Date()) |
| | |
| | | }else if(useDays>0){ |
| | | currentFee = new BigDecimal(useDays).multiply(price); |
| | | } |
| | | //上传保单信息 |
| | | if(StringUtils.isNotBlank(unionApplyBXDDDetailTO.getFileUrl())){ |
| | | Multifile multifile = new Multifile(); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setCreator(user.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjId(insuranceApply.getId()); |
| | | multifile.setObjType(Constants.MultiFile.COMPANY_TBD_SIGNED_PDF.getKey()); |
| | | multifile.setType(Constants.TWO); |
| | | multifile.setFileurl(unionApplyBXDDDetailTO.getFileUrl()); |
| | | multifile.setName(unionApplyBXDDDetailTO.getFileName()); |
| | | multifileMapper.insert(multifile); |
| | | insuranceApply.setUnionApplyTbdStatus(Constants.ONE); |
| | | }else{ |
| | | insuranceApply.setUnionApplyTbdStatus(Constants.ZERO); |
| | | } |
| | | //更新投保申请单 |
| | | insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() |
| | | .set(InsuranceApply::getFee, |
| | |
| | | .set(InsuranceApply::getCurrentFee,currentFee.multiply(new BigDecimal(applyDetails.size()))) |
| | | .set(InsuranceApply::getStartTime,unionApplyBXDDTO.getStartTime()) |
| | | .set(InsuranceApply::getEndTime,unionApplyBXDDTO.getEndTime()) |
| | | .set(InsuranceApply::getUnionApplyTbdStatus,insuranceApply.getUnionApplyTbdStatus()) |
| | | .set(InsuranceApply::getEditDate,new Date()) |
| | | .set(InsuranceApply::getEditor,user.getId()) |
| | | .eq(InsuranceApply::getId,insuranceApply.getId())); |
| | |
| | | .set(ApplyDetail::getEndTime,unionApplyBXDDTO.getEndTime()) |
| | | .in(ApplyDetail::getId,applyDetails.stream().map(m->m.getId()).collect(Collectors.toList())) |
| | | ); |
| | | //上传保单信息 |
| | | if(StringUtils.isNotBlank(unionApplyBXDDDetailTO.getFileUrl())){ |
| | | Multifile multifile = new Multifile(); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setCreator(user.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjId(insuranceApply.getId()); |
| | | multifile.setObjType(Constants.MultiFile.BD_APPLY_PDF.getKey()); |
| | | multifile.setType(Constants.TWO); |
| | | multifile.setFileurl(unionApplyBXDDDetailTO.getFileUrl()); |
| | | multifile.setName(unionApplyBXDDDetailTO.getFileName()); |
| | | multifileMapper.insert(multifile); |
| | | } |
| | | |
| | | sumFee = sumFee.add(price.multiply(new BigDecimal(applyDetails.size())).multiply(new BigDecimal(maxDays))); |
| | | sumCurrFee = sumCurrFee.add(currentFee.multiply(new BigDecimal(applyDetails.size()))); |
| | | } |