From 31bd44345bca0b0fbe9b03eeb67a7499c702a36b Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期五, 18 十二月 2020 10:30:04 +0800
Subject: [PATCH] 优化算费

---
 service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 1 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 acf30ed..77112db 100644
--- 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
@@ -11,6 +11,7 @@
 import com.java110.dto.report.ReportRoomDto;
 import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
 import com.java110.intf.report.IGeneratorFeeMonthStatisticsInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
 import com.java110.po.reportFeeMonthStatistics.ReportFeeMonthStatisticsPo;
 import com.java110.report.dao.IReportCommunityServiceDao;
 import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
@@ -52,6 +53,9 @@
 
     @Autowired
     private IComputeFeeSMO computeFeeSMOImpl;
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
 
     @Override
     public int generatorData(@RequestBody ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
@@ -219,7 +223,7 @@
                 && receivedAmount == 0) {
             return;
         }
-        double receivableAmount = getReceivableAmount(tmpReportFeeDto, null, tmpReportCarDto); //搴旀敹
+        double receivableAmount = getReceivableAmountByCar(tmpReportFeeDto, null, tmpReportCarDto); //搴旀敹
         double oweAmount = getOweAmount(tmpReportFeeDto, receivableAmount, receivedAmount); //娆犺垂
         FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
         OwnerCarDto ownerCarDto = BeanConvertUtil.covertBean(tmpReportCarDto, OwnerCarDto.class);
@@ -410,6 +414,59 @@
      * @param tmpReportFeeDto
      * @return
      */
+    private double getReceivableAmountByCar(ReportFeeDto tmpReportFeeDto, ReportRoomDto reportRoomDto, ReportCarDto reportCarDto) {
+
+        double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, reportCarDto);
+        BigDecimal feePriceDec = new BigDecimal(feePrice);
+
+        if (DateUtil.getCurrentDate().getTime() < tmpReportFeeDto.getStartTime().getTime()) {
+            return 0.0;
+        }
+
+        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeTypeCd())) {
+            return feePrice;
+        }
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCommunityId(tmpReportFeeDto.getCommunityId());
+        ownerCarDto.setCarId(tmpReportFeeDto.getCarId());
+        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+        if(ownerCarDtos == null || ownerCarDtos.size() < 1){
+            return 0.0;
+        }
+        Date endTime = ownerCarDtos.get(0).getEndTime();
+
+        //1.0 璐圭敤鍒版湡鏃堕棿鍜岃垂鐢ㄧ粨鏉熸椂闂� 閮戒笉鍦ㄥ綋鏈�
+        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
+                && !belongCurMonth(endTime)
+                && tmpReportFeeDto.getEndTime().getTime() < DateUtil.getFirstDate().getTime()) {
+            return feePrice;
+        }
+
+        //2.0 璐圭敤鍒版湡鏃堕棿 鍦ㄥ綋鏈堬紝璐圭敤缁撴潫鏃堕棿涓嶅湪褰撴湀
+        if (belongCurMonth(tmpReportFeeDto.getEndTime())
+                && !belongCurMonth(endTime)) {
+            //绠楀ぉ鏁�
+            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
+            BigDecimal curDegree = new BigDecimal(month);
+            return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        }
+        //3.0 璐圭敤鍒版湡鏃堕棿 涓嶅湪褰撴湀锛岃垂鐢ㄧ粨鏉熸椂闂村湪褰撴湀
+        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
+                && belongCurMonth(endTime)) {
+            //绠楀ぉ鏁�
+            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime());
+            BigDecimal curDegree = new BigDecimal(month);
+            return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        }
+        return 0.0;
+    }
+
+    /**
+     * 鑾峰彇褰撴湀搴旀敹
+     *
+     * @param tmpReportFeeDto
+     * @return
+     */
     private double getReceivableAmount(ReportFeeDto tmpReportFeeDto, ReportRoomDto reportRoomDto, ReportCarDto reportCarDto) {
 
         double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, reportCarDto);

--
Gitblit v1.8.0