| | |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.business.vo.CountCyclePriceVO; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.system.vo.BigDecimalVO; |
| | | import com.doumee.service.business.SmsEmailService; |
| | | import com.doumee.service.business.UnionChangeService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | |
| | | @Autowired |
| | | private ApplyChangeJoinMapper applyChangeJoinMapper; |
| | | |
| | | @Autowired |
| | | private UnionApplyMapper unionApplyMapper; |
| | | |
| | | @Autowired |
| | | private ApplyChagneDetailJoinMapper applyChagneDetailJoinMapper; |
| | |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | |
| | | // UnionApply unionApply = unionApplyMapper.selectById(saveUnionChangeDTO.getUnionApplyId()); |
| | | // if(Objects.isNull(unionApply)){ |
| | | // throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"æªæ¥è¯¢å°åå¹¶ä¿åæ°æ®"); |
| | | // } |
| | | |
| | | |
| | | List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class, |
| | | new MPJLambdaWrapper<ApplyChange>() |
| | | .selectAll(ApplyChange.class) |
| | |
| | | ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange)); |
| | | applyLogMapper.insert(log); |
| | | |
| | | if(true){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | public void dealApplyChangeDetail(ApplyChange applyChange,List<ApplyChagneDetail> applyChagneDetailList){ |
| | | |
| | | BigDecimal totalFee = BigDecimal.ZERO; |
| | | BigDecimal currentFee = BigDecimal.ZERO; |
| | | BigDecimalVO bigDecimalVO = new BigDecimalVO(); |
| | | bigDecimalVO.setTotalFee(BigDecimal.ZERO); |
| | | bigDecimalVO.setCurrentFee(BigDecimal.ZERO); |
| | | for (ApplyChagneDetail detail:applyChagneDetailList) { |
| | | Member member = memberMapper.selectById(detail.getMemberId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªæ¥è¯¢å°åå·¥æ°æ®"); |
| | | } |
| | | if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) { |
| | | this.addChangeDetailData(applyChange,detail,detail.getPrice(),currentFee,totalFee); |
| | | this.addChangeDetailData(applyChange,detail,bigDecimalVO); |
| | | }else if(Constants.equalsInteger(detail.getType(),Constants.ONE)){ |
| | | this.reduceChangeDetailData(applyChange,detail,currentFee,totalFee); |
| | | this.reduceChangeDetailData(applyChange,detail,bigDecimalVO); |
| | | }else{ |
| | | this.otherChangeDetailData(applyChange,detail); |
| | | } |
| | | } |
| | | |
| | | if (totalFee.compareTo(new BigDecimal(0)) != 0) { |
| | | if (bigDecimalVO.getTotalFee().compareTo(new BigDecimal(0)) != 0) { |
| | | //妿ä¿åéé¢åçç¼ç ï¼æ´æ°æ»ä¿åéé¢ |
| | | insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda() |
| | | .setSql(" fee = ifnull(fee,0)+" + totalFee) |
| | | .setSql(" current_fee = ifnull(current_fee,0)+" + currentFee) |
| | | .setSql(" fee = ifnull(fee,0)+" + bigDecimalVO.getTotalFee()) |
| | | .setSql(" current_fee = ifnull(current_fee,0)+" + bigDecimalVO.getCurrentFee()) |
| | | .set(InsuranceApply::getEditor, applyChange.getEditor()) |
| | | .set(InsuranceApply::getEditDate, applyChange.getEditDate()) |
| | | .eq(InsuranceApply::getId, applyChange.getApplyId()) |
| | | ); |
| | | applyChangeJoinMapper.update(null, new UpdateWrapper<ApplyChange>().lambda() |
| | | .set(ApplyChange::getFee,totalFee) |
| | | .set(ApplyChange::getEditor, applyChange.getEditor()) |
| | | .set(ApplyChange::getEditDate, applyChange.getEditDate()) |
| | | .eq(ApplyChange::getId, applyChange.getApplyId()) |
| | | ); |
| | | // applyChangeJoinMapper.update(null, new UpdateWrapper<ApplyChange>().lambda() |
| | | // .set(ApplyChange::getFee,bigDecimalVO.getTotalFee()) |
| | | // .set(ApplyChange::getEditor, applyChange.getEditor()) |
| | | // .set(ApplyChange::getEditDate, applyChange.getEditDate()) |
| | | // .eq(ApplyChange::getId, applyChange.getApplyId()) |
| | | // ); |
| | | applyChange.setFee(bigDecimalVO.getTotalFee()); |
| | | } |
| | | |
| | | } |
| | |
| | | * å ä¿æ°æ®å¤ç |
| | | * @param applyChange |
| | | * @param detail |
| | | * @param price |
| | | * @param currentFee |
| | | * @param totalFee |
| | | */ |
| | | public void addChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail |
| | | ,BigDecimal price,BigDecimal currentFee,BigDecimal totalFee){ |
| | | public void addChangeDetailData(ApplyChange applyChange, ApplyChagneDetail detail |
| | | , BigDecimalVO bigDecimalVO){ |
| | | //æ¥è¯¢å ä¿äººåæ¯å¦åå¨ å²çªç ä¿åæç»æ°æ® |
| | | if(applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>() |
| | | .lambda() |
| | |
| | | if(new Date().compareTo(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))>=0){ |
| | | Integer days = DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(new Date(), 2),0); |
| | | //å¦æå·²å·²äº§çè´¹ç¨ï¼è®¡ç®å·²å·²äº§çè´¹ç¨ |
| | | add.setCurrentFee(new BigDecimal(days).multiply(price)); |
| | | add.setCurrentFee(new BigDecimal(days).multiply(detail.getPrice())); |
| | | }else{ |
| | | add.setCurrentFee(BigDecimal.ZERO); |
| | | } |
| | |
| | | add.setDuId(detail.getDuId()); |
| | | add.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1)); |
| | | add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2)); |
| | | add.setFee(new BigDecimal(countDays).multiply(price)); |
| | | add.setFee(new BigDecimal(countDays).multiply(detail.getPrice())); |
| | | applyDetailJoinMapper.insert(add); |
| | | |
| | | detail.setFee(add.getFee()); |
| | |
| | | .set(ApplyChagneDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(), 1)) |
| | | .eq(ApplyChagneDetail::getId,detail.getId()) |
| | | ); |
| | | |
| | | totalFee = totalFee.add(add.getFee()); |
| | | currentFee = currentFee.add(add.getCurrentFee()); |
| | | bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(add.getFee())); |
| | | bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(add.getCurrentFee())); |
| | | |
| | | MemberInsurance memberInsurance = new MemberInsurance(detail, applyChange, applyChange.getEditor(), add.getId(),applyChange.getSolutionsId()); |
| | | memberInsurance.setStartTime(add.getStartTime()); |
| | |
| | | * åä¿æ°æ®å¤ç |
| | | * @param applyChange |
| | | * @param detail |
| | | * @param currentFee |
| | | * @param totalFee |
| | | */ |
| | | public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,BigDecimal currentFee,BigDecimal totalFee){ |
| | | public void reduceChangeDetailData(ApplyChange applyChange,ApplyChagneDetail detail,BigDecimalVO bigDecimalVO){ |
| | | //æ¥è¯¢åå·¥æ¯å¨ä¸»åä¸ æ¯å¦åå¨çæä¸çæ°æ® |
| | | ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda() |
| | | .eq(ApplyDetail::getApplyId, applyChange.getApplyId()) |
| | |
| | | .set(ApplyDetail::getEditDate, applyChange.getEditDate()) |
| | | .eq(ApplyDetail::getId, oldModel.getId()) |
| | | ); |
| | | totalFee = totalFee.add(reduceFee); |
| | | currentFee = currentFee.add(pullFee); |
| | | |
| | | bigDecimalVO.setTotalFee(bigDecimalVO.getTotalFee().add(reduceFee)); |
| | | bigDecimalVO.setCurrentFee(bigDecimalVO.getCurrentFee().add(pullFee)); |
| | | |
| | | //ä¿®æ¹ åå·¥æä¿æç»è®°å½ å岿°æ® |
| | | memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda() |