From 22d7512ecb341426ecaa5ac8d48d7aa2b37c1059 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 09 六月 2022 16:27:41 +0800
Subject: [PATCH] 优化代码

---
 java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java |  250 ++++++++++++++++++++++++++------------------------
 1 files changed, 130 insertions(+), 120 deletions(-)

diff --git a/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java b/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
index 5de6d60..f24565d 100755
--- a/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
+++ b/java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
@@ -1,16 +1,15 @@
 package com.java110.core.smo.impl;
 
+import com.java110.config.properties.code.Java110Properties;
+import com.java110.core.context.Environment;
+import com.java110.core.log.LoggerFactory;
 import com.java110.core.smo.IComputeFeeSMO;
 import com.java110.dto.RoomDto;
 import com.java110.dto.community.CommunityDto;
 import com.java110.dto.contract.ContractDto;
 import com.java110.dto.contractRoom.ContractRoomDto;
-import com.java110.dto.fee.BillDto;
-import com.java110.dto.fee.BillOweFeeDto;
-import com.java110.dto.fee.FeeAttrDto;
-import com.java110.dto.fee.FeeConfigDto;
-import com.java110.dto.fee.FeeDto;
-import com.java110.dto.fee.TempCarFeeResult;
+import com.java110.dto.fee.*;
+import com.java110.dto.machine.CarInoutDetailDto;
 import com.java110.dto.machine.CarInoutDto;
 import com.java110.dto.owner.OwnerCarDto;
 import com.java110.dto.owner.OwnerDto;
@@ -18,12 +17,9 @@
 import com.java110.dto.report.ReportCarDto;
 import com.java110.dto.report.ReportFeeDto;
 import com.java110.dto.report.ReportRoomDto;
-import com.java110.dto.tempCarFeeConfig.TempCarFeeConfigAttrDto;
-import com.java110.dto.tempCarFeeConfig.TempCarFeeConfigDto;
 import com.java110.intf.community.ICommunityInnerServiceSMO;
 import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
 import com.java110.intf.community.IRoomInnerServiceSMO;
-import com.java110.intf.fee.IComputeTempCarFee;
 import com.java110.intf.fee.IFeeInnerServiceSMO;
 import com.java110.intf.fee.ITempCarFeeConfigAttrInnerServiceSMO;
 import com.java110.intf.fee.ITempCarFeeConfigInnerServiceSMO;
@@ -34,13 +30,11 @@
 import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo;
 import com.java110.utils.constant.ResponseConstant;
 import com.java110.utils.exception.ListenerExecuteException;
-import com.java110.utils.factory.ApplicationContextFactory;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.DateUtil;
 import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -48,12 +42,7 @@
 import javax.script.ScriptEngineManager;
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 璐圭敤璁$畻 鏈嶅姟绫�
@@ -97,6 +86,9 @@
 
     @Autowired(required = false)
     private ITempCarFeeConfigAttrInnerServiceSMO tempCarFeeConfigAttrInnerServiceSMOImpl;
+
+    @Autowired
+    private Java110Properties java110Properties;
 
     @Override
     public Date getFeeEndTime() {
@@ -187,7 +179,7 @@
         feeDto.setFeePrice(Double.parseDouble(feePriceAll.get("feePrice").toString()));
         BigDecimal price = new BigDecimal(feeDto.getFeePrice());
         price = price.multiply(new BigDecimal(oweMonth));
-        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
         feeDto.setDeadlineTime(targetEndDate);
 
         //鍔ㄦ�佽垂鐢�
@@ -216,7 +208,7 @@
         //double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
         BigDecimal price = new BigDecimal(feeDto.getFeePrice());
         price = price.multiply(new BigDecimal(oweMonth));
-        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
         feeDto.setDeadlineTime(targetEndDate);
 
         //鍔ㄦ�佽垂鐢�
@@ -244,7 +236,7 @@
         //double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
         BigDecimal price = new BigDecimal(feeDto.getFeePrice());
         price = price.multiply(new BigDecimal(oweMonth));
-        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
         feeDto.setDeadlineTime(targetEndDate);
 
         //鍔ㄦ�佽垂鐢�
@@ -292,7 +284,7 @@
                 } else {
                     BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                     BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
                     feeReceiptDetailPo.setArea(sub.doubleValue() + "");
                     feeReceiptDetailPo.setSquarePrice(feeDto.getSquarePrice() + "/" + feeDto.getAdditionalAmount());
                 }
@@ -314,10 +306,13 @@
                 } else {
                     BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                     BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
                     feeReceiptDetailPo.setArea(sub.doubleValue() + "");
                     feeReceiptDetailPo.setSquarePrice(feeDto.getMwPrice() + "/" + feeDto.getAdditionalAmount());
                 }
