From 8954429263a75e3c7d19db20a60370fca005f2bd Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 08 八月 2023 15:44:49 +0800
Subject: [PATCH] 优化代码

---
 service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java b/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
index 695d42c..c80178f 100755
--- a/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
+++ b/service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
@@ -5,7 +5,7 @@
 import com.java110.core.factory.Java110ThreadPoolFactory;
 import com.java110.core.log.LoggerFactory;
 import com.java110.core.smo.IComputeFeeSMO;
-import com.java110.dto.RoomDto;
+import com.java110.dto.room.RoomDto;
 import com.java110.dto.fee.FeeConfigDto;
 import com.java110.dto.fee.FeeDto;
 import com.java110.dto.owner.OwnerCarDto;
@@ -21,9 +21,7 @@
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.ResponseConstant;
 import com.java110.utils.exception.ListenerExecuteException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.StringUtil;
+import com.java110.utils.util.*;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,8 +30,6 @@
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 @Service
@@ -88,12 +84,24 @@
             feeDtos = new ArrayList<>();
             return ResultVo.createResponseEntity(feeDtos);
         }
+        String val = CommunitySettingFactory.getValue(feeDtos.get(0).getCommunityId(), TOTAL_FEE_PRICE);
+        if (StringUtil.isEmpty(val)) {
+            val = MappingCache.getValue(DOMAIN_COMMON, TOTAL_FEE_PRICE);
+        }
         List<FeeDto> tmpFeeDtos = new ArrayList<>();
         for (FeeDto tmpFeeDto : feeDtos) {
             try {
                 computeFeeSMOImpl.computeEveryOweFee(tmpFeeDto);//璁$畻娆犺垂閲戦
                 //濡傛灉閲戦涓�0 灏辨帓闄�
-                //if (tmpFeeDto.getFeePrice() > 0 && tmpFeeDto.getEndTime().getTime() <= DateUtil.getCurrentDate().getTime()) {
+                tmpFeeDto.setFeeTotalPrice(
+                        MoneyUtil.computePriceScale(
+                                tmpFeeDto.getFeeTotalPrice(),
+                                tmpFeeDto.getScale(),
+                                Integer.parseInt(tmpFeeDto.getDecimalPlace())
+                        )
+                );
+
+                tmpFeeDto.setVal(val);
                 if (tmpFeeDto.getFeePrice() > 0) {
                     tmpFeeDtos.add(tmpFeeDto);
                 }
@@ -132,12 +140,16 @@
         }
         String cycel = null;
         String custEndTime = null;
+        String customStartTime = "";
+        String customEndTime = "";
         if (!StringUtil.isEmpty(feeDto.getCycle())) {
             cycel = feeDto.getCycle();
         }
         if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
             custEndTime = feeDto.getCustEndTime();
         }
+        customStartTime = feeDto.getCustomStartTime();
+        customEndTime = feeDto.getCustomEndTime();
         feeDto = feeDtos.get(0);
         if (!StringUtil.isEmpty(cycel)) {
             feeDto.setCycle(cycel);
@@ -145,6 +157,9 @@
         if (!StringUtil.isEmpty(custEndTime)) {
             feeDto.setCustEndTime(custEndTime);
         }
+
+        feeDto.setCustomStartTime(customStartTime);
+        feeDto.setCustomEndTime(customEndTime);
 
         if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
             RoomDto roomDto = new RoomDto();
@@ -177,9 +192,26 @@
             feeDto.setPayerObjName(ownerCarDto.getCarNum() + "(" + parkingSpaceDto.getAreaNum() + "鍋滆溅鍦�" + parkingSpaceDto.getNum() + "杞︿綅)");
             feeDto.setBuiltUpArea(parkingSpaceDto.getArea());
         }
+
         Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
         feeDto.setFeePrice(Double.parseDouble(feePriceAll.get("feePrice").toString()));
-        feeDto.setFeeTotalPrice(Double.parseDouble(feePriceAll.get("feeTotalPrice").toString()));
+
+        feeDto.setFeeTotalPrice(
+                MoneyUtil.computePriceScale(
+                        Double.parseDouble(feePriceAll.get("feeTotalPrice").toString()),
+                        feeDto.getScale(),
+                        Integer.parseInt(feeDto.getDecimalPlace())
+                )
+        );
+
+        if (!StringUtil.isEmpty(custEndTime)) {
+            Date date = DateUtil.getDateFromStringB(custEndTime);
+            computeFeeSMOImpl.dealRentRateCustEndTime(feeDto, date);
+        } else {
+            computeFeeSMOImpl.dealRentRateCycle(feeDto, NumberUtil.getDouble(feeDto.getCycle()));
+        }
+
+
         //搴旀敹娆惧彇鍊�
         //鍏堝彇鍗曞皬鍖虹殑濡傛灉娌℃湁閰嶇疆 鍙� 鍏ㄥ眬鐨�
         String val = CommunitySettingFactory.getValue(feeDto.getCommunityId(), TOTAL_FEE_PRICE);
@@ -204,6 +236,9 @@
             offlinePayFeeSwitch = MappingCache.getValue(DOMAIN_COMMON, OFFLINE_PAY_FEE_SWITCH);
         }
         feeDto.setOfflinePayFeeSwitch(offlinePayFeeSwitch);
+        //鍘绘帀澶氫綑0
+        feeDto.setSquarePrice(Double.parseDouble(feeDto.getSquarePrice()) + "");
+        feeDto.setAdditionalAmount(Double.parseDouble(feeDto.getAdditionalAmount()) + "");
         return ResultVo.createResponseEntity(feeDto);
     }
 
@@ -448,6 +483,8 @@
             feePrice = 0.0;
         } else if ("1101".equals(computingFormula)) { // 绉熼噾
             feePrice = 0.0;
+        } else if ("1102".equals(computingFormula)) { // 绉熼噾
+            feePrice = 0.0;
         } else if ("4004".equals(computingFormula)) {
             feePrice = Double.parseDouble(feeDto.getAmount());
         } else if ("5005".equals(computingFormula)) {
@@ -567,6 +604,9 @@
         } else if ("1101".equals(computingFormula)) { // 绉熼噾
             BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpRoomDto.getRoomRent()));
             feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else if ("1102".equals(computingFormula)) { // 绉熼噾
+            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpRoomDto.getRoomRent()));
+            feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN).doubleValue();
         } else if ("4004".equals(computingFormula)) {
             feePrice = Double.parseDouble(feeDto.getAmount());
         } else if ("5005".equals(computingFormula)) {

--
Gitblit v1.8.0