Your Name
2023-05-18 f4dbf3ffa233786dbb4e28ab2174a304e34fece8
优化 离散月
3个文件已修改
155 ■■■■ 已修改文件
service-fee/src/main/java/com/java110/fee/feeMonth/IPayFeeMonthHelp.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java 128 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-fee/src/main/java/com/java110/fee/feeMonth/IPayFeeMonthHelp.java
@@ -16,33 +16,8 @@
    Double getMonthFeePrice(FeeDto feeDto);
    Double getReceivableAmount(List<FeeDetailDto> feeDetailDtos, Double feePrice, Date curDate, FeeDto feeDto);
    /**
     * 计算实收
     * @param feeDetailDtos
     * @param feePrice
     * @return
     */
    Double getReceivedAmount(List<FeeDetailDto> feeDetailDtos, Double feePrice, Date curDate, FeeDto feeDto);
    Double getDiscountAmount(Double feePrice, double receivedAmount, Date curDate, FeeDto feeDto);
    /**
     * 计算缴费DetailId
     * @param feeDetailDtos
     * @param time
     * @return
     */
    String getFeeDetailId(List<FeeDetailDto> feeDetailDtos, Date time);
    /**
     * 获取 支付时间
     * @param feeDetailDtos
     * @param detailId
     * @return
     */
    String getFeeFeeTime(List<FeeDetailDto> feeDetailDtos, String detailId);
    void waitDispersedFeeDetail(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto);
service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java
@@ -68,49 +68,6 @@
    }
    public Double getReceivableAmount(List<FeeDetailDto> feeDetailDtos, Double feePrice, Date curDate, FeeDto feeDto) {
        FeeDetailDto feeDetailDto = getCurFeeDetail(feeDetailDtos, curDate);
        if (feeDetailDto == null && curDate.getTime() < feeDto.getEndTime().getTime()) {
            return 0.00;
        }
        return feePrice;
    }
    @Override
    public Double getReceivedAmount(List<FeeDetailDto> feeDetailDtos, Double feePrice, Date curDate, FeeDto feeDto) {
        //todo 这种情况下应该 实收为0
        if (curDate.getTime() >= feeDto.getEndTime().getTime()) {
            return 0.00;
        }
        //todo 如果 fee 为空
        if (feeDetailDtos == null) {
            return feePrice;
        }
        FeeDetailDto feeDetailDto = getCurFeeDetail(feeDetailDtos, curDate);
        if (feeDetailDto == null && curDate.getTime() < feeDto.getEndTime().getTime()) {
            return 0.00;
        }
        if (feeDetailDto == null) {
            return feePrice;
        }
        double maxMonth = Math.ceil(computeFeeSMOImpl.dayCompare(feeDetailDto.getStartTime(), feeDetailDto.getEndTime()));
        if (maxMonth < 1) {
            return Double.parseDouble(feeDetailDto.getReceivedAmount());
        }
        BigDecimal totalRecDec = new BigDecimal(feeDetailDto.getReceivedAmount());
        //每月平均值
        BigDecimal priRecDec = totalRecDec.divide(new BigDecimal(maxMonth), 4, BigDecimal.ROUND_HALF_UP);
        return priRecDec.doubleValue();
    }
    @Override
    public Double getDiscountAmount(Double feePrice, double receivedAmount, Date curDate, FeeDto feeDto) {
@@ -123,32 +80,10 @@
        return discountAmountDec.doubleValue();
    }
    @Override
    public String getFeeDetailId(List<FeeDetailDto> feeDetailDtos, Date curDate) {
        FeeDetailDto feeDetailDto = getCurFeeDetail(feeDetailDtos, curDate);
        if (feeDetailDto == null) {
            return "-1";
        }
        return feeDetailDto.getDetailId();
    }
    @Override
    public String getFeeFeeTime(List<FeeDetailDto> feeDetailDtos, String detailId) {
        if (feeDetailDtos == null || feeDetailDtos.size() < 1) {
            return null;
        }
        for (FeeDetailDto feeDetailDto : feeDetailDtos) {
            if (feeDetailDto.getDetailId().equals(detailId)) {
                return DateUtil.getFormatTimeStringA(feeDetailDto.getCreateTime());
            }
        }
        return null;
    }
    /**
     *  处理已经交过费的记录处理
     * 处理已经交过费的记录处理
     *
     * @param feeDto
     * @param payFeeMonthOwnerDto
     */
