| | |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dto.*; |
| | | import com.doumee.dao.business.join.ApplyDetailJoinMapper; |
| | | import com.doumee.dao.business.join.ApplyLogJoinMapper; |
| | | import com.doumee.dao.business.join.InsuranceApplyJoinMapper; |
| | | import com.doumee.dao.business.join.UnionApplyJoinMapper; |
| | | import com.doumee.dao.business.join.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.SmsEmailService; |
| | |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Autowired |
| | | private ApplyLogJoinMapper applyLogJoinMapper; |
| | | |
| | | @Autowired |
| | | private MemberInsuranceJoinMapper memberInsuranceJoinMapper; |
| | | @Value("${debug_model}") |
| | | private boolean debugModel; |
| | | |
| | |
| | | MPJLambdaWrapper<UnionApply> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | queryWrapper.selectAll(UnionApply.class); |
| | | queryWrapper.selectAs(Solutions::getName,UnionApply::getSolutionName); |
| | | queryWrapper.selectAs(Solutions::getName,UnionApply::getSolutionName) |
| | | .selectAs(Solutions::getMaxAge,UnionApply::getMaxAge) |
| | | .selectAs(Solutions::getMinAge,UnionApply::getMinAge) |
| | | .selectAs(Solutions::getPrice,UnionApply::getPrice) |
| | | .selectAs(Solutions::getTimeUnit,UnionApply::getTimeUnit) |
| | | .selectAs(Solutions::getOrtherInfo,UnionApply::getOrtherInfo) |
| | | .selectAs(Solutions::getSpecialAgreement,UnionApply::getSpecialAgreement) |
| | | .selectAs(Solutions::getSpecialInfo,UnionApply::getSpecialInfo); |
| | | queryWrapper.select("(select count(b.id) from apply_detail b where b.isdeleted=0 and b.union_apply_id=t.id) as insureNum "); |
| | | |
| | | queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id where b.union_apply_id=t.id " + |
| | | "and b.status = "+Constants.InsuranceApplyStatus.WTB_TOUBAOING.getKey()+" and a.type = 0 ) as addApplyNum "); |
| | | |
| | | queryWrapper.select("(select count(1) from apply_change a inner join insurance_apply b on a.apply_id = b.id where b.union_apply_id=t.id " + |
| | | "and b.status = "+Constants.InsuranceApplyStatus.WTB_TOUBAOING.getKey()+" and a.type = 1 ) as changeApplyNum "); |
| | | |
| | | queryWrapper.leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId); |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(Constants.equalsInteger(user.getType(),Constants.TWO)){ |
| | |
| | | eq(Solutions::getType,Constants.ONE) |
| | | .eq(Solutions::getIsdeleted,Constants.ZERO) |
| | | .eq(Solutions::getDataType,Constants.ZERO) |
| | | .eq(Solutions::getBaseId,saveUnionApplyDTO.getBaseSolutionId())); |
| | | .eq(Solutions::getId,saveUnionApplyDTO.getBaseSolutionId())); |
| | | //查询方案数据 |
| | | if(solutions == null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,方案信息有误,请刷新页面重试"); |
| | |
| | | if(insuranceApplyList.size()!=saveUnionApplyDTO.getApplyIds().size()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"存在数据已处理,请刷新重试"); |
| | | } |
| | | |
| | | saveUnionApplyDTO.setEndDate(DateUtil.getMontageDate(saveUnionApplyDTO.getEndDate(),2)); |
| | | UnionApply unionApply = new UnionApply(); |
| | | unionApply.setCreateDate(new Date()); |
| | | unionApply.setCreator(user.getId()); |
| | |
| | | multifileMapper.delete(new QueryWrapper<Multifile>() |
| | | .lambda() |
| | | .apply(" multifile.id in ( select i.id from insurance_apply i where i.UNION_APPLY_ID = "+unionApply.getId()+" ) ") |
| | | .eq(Multifile::getObjType,Constants.MultiFile.COMPANY_TBD_SIGNED.getKey())); |
| | | .eq(Multifile::getObjType,Constants.MultiFile.BD_APPLY_PDF.getKey())); |
| | | } |
| | | insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() |
| | | .set(InsuranceApply::getUnionApplyId,null) |
| | |
| | | multifile.setCreator(user.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjType(Constants.MultiFile.COMPANY_TBD_SIGNED.getKey()); |
| | | multifile.setObjType(Constants.MultiFile.BD_APPLY_PDF.getKey()); |
| | | multifile.setType(Constants.TWO); |
| | | multifileMapper.insert(multifile); |
| | | |
| | |
| | | multifile.setFileurl(uploadMultifileDTO.getFileurl()); |
| | | multifile.setName(uploadMultifileDTO.getName()); |
| | | multifileMapper.insert(multifile); |
| | | |
| | | |
| | | Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD_TBD; |
| | | ApplyLog log = new ApplyLog(unionApply,applyLogType.getName(), null |
| | | ,unionApply.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionApply)); |
| | | applyLogMapper.insert(log); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | Multifile f = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() |
| | | .eq(Multifile::getObjId,unionApply.getId()) |
| | | .eq(Multifile::getObjType,Constants.MultiFile.HBD_BD_SIGNED_PDF.getKey()) |
| | | .eq(Multifile::getObjType,Constants.MultiFile.HBD_BD_APPLY_PDF.getKey()) |
| | | .eq(Multifile::getIsdeleted,Constants.ZERO) |
| | | .last("limit 1")); |
| | | if(f == null || StringUtils.isBlank(f.getFileurl())){ |
| | |
| | | if(unionApply == null ||!Constants.equalsInteger(unionApply.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey())){ |
| | | if(!unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该合并单状态已流转,当前不支持该操作~"); |
| | | } |
| | | //加价参数 |
| | | List<UnionApplyBXDDetailDTO> unionApplyBXDDetailDTOList = unionApplyBXDDTO.getUnionApplyBXDDDetailDTOList(); |
| | | |
| | | //所有投保申请保单明细行 |
| | | List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().select(ApplyDetail::getPrice) |
| | | List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda() |
| | | .select(ApplyDetail::getId,ApplyDetail::getApplyId,ApplyDetail::getPrice) |
| | | .in(ApplyDetail::getUnionApplyId,unionApply.getId())); |
| | | unionApplyBXDDTO.setEndTime(DateUtil.getMontageDate(unionApplyBXDDTO.getEndTime(),2)); |
| | | //总天数 |
| | | Integer maxDays = DateUtil.calculateBetween(unionApplyBXDDTO.getStartTime(),unionApplyBXDDTO.getEndTime(),0); |
| | | //实际已经产生费用的天数 |
| | |
| | | List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectList(new QueryWrapper<InsuranceApply>() |
| | | .lambda().eq(InsuranceApply::getUnionApplyId,unionApply.getId())); |
| | | for (InsuranceApply insuranceApply:insuranceApplyList) { |
| | | BigDecimal price = insuranceApply.getPrice(); |
| | | Optional<UnionApplyBXDDetailDTO> unionApplyBXDDDetailTO= unionApplyBXDDetailDTOList.stream().filter(m->m.getApplyId().equals(insuranceApply.getId())).findFirst(); |
| | | List<ApplyDetail> applyDetails = applyDetailList.stream() |
| | | .filter(m->Constants.equalsInteger(m.getApplyId(),(insuranceApply.getId()))).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(applyDetails)){ |
| | | continue; |
| | | } |
| | | BigDecimal price = Constants.formatBigdecimal(applyDetails.get(Constants.ZERO).getPrice()); |
| | | |
| | | Optional<UnionApplyBXDDetailDTO> unionApplyBXDDDetailTO= unionApplyBXDDetailDTOList.stream().filter( |
| | | m->m.getApplyId().equals(insuranceApply.getId())).findFirst(); |
| | | if(unionApplyBXDDDetailTO.isPresent()){ |
| | | UnionApplyBXDDetailDTO unionApplyBXDDetailDTO = unionApplyBXDDDetailTO.get(); |
| | | price = price.add(unionApplyBXDDetailDTO.getServerMoney()); |
| | | |
| | | BigDecimal dayServerMoney = unionApplyBXDDetailDTO.getServerMoney().divide(new BigDecimal(maxDays),2, RoundingMode.HALF_UP); |
| | | |
| | | price = Constants.formatBigdecimal(price).add(Constants.formatBigdecimal(dayServerMoney)); |
| | | //上传保单信息 |
| | | if(StringUtils.isNotBlank(unionApplyBXDDetailDTO.getFileUrl())){ |
| | | Multifile multifile = new Multifile(); |
| | |
| | | }else if(useDays>0){ |
| | | currentFee = new BigDecimal(useDays).multiply(price); |
| | | } |
| | | //生成投保记录 |
| | | if(CollectionUtils.isNotEmpty(applyDetailList)){ |
| | | List<MemberInsurance> memberInsuranceList = new ArrayList<>(); |
| | | for (ApplyDetail applyDetail:applyDetailList.stream() |
| | | .filter(m->Constants.equalsInteger(m.getApplyId(),(insuranceApply.getId()))).collect(Collectors.toList())) { |
| | | applyDetail.setPrice(price); |
| | | applyDetail.setFee(price.multiply(new BigDecimal(maxDays))); |
| | | MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId()); |
| | | memberInsurance.setRelationType(Constants.ZERO); |
| | | memberInsuranceList.add(memberInsurance); |
| | | } |
| | | memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList); |
| | | } |
| | | |
| | | List<ApplyDetail> applyDetails = applyDetailList.stream().filter(m->m.getApplyId().equals(insuranceApply.getId())).collect(Collectors.toList()); |
| | | //更新投保申请单 |
| | | insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() |
| | | .set(InsuranceApply::getUnionApplyTbdStatus,Constants.THREE) |
| | | .set(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey()) |
| | | .set(InsuranceApply::getFee,price.multiply(new BigDecimal(applyDetails.size())).multiply(new BigDecimal(maxDays))) |
| | | .set(InsuranceApply::getCurrentFee,currentFee.multiply(new BigDecimal(applyDetails.size()))) |
| | |
| | | .set(InsuranceApply::getEndTime,unionApplyBXDDTO.getEndTime()) |
| | | .set(InsuranceApply::getEditDate,new Date()) |
| | | .set(InsuranceApply::getEditor,user.getId()) |
| | | .set(InsuranceApply::getCode,unionApplyBXDDTO.getCode()) |
| | | .eq(InsuranceApply::getId,insuranceApply.getId())); |
| | | //更新投保单明细金额 |
| | | applyDetailJoinMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda() |
| | |
| | | |
| | | unionApplyMapper.update(null,new UpdateWrapper<UnionApply>() |
| | | .lambda() |
| | | .set(UnionApply::getStatus,Constants.UnionApplyStatus.FINISH) |
| | | .set(UnionApply::getStatus,Constants.UnionApplyStatus.FINISH.getKey()) |
| | | .set(UnionApply::getEditDate,new Date()) |
| | | .set(UnionApply::getEditor,user.getId()) |
| | | .set(UnionApply::getStartTime,unionApplyBXDDTO.getStartTime()) |
| | | .set(UnionApply::getEndTime,unionApplyBXDDTO.getEndTime()) |
| | | .set(UnionApply::getCode,unionApplyBXDDTO.getCode()) |
| | | .set(UnionApply::getFee,sumFee) |
| | | .set(UnionApply::getCurrentFee,sumCurrFee) |
| | | .eq(UnionApply::getId,unionApply.getId()) |
| | |
| | | multifileMapper.insert(multifile); |
| | | } |
| | | |
| | | Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD_TBD; |
| | | Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_UPLOAD_BXD; |
| | | String info = ""; |
| | | if(Objects.nonNull(unionApplyBXDDTO.getStartTime())&&Objects.nonNull(unionApplyBXDDTO.getEndTime())){ |
| | | info =applyLogType.getInfo(); |