From e52ddfe8caf7d0027950033a5aff2a1fd3482e9d Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 01 六月 2022 17:50:25 +0800
Subject: [PATCH] 优化装修 跟踪记录 回显

---
 service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java |   75 +++++++++++++++++++++++++------------
 1 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
index 612bad9..0685c30 100755
--- a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
+++ b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
@@ -17,24 +17,16 @@
 import com.java110.report.dao.IReportCommunityServiceDao;
 import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
 import com.java110.report.dao.IReportFeeServiceDao;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.ListUtil;
-import com.java110.utils.util.StringUtil;
+import com.java110.utils.util.*;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @ClassName GeneratorFeeMonthStatisticsInnerServiceSMOImpl
@@ -256,6 +248,10 @@
 //            reportFeeMonthStatisticsPo.setReceivedAmount("0");
             reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            // 缂磋垂浜嗗氨寰楀埛
+            reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
+            //鏈夊彲鑳芥槸鏈堝唴鍒涘缓鐨勮垂鐢� 姣斿鐢佃垂姘磋垂
+            reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
             reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
             reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
             reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
@@ -453,6 +449,10 @@
             reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
             reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
+            // 缂磋垂浜嗗氨寰楀埛
+            reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
+            //鏈夊彲鑳芥槸鏈堝唴鍒涘缓鐨勮垂鐢� 姣斿鐢佃垂姘磋垂
+            reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
             reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
             reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
             reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
@@ -508,7 +508,7 @@
         paramIn.put("endTime", DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
         paramIn.put("feeId", tmpReportFeeDto.getFeeId());
         paramIn.put("yearMonth", DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_M));
-        paramIn.put("flag", 1);
+        paramIn.put("flag", flag);
         double curReceivedAmount = reportFeeMonthStatisticsServiceDaoImpl.getReceivedAmountByMonth(paramIn);
         return curReceivedAmount;
     }
@@ -529,16 +529,34 @@
                 || curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
             return 0.0;
         }
+
+        //杩欓噷闇�瑕佸垽鏂� 缁撴潫鏃堕棿 鏄惁 澶т簬浜嗗綋鏈堟渶鍚庝竴澶╋紝褰撴湀澶╂暟 * 姣忓ぉ閲戦
+        Calendar nextDateC = Calendar.getInstance();
+        nextDateC.setTime(curDate);
+        nextDateC.add(Calendar.MONTH, 1);
+        Date nextDate = nextDateC.getTime();
+
         if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
-            month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
-            month = Math.ceil(month);
-            if (month == 0) {
-                return 0.0;
+            double allDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+            allDays = Math.ceil(allDays);
+            if (allDays == 0) { // 闃叉闄ゆ暟涓�0
+                return 0;
             }
-            double money = feePriceDec.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-            return money;
+            BigDecimal moneyPreDay = feePriceDec.divide(new BigDecimal(allDays), 2, BigDecimal.ROUND_HALF_EVEN);
+            if (tmpReportFeeDto.getDeadlineTime().getTime() > nextDate.getTime()) {
+                int day = DateUtil.getCurrentMonthDay();
+                return moneyPreDay.multiply(new BigDecimal(day)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+            }
+            // 缁撴潫鏃堕棿 鍦ㄥ綋鏈堝唴
+            double hisDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), curDate);
+            BigDecimal hisDayDec = moneyPreDay.multiply(new BigDecimal(hisDays)).setScale(2, BigDecimal.ROUND_HALF_UP);
+            return feePriceDec.subtract(hisDayDec).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
         }
-        month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curDate);
+
+        month = computeFeeSMOImpl.dayCompare(curDate, tmpReportFeeDto.getDeadlineTime());
+        if (month < 0) {
+            return 0;
+        }
         if (month < 1) {
             return feePriceDec.multiply(new BigDecimal(month)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
         }
@@ -556,7 +574,7 @@
     private double getHisOweAmount(ReportFeeDto tmpReportFeeDto) {
 
         BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
-        Date curDate = DateUtil.getFirstDate();
+        Date curDate = DateUtil.getFirstDate();//11鏈�1鏃�
         //璇存槑娌℃湁鍘嗗彶娆犺垂
         if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
             return 0.0;
@@ -567,10 +585,17 @@
             if (tmpReportFeeDto.getDeadlineTime().getTime() < curDate.getTime()) {
                 return tmpReportFeeDto.getFeePrice();
             }
-            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getDeadlineTime(), tmpReportFeeDto.getEndTime());
-            month = Math.ceil(month);
-            double money = feePriceDec.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-            return money;
+            double allDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+            allDays = Math.ceil(allDays);
+            if (allDays == 0) { // 闃叉闄ゆ暟涓�0
+                return 0;
+            }
+            //杩欐槸姣忓ぉ鐨勯挶
+            BigDecimal moneyPreDay = feePriceDec.divide(new BigDecimal(allDays), 2, BigDecimal.ROUND_HALF_EVEN);
+
+            double hisDays = computeFeeSMOImpl.daysBetween(tmpReportFeeDto.getEndTime(), curDate);
+
+            return moneyPreDay.multiply(new BigDecimal(hisDays)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
         }
 
         double month = 0.0;
@@ -787,7 +812,7 @@
         month = Math.ceil(month);
 
         if (month == 0) {
-            logger.debug("鐩稿樊鏈堜唤涓�0锛寋}", JSONObject.toJSONString(tmpReportFeeDto);
+            logger.debug("鐩稿樊鏈堜唤涓�0锛寋}", JSONObject.toJSONString(tmpReportFeeDto));
             return tmpReportFeeDto.getFeePrice();
         }
 

--
Gitblit v1.8.0