@@ -172,6 +107,7 @@
    /**
     * 处理 欠费 离散
     *
     * @param feeDto
     * @param payFeeMonthOwnerDto
     * @param feePrice
@@ -180,8 +116,8 @@
    @Autowired
    public void waitDispersedOweFee(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto, Double feePrice, Date deadlineTime) {
        // todo 费用已经结束
        if(FeeDto.STATE_FINISH.equals(feeDto.getState())){
            return ;
        if (FeeDto.STATE_FINISH.equals(feeDto.getState())) {
            return;
        }
        // todo 清理 detailId 为-1 的数据
@@ -211,7 +147,7 @@
        int curMonthMaxDay = 30;
        BigDecimal curMonthReceivableAmount = null;
        BigDecimal dayReceivableAmount = null;
        while (firstMonthDayTime.getTime() > endTime.getTime()) {
        while (firstMonthDayTime.getTime() < endTime.getTime()) {
            curDay = DateUtil.daysBetween(firstMonthDayTime, startMonthDayTime);
            // todo 计算当月天数
@@ -223,7 +159,7 @@
            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);
            toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
            // todo 将startTime 修改为 下月1日时间
            startMonthDayTime = firstMonthDayTime;
@@ -248,7 +184,7 @@
        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);
        toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
        payFeeDetailMonthInnerServiceSMOImpl.savePayFeeDetailMonths(payFeeDetailMonthPos);
    }
@@ -283,7 +219,7 @@
        int curDay = 0;
        BigDecimal curMonthReceivableAmount = null;
        BigDecimal curMonthReceivedAmount = null;
        while (firstMonthDayTime.getTime() > endTime.getTime()) {
        while (firstMonthDayTime.getTime() < endTime.getTime()) {
            curDay = DateUtil.daysBetween(firstMonthDayTime, startMonthDayTime);
            // todo 计算 应收
            curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP);
@@ -291,7 +227,7 @@
            curMonthReceivedAmount = new BigDecimal(curDay).multiply(dayReceivedAmount).setScale(4, BigDecimal.ROUND_HALF_UP);
            // todo 保存数据到pay_fee_detail_month
            toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto,payFeeDetailMonthPos,startMonthDayTime);
            toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
            // todo 将startTime 修改为 下月1日时间
            startMonthDayTime = firstMonthDayTime;
@@ -312,7 +248,7 @@
        curMonthReceivedAmount = new BigDecimal(curDay).multiply(dayReceivedAmount).setScale(4, BigDecimal.ROUND_HALF_UP);
        // todo 保存数据到pay_fee_detail_month
        toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto,payFeeDetailMonthPos,startMonthDayTime);
        toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
        payFeeDetailMonthInnerServiceSMOImpl.savePayFeeDetailMonths(payFeeDetailMonthPos);
    }
@@ -338,9 +274,9 @@
        PayFeeDetailMonthPo tmpPayFeeDetailMonthPo = new PayFeeDetailMonthPo();
        tmpPayFeeDetailMonthPo.setFeeId(feeDto.getFeeId());
        tmpPayFeeDetailMonthPo.setCommunityId(feeDto.getCommunityId());
        if(feeDetailDto == null){
        if (feeDetailDto == null) {
            tmpPayFeeDetailMonthPo.setDetailId("-1");
        }else{ // todo 交费记录 保存时
        } else { // todo 交费记录 保存时
            tmpPayFeeDetailMonthPo.setDetailId(feeDetailDto.getDetailId());
        }
        tmpPayFeeDetailMonthPo.setDetailYear(calendar.get(Calendar.YEAR) + "");
@@ -360,9 +296,9 @@
        tmpPayFeeDetailMonthPo.setOwnerName(payFeeMonthOwnerDto.getOwnerName());
        tmpPayFeeDetailMonthPo.setLink(payFeeMonthOwnerDto.getLink());
        tmpPayFeeDetailMonthPo.setCurMonthTime(DateUtil.getFormatTimeStringB(calendar.getTime()));
        if(feeDetailDto == null){
        if (feeDetailDto == null) {
            tmpPayFeeDetailMonthPo.setPayFeeTime(null);
        }else{ // todo 交费记录 保存时
        } else { // todo 交费记录 保存时
            tmpPayFeeDetailMonthPo.setPayFeeTime(DateUtil.getFormatTimeStringA(feeDetailDto.getCreateTime()));
        }
        tmpPayFeeDetailMonthPo.setState("W"); // todo 这里暂时写死,目前用不到,算是预留字段
@@ -372,40 +308,6 @@
    }
    /**
     * 获取当前缴费记录
     *
     * @param feeDetailDtos
     * @param curDate
     * @return
     */
    private FeeDetailDto getCurFeeDetail(List<FeeDetailDto> feeDetailDtos, Date curDate) {
        if (feeDetailDtos == null || feeDetailDtos.size() < 1) {
            return null;
        }
        List<FeeDetailDto> tFeeDetailDtos = new ArrayList<>();
        for (FeeDetailDto feeDetailDto : feeDetailDtos) {
            if (feeDetailDto.getStartTime().getTime() <= curDate.getTime() && feeDetailDto.getEndTime().getTime() > curDate.getTime()) {
                tFeeDetailDtos.add(BeanConvertUtil.covertBean(feeDetailDto,FeeDetailDto.class));
            }
        }
        if (tFeeDetailDtos.size() < 1) {
            return null;
        }
        if (tFeeDetailDtos.size() == 1) {
            return tFeeDetailDtos.get(0);
        }
        //todo 这种应该是数据异常 也就是一个月费用变更后重复缴费
        BigDecimal cReceivedAmount = new BigDecimal(0.00);
        for (FeeDetailDto feeDetailDto : tFeeDetailDtos) {
            cReceivedAmount = cReceivedAmount.add(new BigDecimal(Double.parseDouble(feeDetailDto.getReceivedAmount()))).setScale(4, BigDecimal.ROUND_HALF_UP);
        }
        tFeeDetailDtos.get(0).setReceivedAmount(cReceivedAmount.doubleValue() + "");
        return tFeeDetailDtos.get(0);
    }
}
service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthImpl.java
@@ -166,7 +166,7 @@
    private void doGeneratorOrRefreshFeeMonth(FeeDto feeDto, String communityId) {
        //todo 计算每月单价
        // todo 计算每月单价
        Double feePrice = payFeeMonthHelp.getMonthFeePrice(feeDto);
        // todo 准备离散的基础数据