From 22e8a676ee42c0d78b3526bcd9a635abbe8dca03 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 28 六月 2022 11:28:21 +0800
Subject: [PATCH] 优化databus bug

---
 service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 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 e43fe25..30c13dc 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
@@ -19,7 +19,7 @@
 import com.java110.report.dao.IReportFeeServiceDao;
 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;
@@ -71,6 +71,9 @@
 
         Assert.hasLength(communityId, "鏈寘鍚皬鍖轰俊鎭�");
 
+        //杩欓噷澶勭悊 鎶ヨ〃涓殑璐圭敤鏄惁琚汉涓� 鍙栨秷 鎴栬�呰垂鐢ㄩ」鏄惁琚垹闄わ紝杩欑鏁版嵁 鎶ヨ〃涓仛娓呯悊锛屼互闃插奖鍝� 鎶ヨ〃鐨勫噯纭害
+        feeDataFiltering(communityId);
+
         //澶勭悊鎴垮眿璐圭敤
         dealRoomFee(reportFeeMonthStatisticsPo);
 
@@ -79,6 +82,12 @@
 
         //澶勭悊缂磋垂缁撴潫鐨勬儏鍐�
         dealFinishFee(communityId);
+    }
+
+    private void feeDataFiltering(String communityId) {
+        Map reportFeeDto = new HashMap();
+        reportFeeDto.put("communityId", communityId);
+        reportFeeMonthStatisticsServiceDaoImpl.deleteInvalidFee(reportFeeDto);
     }
 
     private void dealFinishFee(String communityId) {
@@ -248,6 +257,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) + "");
@@ -445,6 +458,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) + "");
@@ -768,6 +785,11 @@
         }
         Date endTime = ownerCarDtos.get(0).getEndTime();
 
+        Date maxEndDate = tmpReportFeeDto.getDeadlineTime();
+        if(FeeDto.FEE_FLAG_CYCLE.equals(tmpReportFeeDto.getFeeFlag())){
+            maxEndDate = tmpReportFeeDto.getConfigEndTime();
+        }
+
         //1.0 璐圭敤鍒版湡鏃堕棿鍜岃垂鐢ㄧ粨鏉熸椂闂� 閮戒笉鍦ㄥ綋鏈�
         if (!belongCurMonth(tmpReportFeeDto.getEndTime())
                 && !belongCurMonth(endTime)
@@ -787,7 +809,7 @@
         if (!belongCurMonth(tmpReportFeeDto.getEndTime())
                 && belongCurMonth(endTime)) {
             //绠楀ぉ鏁�
-            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime());
+            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate);
             BigDecimal curDegree = new BigDecimal(month);
             return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
         }
@@ -833,16 +855,21 @@
             return computeOnceFee(tmpReportFeeDto);
         }
 
+        Date maxEndDate = tmpReportFeeDto.getDeadlineTime();
+        if(FeeDto.FEE_FLAG_CYCLE.equals(tmpReportFeeDto.getFeeFlag())){
+            maxEndDate = tmpReportFeeDto.getConfigEndTime();
+        }
+
         //1.0 璐圭敤鍒版湡鏃堕棿鍜岃垂鐢ㄧ粨鏉熸椂闂� 閮戒笉鍦ㄥ綋鏈�
         if (!belongCurMonth(tmpReportFeeDto.getEndTime())
-                && !belongCurMonth(tmpReportFeeDto.getConfigEndTime())
+                && !belongCurMonth(maxEndDate)
                 && tmpReportFeeDto.getEndTime().getTime() < DateUtil.getFirstDate().getTime()) {
             return feePrice;
         }
 
         //2.0 璐圭敤鍒版湡鏃堕棿 鍦ㄥ綋鏈堬紝璐圭敤缁撴潫鏃堕棿涓嶅湪褰撴湀
         if (belongCurMonth(tmpReportFeeDto.getEndTime())
-                && !belongCurMonth(tmpReportFeeDto.getConfigEndTime())) {
+                && !belongCurMonth(maxEndDate)) {
             //绠楀ぉ鏁�
             double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
             BigDecimal curDegree = new BigDecimal(month);
@@ -850,9 +877,9 @@
         }
         //3.0 璐圭敤鍒版湡鏃堕棿 涓嶅湪褰撴湀锛岃垂鐢ㄧ粨鏉熸椂闂村湪褰撴湀
         if (!belongCurMonth(tmpReportFeeDto.getEndTime())
-                && belongCurMonth(tmpReportFeeDto.getConfigEndTime())) {
+                && belongCurMonth(maxEndDate)) {
             //绠楀ぉ鏁�
-            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime());
+            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate);
             BigDecimal curDegree = new BigDecimal(month);
             return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
         }

--
Gitblit v1.8.0