+            } else if ("1101".equals(computingFormula)) { //绉熼噾
+                feeReceiptDetailPo.setArea(roomDtos.get(0).getBuiltUpArea());
+                feeReceiptDetailPo.setSquarePrice(roomDtos.get(0).getRoomRent());
             } else {
             }
         } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//杞︿綅鐩稿叧
@@ -352,7 +347,7 @@
                 } else {
                     BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                     BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
                     feeReceiptDetailPo.setArea(sub.doubleValue() + "");
                     feeReceiptDetailPo.setSquarePrice(feeDto.getSquarePrice() + "/" + feeDto.getAdditionalAmount());
                 }
@@ -381,7 +376,7 @@
                 } else {
                     BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                     BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
                     feeReceiptDetailPo.setArea(sub.doubleValue() + "");
                     feeReceiptDetailPo.setSquarePrice(feeDto.getMwPrice() + "/" + feeDto.getAdditionalAmount());
                 }
@@ -429,7 +424,7 @@
                 } else {
                     BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                     BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
                     feeReceiptDetailPo.setArea(sub.doubleValue() + "");
                     feeReceiptDetailPo.setSquarePrice(feeDto.getSquarePrice() + "/" + feeDto.getAdditionalAmount());
                 }
@@ -455,7 +450,7 @@
                 } else {
                     BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                     BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                    BigDecimal sub = curDegree.subtract(preDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
                     feeReceiptDetailPo.setArea(sub.doubleValue() + "");
                     feeReceiptDetailPo.setSquarePrice(feeDto.getMwPrice() + "/" + feeDto.getAdditionalAmount());
                 }
@@ -800,19 +795,19 @@
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(reportRoomDto.getBuiltUpArea()));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
             } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAdditionalAmount()));
-                feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
             } else if ("3003".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getRoomArea()));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_UP);
             } else if ("1101".equals(computingFormula)) { // 绉熼噾
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getRoomRent()));
-                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_UP);
             } else if ("4004".equals(computingFormula)) {
                 feePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAmount()));
             } else if ("5005".equals(computingFormula)) {
@@ -826,7 +821,7 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("6006".equals(computingFormula)) {
                 feePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAmount()));
@@ -843,7 +838,7 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                 }
             } else {
                 throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
@@ -855,11 +850,11 @@
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble("0"));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
             } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAdditionalAmount()));
-                feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
             } else if ("3003".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
                 feePrice = new BigDecimal(0);
@@ -878,7 +873,7 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("6006".equals(computingFormula)) {
                 feePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAmount()));
@@ -895,13 +890,13 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                 }
             } else {
                 throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
             }
         }
-        return feePrice.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        return feePrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
     }
 
     @Override
@@ -914,6 +909,9 @@
         BigDecimal feePrice = new BigDecimal("0.0");
         BigDecimal feeTotalPrice = new BigDecimal(0.0);
         Map<String, Object> feeAmount = new HashMap<>();
