| | |
| | | Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto); |
| | | |
| | | Double feePrice = Double.parseDouble(feePriceAll.get("feePrice").toString()); |
| | | //todo 如果是一次性费用 除以 |
| | | // if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getPayerObjType())) { |
| | | // return feePrice; |
| | | // } |
| | | // double maxMonth = Math.ceil(computeFeeSMOImpl.dayCompare(feeDto.getStartTime(), feeDto.getEndTime())); |
| | | // if (maxMonth <= 0) { |
| | | // return feePrice; |
| | | // |
| | | // } |
| | | // BigDecimal feePriceDec = new BigDecimal(feePrice).divide(new BigDecimal(maxMonth), 2, BigDecimal.ROUND_HALF_UP); |
| | | // feePrice = feePriceDec.doubleValue(); |
| | | |
| | | return feePrice; |
| | | } |
| | | |
| | |
| | | * @param payFeeMonthOwnerDto |
| | | */ |
| | | @Override |
| | | public void waitDispersedFeeDetail(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto,Double feePrice) { |
| | | public void waitDispersedFeeDetail(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto, Double feePrice) { |
| | | PayFeeDetailMonthDto payFeeDetailMonthDto = new PayFeeDetailMonthDto(); |
| | | payFeeDetailMonthDto.setCommunityId(feeDto.getCommunityId()); |
| | | payFeeDetailMonthDto.setFeeId(feeDto.getFeeId()); |
| | |
| | | * @param deadlineTime |
| | | */ |
| | | @Override |
| | | public void waitDispersedOweFee(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto, Double feePrice, Date deadlineTime) { |
| | | public void waitDispersedOweFee(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto, Double feePrice, Date deadlineTime, double oweMonth) { |
| | | |
| | | |
| | | // todo 清理 detailId 为-1 的数据 |
| | |
| | | return; |
| | | } |
| | | |
| | | // 自然月周期性费用计算 |
| | | waitDispersedOweFeeCycleNormalMonth(feeDto,payFeeMonthOwnerDto,feePrice,deadlineTime); |
| | | |
| | | // 一次性或者非自然月处理 |
| | | waitDispersedOweFeeOnceUnNormalMonth(feeDto,payFeeMonthOwnerDto,feePrice,deadlineTime,oweMonth); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 自然月周期性费用计算 |
| | | * |
| | | * @param feeDto |
| | | * @param payFeeMonthOwnerDto |
| | | * @param feePrice |
| | | * @param deadlineTime |
| | | */ |
| | | private void waitDispersedOweFeeCycleNormalMonth(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto, Double feePrice, Date deadlineTime) { |
| | | // 一次性费用直接返回 |
| | | if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) { |
| | | return; |
| | | } |
| | | // 不是自然月 费用直接返回 |
| | | if(DateUtil.getDay(feeDto.getStartTime()) !=1){ |
| | | return; |
| | | } |
| | | List<PayFeeDetailMonthPo> payFeeDetailMonthPos = new ArrayList<>(); |
| | | // todo 处理 开始时间和结束时间 |
| | | Date startTime = DateUtil.timeToDate(feeDto.getEndTime()); |
| | |
| | | BigDecimal receivableAmount = new BigDecimal(feePrice); |
| | | |
| | | BigDecimal dayReceivableAmount = null; |
| | | |
| | | //todo 一次性费用 日应收计算 |
| | | if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) { |
| | | int day = DateUtil.daysBetween(endTime, startTime); |
| | | if (day < 1) { |
| | | day = 1; |
| | | } |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(day), 8, BigDecimal.ROUND_HALF_UP);// 日 应收 |
| | | } |
| | | |
| | | // todo 寻找第一个自然月 一日 |
| | | Calendar firstMonthDayCal = Calendar.getInstance(); |
| | |
| | | calendar.setTime(startMonthDayTime); |
| | | curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | |
| | | |
| | | //todo 周期性费用 日应收重新算 |
| | | if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) { |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | } |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | // todo 计算 应收 |
| | | curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP); |
| | | |
| | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startMonthDayTime); |
| | | curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | // todo 如果不是整月,则转换为按天计算 |
| | | // if (curDay != curMonthMaxDay) { |
| | | //todo 周期性费用 日应收重新算 |
| | | if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) { |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | } |
| | | // todo 计算 应收 |
| | | curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP); |
| | | // } else { // todo 如果是整月 那就按月计算,以免 转换成天再 乘以天数后的误差 |
| | | // curMonthReceivableAmount = receivableAmount; |
| | | // } |
| | | //todo 周期性费用 日应收重新算 |
| | | if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) { |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | } |
| | | // todo 计算 应收 |
| | | curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP); |
| | | |
| | | // todo 保存数据到pay_fee_detail_month |
| | | toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime, deadlineTime); |
| | | payFeeDetailMonthInnerServiceSMOImpl.savePayFeeDetailMonths(payFeeDetailMonthPos); |
| | | |
| | | } |
| | | |
| | | private void doDispersedFeeDetail(FeeDetailDto feeDetailDto, FeeDto feeDto, PayFeeMonthOwnerDto |
| | | payFeeMonthOwnerDto,Double feePrice) { |
| | | List<PayFeeDetailMonthPo> payFeeDetailMonthPos = new ArrayList<>(); |
| | | |
| | | // todo 去除 开始时间和 结束时间的 小时 分钟 秒 |
| | | Date startTime = DateUtil.timeToDate(feeDetailDto.getStartTime()); |
| | | Date endTime = DateUtil.timeToDate(feeDetailDto.getEndTime()); |
| | | /** |
| | | * 一次性或者非自然月处理 |
| | | * @param feeDto |
| | | * @param payFeeMonthOwnerDto |
| | | * @param deadlineTime |
| | | * @param oweMonth |
| | | */ |
| | | private void waitDispersedOweFeeOnceUnNormalMonth(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto,double feePrice, Date deadlineTime, double oweMonth) { |
| | | |
| | | // 不是一次性费用 并且是 自然月就返回 |
| | | if(!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag()) && DateUtil.getDay(feeDto.getStartTime()) == 1){ |
| | | return; |
| | | } |
| | | List<PayFeeDetailMonthPo> payFeeDetailMonthPos = new ArrayList<>(); |
| | | // todo 处理 开始时间和结束时间 |
| | | Date startTime = DateUtil.timeToDate(feeDto.getEndTime()); |
| | | Date endTime = DateUtil.deadTimeToDate(deadlineTime); |
| | | |
| | | |
| | | BigDecimal receivableAmount = new BigDecimal(feePrice).multiply(new BigDecimal(oweMonth)).setScale(8,BigDecimal.ROUND_HALF_UP); |
| | | |
| | | BigDecimal dayReceivableAmount = null; |
| | | |
| | | |
| | | int day = DateUtil.daysBetween(endTime, startTime); |
| | | if (day < 1) { |
| | | day = 1; |
| | | } |
| | | double month = DateUtil.dayCompare(feeDetailDto.getStartTime(),feeDetailDto.getEndTime(),true); |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(day), 8, BigDecimal.ROUND_HALF_UP);// 日 应收 |
| | | |
| | | BigDecimal receivableAmount = new BigDecimal(feePrice+""); |
| | | // todo 寻找第一个自然月 一日 |
| | | Calendar firstMonthDayCal = Calendar.getInstance(); |
| | | firstMonthDayCal.setTime(startTime); |
| | | firstMonthDayCal.add(Calendar.MONTH, 1); |
| | | firstMonthDayCal.set(Calendar.DAY_OF_MONTH, 1); |
| | | Date firstMonthDayTime = firstMonthDayCal.getTime(); |
| | | |
| | | Date startMonthDayTime = startTime; |
| | | // todo 循环,只到 firstMonthDayTime 大于 endTime |
| | | int curDay = 0; |
| | | int curMonthMaxDay = 30; |
| | | BigDecimal curMonthReceivableAmount = null; |
| | | |
| | | while (firstMonthDayTime.getTime() < endTime.getTime()) { |
| | | curDay = DateUtil.daysBetween(firstMonthDayTime, startMonthDayTime); |
| | | // todo 计算 应收 |
| | | curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP); |
| | | |
| | | // todo 保存数据到pay_fee_detail_month |
| | | toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime, deadlineTime); |
| | | |
| | | // todo 将startTime 修改为 下月1日时间 |
| | | startMonthDayTime = firstMonthDayTime; |
| | | firstMonthDayCal.add(Calendar.MONTH, 1); |
| | | firstMonthDayTime = firstMonthDayCal.getTime(); |
| | | } |
| | | |
| | | //todo 最后处理 最后 startMonthDayTime 到endTime 的 |
| | | if (startMonthDayTime.getTime() >= endTime.getTime()) { |
| | | payFeeDetailMonthInnerServiceSMOImpl.savePayFeeDetailMonths(payFeeDetailMonthPos); |
| | | return; |
| | | } |
| | | curDay = DateUtil.daysBetween(endTime, startMonthDayTime); |
| | | // todo 计算 应收 |
| | | curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP); |
| | | // todo 保存数据到pay_fee_detail_month |
| | | toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime, deadlineTime); |
| | | payFeeDetailMonthInnerServiceSMOImpl.savePayFeeDetailMonths(payFeeDetailMonthPos); |
| | | } |
| | | |
| | | private void doDispersedFeeDetail(FeeDetailDto feeDetailDto, FeeDto feeDto, PayFeeMonthOwnerDto |
| | | payFeeMonthOwnerDto, Double feePrice) { |
| | | List<PayFeeDetailMonthPo> payFeeDetailMonthPos = new ArrayList<>(); |
| | | |
| | | // todo 去除 开始时间和 结束时间的 小时 分钟 秒 |
| | | Date startTime = DateUtil.timeToDate(feeDetailDto.getStartTime()); |
| | | Date endTime = feeDetailDto.getEndTime(); |
| | | endTime = DateUtil.getNextSecDateTime(endTime); |
| | | endTime = DateUtil.timeToDate(endTime); |
| | | |
| | | int day = DateUtil.daysBetween(endTime, startTime); |
| | | if (day < 1) { |
| | | day = 1; |
| | | } |
| | | double month = DateUtil.dayCompare(feeDetailDto.getStartTime(), feeDetailDto.getEndTime(), true); |
| | | |
| | | BigDecimal receivableAmount = new BigDecimal(feePrice + ""); |
| | | BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(feeDetailDto.getReceivedAmount())); |
| | | |
| | | BigDecimal dayReceivableAmount = receivableAmount.divide(new BigDecimal(day), 8, BigDecimal.ROUND_HALF_UP);// 日 应收 |
| | |
| | | curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) { |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | dayReceivedAmount = receivedAmount.divide(new BigDecimal(month+""), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | dayReceivedAmount = receivedAmount.divide(new BigDecimal(month + ""), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | dayReceivedAmount = dayReceivedAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | } |
| | | // todo 计算 应收 |
| | |
| | | curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) { |
| | | dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | dayReceivedAmount = receivedAmount.divide(new BigDecimal(month+""), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | dayReceivedAmount = receivedAmount.divide(new BigDecimal(month + ""), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | dayReceivedAmount = dayReceivedAmount.divide(new BigDecimal(curMonthMaxDay), 8, BigDecimal.ROUND_HALF_UP);// 日 实收 |
| | | } |
| | | // todo 计算 应收 |
| | |
| | | getDiscountAmount(Double.parseDouble(tmpPayFeeDetailMonthPo.getReceivableAmount()), |
| | | Double.parseDouble(tmpPayFeeDetailMonthPo.getReceivedAmount()), |
| | | calendar.getTime(), feeDto) + ""); |
| | | if (feeDetailDto == null) { |
| | | tmpPayFeeDetailMonthPo.setDiscountAmount("0"); |
| | | } |
| | | tmpPayFeeDetailMonthPo.setMonthId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_monthId, true)); |
| | | tmpPayFeeDetailMonthPo.setRemark("程序计算生成"); |
| | | tmpPayFeeDetailMonthPo.setObjName(payFeeMonthOwnerDto.getObjName()); |