+        if (Environment.isOwnerPhone(java110Properties)) {
+            return getOwnerPhoneFee(feeAmount);
+        }
         if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
             String computingFormula = feeDto.getComputingFormula();
             if (roomDto == null) {
@@ -931,41 +929,41 @@
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(roomDto.getBuiltUpArea()));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("3003".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(roomDto.getRoomArea()));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("1101".equals(computingFormula)) { // 绉熼噾
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(roomDto.getRoomRent()));
-                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("4004".equals(computingFormula)) {  //鍔ㄦ�佽垂鐢�
                 feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("5005".equals(computingFormula)) {  //(鏈湡搴︽暟-涓婃湡搴︽暟)*鍗曚环+闄勫姞璐�
                 if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
@@ -978,11 +976,11 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
 
                     if (!StringUtil.isEmpty(feeDto.getCycle())) {
                         BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                     }
                 }
             } else if ("6006".equals(computingFormula)) {
@@ -990,20 +988,20 @@
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
                 feePrice = computeRoomCustomizeFormula(feeDto, roomDto);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = feePrice.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = feePrice.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("8008".equals(computingFormula)) {  //鎵嬪姩鍔ㄦ�佽垂鐢�
                 feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("9009".equals(computingFormula)) {  //(鏈湡搴︽暟-涓婃湡搴︽暟)*鍔ㄦ�佸崟浠�+闄勫姞璐�
                 if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
@@ -1016,10 +1014,10 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                     if (!StringUtil.isEmpty(feeDto.getCycle())) {
                         BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                     }
                 }
             } else {
@@ -1045,41 +1043,41 @@
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(parkingSpaceDtos.get(0).getArea()));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("3003".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(roomDto.getRoomArea()));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("1101".equals(computingFormula)) { // 绉熼噾
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(roomDto.getRoomRent()));
-                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("4004".equals(computingFormula)) {
                 feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("5005".equals(computingFormula)) {
                 if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
@@ -1092,10 +1090,10 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                     if (!StringUtil.isEmpty(feeDto.getCycle())) {
                         BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                     }
                 }
             } else if ("6006".equals(computingFormula)) {
@@ -1103,13 +1101,13 @@
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
                 feePrice = computeCarCustomizeFormula(feeDto, ownerCarDtos.get(0));
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = feePrice.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = feePrice.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("9009".equals(computingFormula)) {  //(鏈湡搴︽暟-涓婃湡搴︽暟)*鍔ㄦ�佸崟浠�+闄勫姞璐�
                 if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
@@ -1122,10 +1120,10 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                     if (!StringUtil.isEmpty(feeDto.getCycle())) {
                         BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                     }
                 }
             } else {
@@ -1149,43 +1147,43 @@
                 }
                 feeDto.setBuiltUpArea(builtUpArea.doubleValue() + "");
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("2002".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 //feePrice = Double.parseDouble(feeDto.getAdditionalAmount());
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
 //                BigDecimal roomDount = new BigDecimal(contractRoomDtos.size());
 //                additionalAmount = additionalAmount.multiply(roomDount);
-                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("3003".equals(computingFormula)) { // 鍥哄畾璐圭敤
                 BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
                 BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(roomDto.getRoomArea()));
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("1101".equals(computingFormula)) { // 绉熼噾
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(roomDto.getRoomRent()));
-                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_EVEN);
+                feePrice = additionalAmount.setScale(3, BigDecimal.ROUND_HALF_UP);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = additionalAmount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("4004".equals(computingFormula)) {  //鍔ㄦ�佽垂鐢�
                 feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("5005".equals(computingFormula)) {  //(鏈湡搴︽暟-涓婃湡搴︽暟)*鍗曚环+闄勫姞璐�
                 if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
@@ -1198,10 +1196,10 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                     if (!StringUtil.isEmpty(feeDto.getCycle())) {
                         BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                        feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                     }
                 }
             } else if ("6006".equals(computingFormula)) {
@@ -1209,20 +1207,20 @@
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("7007".equals(computingFormula)) { //鑷畾涔夊叕寮�
                 feePrice = computeContractCustomizeFormula(feeDto, contractRoomDtos);
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                    feeTotalPrice = feePrice.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = feePrice.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("8008".equals(computingFormula)) {  //鎵嬪姩鍔ㄦ�佽垂鐢�
                 feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
                     BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
                     BigDecimal amount = new BigDecimal(feeDto.getAmount());
-                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                    feeTotalPrice = amount.multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("9009".equals(computingFormula)) {  //(鏈湡搴︽暟-涓婃湡搴︽暟)*鍔ㄦ�佸崟浠�+闄勫姞璐�
                 if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
@@ -1235,17 +1233,18 @@
                     BigDecimal sub = curDegree.subtract(preDegree);
                     feePrice = sub.multiply(squarePrice)
                             .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                            .setScale(2, BigDecimal.ROUND_HALF_UP);
                     if (!StringUtil.isEmpty(feeDto.getCycle())) {
                         BigDecimal cycle1 = new BigDecimal(feeDto.getCycle());
-                        feeTotalPrice = sub.multiply(squarePrice).add(additionalAmount).multiply(cycle1).setScale(3, BigDecimal.ROUND_DOWN);
+                        feeTotalPrice = sub.multiply(squarePrice).add(additionalAmount).multiply(cycle1).setScale(3, BigDecimal.ROUND_HALF_UP);
                     }
                 }
             } else {
                 throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
             }
         }
-        feePrice.setScale(3, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+
+        feePrice.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
         feeAmount.put("feePrice", feePrice);
         feeAmount.put("feeTotalPrice", feeTotalPrice);
         return feeAmount;
@@ -1535,6 +1534,30 @@
         return resMonth;
     }
 
+
+    //鎵嬫満绔即璐瑰鐞�
+    public Map getOwnerPhoneFee(Map feeAmount) {
+        feeAmount.put("feePrice", new BigDecimal(1.00 / 100));
+        feeAmount.put("feeTotalPrice", new BigDecimal(1.00 / 100));
+        return feeAmount;
+    }
+
+
+    /**
+     * 銆�銆� *瀛楃涓茬殑鏃ユ湡鏍煎紡鐨勮绠�
+     */
+    public long daysBetween(Date smdate, Date bdate) {
+        long between_days = 0;
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(smdate);
+        long time1 = cal.getTimeInMillis();
+        cal.setTime(bdate);
+        long time2 = cal.getTimeInMillis();
+        between_days = (time2 - time1) / (1000 * 3600 * 24);
+
+        return between_days;
+    }
+
     @Override
     public Date getTargetEndTime(double month, Date startDate) {
         Calendar endDate = Calendar.getInstance();
@@ -1554,52 +1577,39 @@
 
 
     @Override
-    public void computeTempCarStopTimeAndFee(List<CarInoutDto> carInoutDtos) {
+    public List<CarInoutDto> computeTempCarStopTimeAndFee(List<CarInoutDto> carInoutDtos) {
 
         if (carInoutDtos == null || carInoutDtos.size() < 1) {
-            return;
+            return null;
         }
 
-//璁$畻鍋滆溅鏃堕棿
-        TempCarFeeConfigDto tempCarFeeConfigDto = new TempCarFeeConfigDto();
-        tempCarFeeConfigDto.setPaId(carInoutDtos.get(0).getPaId());
-        tempCarFeeConfigDto.setCommunityId(carInoutDtos.get(0).getCommunityId());
-        List<TempCarFeeConfigDto> tempCarFeeConfigDtos = tempCarFeeConfigInnerServiceSMOImpl.queryTempCarFeeConfigs(tempCarFeeConfigDto);
 
-        if (tempCarFeeConfigDtos == null || tempCarFeeConfigDtos.size() < 1) {
-            return;
-        }
-        TempCarFeeConfigAttrDto tempCarFeeConfigAttrDto = new TempCarFeeConfigAttrDto();
-        tempCarFeeConfigAttrDto.setConfigId(tempCarFeeConfigDto.getConfigId());
-        tempCarFeeConfigAttrDto.setCommunityId(tempCarFeeConfigDto.getCommunityId());
+        carInoutDtos = tempCarFeeConfigInnerServiceSMOImpl.computeTempCarFee(carInoutDtos);
 
-        List<TempCarFeeConfigAttrDto> tempCarFeeConfigAttrDtos = tempCarFeeConfigAttrInnerServiceSMOImpl.queryTempCarFeeConfigAttrs(tempCarFeeConfigAttrDto);
-        long time = 0;
-        for (CarInoutDto carInoutDto : carInoutDtos) {
-            try {
-                IComputeTempCarFee computeTempCarFee = ApplicationContextFactory.getBean(tempCarFeeConfigDtos.get(0).getRuleId(), IComputeTempCarFee.class);
-                TempCarFeeResult result = computeTempCarFee.computeTempCarFee(carInoutDtos.get(0), tempCarFeeConfigDtos.get(0),tempCarFeeConfigAttrDtos);
-                carInoutDto.setMin(result.getMin());
-                carInoutDto.setHours(result.getHours());
-                carInoutDto.setPayCharge(result.getPayCharge()+"");
-            } catch (Exception e) {
-                logger.error("涓存椂杞︾畻璐瑰け璐�", e);
-            }
+        return carInoutDtos;
+
+    }
+
+    @Override
+    public List<CarInoutDetailDto> computeTempCarInoutDetailStopTimeAndFee(List<CarInoutDetailDto> carInoutDtos) {
+        if (carInoutDtos == null || carInoutDtos.size() < 1) {
+            return null;
         }
+
+
+        carInoutDtos = tempCarFeeConfigInnerServiceSMOImpl.computeTempCarInoutDetailFee(carInoutDtos);
+
+        return carInoutDtos;
     }
 
 
     public static void main(String[] args) {
-        ComputeFeeSMOImpl computeFeeSMO = new ComputeFeeSMOImpl();
-        try {
-            double month = computeFeeSMO.dayCompare(
-                    DateUtil.getDateFromString("2021-6-1 00:00:00", DateUtil.DATE_FORMATE_STRING_A),
-                    DateUtil.getDateFromString("2021-8-5 18:00:00", DateUtil.DATE_FORMATE_STRING_A)
-            );
-            System.out.println(month);
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
+        BigDecimal squarePrice = new BigDecimal(Double.parseDouble("4.50"));
+        BigDecimal builtUpArea = new BigDecimal(Double.parseDouble("52.69"));
+        BigDecimal additionalAmount = new BigDecimal(Double.parseDouble("0"));
+            BigDecimal cycle = new BigDecimal(Double.parseDouble("3"));
+        BigDecimal  feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(3, BigDecimal.ROUND_HALF_DOWN);
+        System.out.println(feeTotalPrice.doubleValue());
     }
 
 //    public static void main(String[] args) {

--
Gitblit v1.8.0