From 3d8ec5c23ef49d0908195c8b5b892920a46aaa8c Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 30 五月 2023 11:42:48 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

---
 service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java |   81 ++++++++++++++++++++++++----------------
 1 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java b/service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java
index 3ca022f..faa9659 100644
--- a/service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java
+++ b/service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java
@@ -10,9 +10,7 @@
 import com.java110.intf.community.IRoomInnerServiceSMO;
 import com.java110.intf.fee.IPayFeeDetailMonthInnerServiceSMO;
 import com.java110.po.payFeeDetailMonth.PayFeeDetailMonthPo;
-import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.DateUtil;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -54,16 +52,16 @@
 
         Double feePrice = Double.parseDouble(feePriceAll.get("feePrice").toString());
         //todo 濡傛灉鏄竴娆℃�ц垂鐢� 闄や互
-        if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getPayerObjType())) {
-            return feePrice;
-        }
-        double maxMonth = Math.ceil(computeFeeSMOImpl.dayCompare(feeDto.getStartTime(), feeDto.getEndTime()));
-        if (maxMonth <= 0) {
-            return feePrice;
-
-        }
-        BigDecimal feePriceDec = new BigDecimal(feePrice).divide(new BigDecimal(maxMonth), 2, BigDecimal.ROUND_HALF_UP);
-        feePrice = feePriceDec.doubleValue();
+//        if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getPayerObjType())) {
+//            return feePrice;
+//        }
+//        double maxMonth = Math.ceil(computeFeeSMOImpl.dayCompare(feeDto.getStartTime(), feeDto.getEndTime()));
+//        if (maxMonth <= 0) {
+//            return feePrice;
+//
+//        }
+//        BigDecimal feePriceDec = new BigDecimal(feePrice).divide(new BigDecimal(maxMonth), 2, BigDecimal.ROUND_HALF_UP);
+//        feePrice = feePriceDec.doubleValue();
         return feePrice;
     }
 
@@ -87,7 +85,7 @@
      * @param feeDto
      * @param payFeeMonthOwnerDto
      */
-    @Autowired
+    @Override
     public void waitDispersedFeeDetail(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto) {
         PayFeeDetailMonthDto payFeeDetailMonthDto = new PayFeeDetailMonthDto();
         payFeeDetailMonthDto.setCommunityId(feeDto.getCommunityId());
@@ -113,7 +111,7 @@
      * @param feePrice
      * @param deadlineTime
      */
-    @Autowired
+    @Override
     public void waitDispersedOweFee(FeeDto feeDto, PayFeeMonthOwnerDto payFeeMonthOwnerDto, Double feePrice, Date deadlineTime) {
         // todo 璐圭敤宸茬粡缁撴潫
         if (FeeDto.STATE_FINISH.equals(feeDto.getState())) {
@@ -134,6 +132,17 @@
 
         BigDecimal receivableAmount = new BigDecimal(feePrice);
 
+        BigDecimal dayReceivableAmount = null;
+
+        //todo 涓�娆℃�ц垂鐢� 鏃ュ簲鏀惰绠�
+        if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
+            int day = DateUtil.daysBetween(endTime, startTime);
+            if (day < 1) {
+                day = 1;
+            }
+            dayReceivableAmount = receivableAmount.divide(new BigDecimal(day), 4, BigDecimal.ROUND_HALF_UP);// 鏃� 搴旀敹
+        }
+
         // todo 瀵绘壘绗竴涓嚜鐒舵湀 涓�鏃�
         Calendar firstMonthDayCal = Calendar.getInstance();
         firstMonthDayCal.setTime(startTime);
@@ -146,20 +155,23 @@
         int curDay = 0;
         int curMonthMaxDay = 30;
         BigDecimal curMonthReceivableAmount = null;
-        BigDecimal dayReceivableAmount = null;
+
         while (firstMonthDayTime.getTime() < endTime.getTime()) {
             curDay = DateUtil.daysBetween(firstMonthDayTime, startMonthDayTime);
 
-            // todo 璁$畻褰撴湀澶╂暟
-            Calendar calendar = Calendar.getInstance();
-            calendar.setTime(startMonthDayTime);
-            curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
-            dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 4, BigDecimal.ROUND_HALF_UP);// 鏃� 瀹炴敹
+            //todo 鍛ㄦ湡鎬ц垂鐢� 鏃ュ簲鏀堕噸鏂扮畻
+            if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
+                // todo 璁$畻褰撴湀澶╂暟
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(startMonthDayTime);
+                curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+                dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 4, BigDecimal.ROUND_HALF_UP);// 鏃� 瀹炴敹
+            }
             // todo 璁$畻 搴旀敹
             curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP);
 
             // todo 淇濆瓨鏁版嵁鍒皃ay_fee_detail_month
-            toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
+            toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime,deadlineTime);
 
             // todo 灏唖tartTime 淇敼涓� 涓嬫湀1鏃ユ椂闂�
             startMonthDayTime = firstMonthDayTime;
@@ -174,17 +186,19 @@
         }
 
         curDay = DateUtil.daysBetween(endTime, startMonthDayTime);
-
-        // todo 璁$畻褰撴湀澶╂暟
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(startMonthDayTime);
-        curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
-        dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 4, BigDecimal.ROUND_HALF_UP);// 鏃� 瀹炴敹
+        //todo 鍛ㄦ湡鎬ц垂鐢� 鏃ュ簲鏀堕噸鏂扮畻
+        if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
+            // todo 璁$畻褰撴湀澶╂暟
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(startMonthDayTime);
+            curMonthMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+            dayReceivableAmount = receivableAmount.divide(new BigDecimal(curMonthMaxDay), 4, BigDecimal.ROUND_HALF_UP);// 鏃� 瀹炴敹
+        }
         // todo 璁$畻 搴旀敹
         curMonthReceivableAmount = new BigDecimal(curDay).multiply(dayReceivableAmount).setScale(4, BigDecimal.ROUND_HALF_UP);
 
         // todo 淇濆瓨鏁版嵁鍒皃ay_fee_detail_month
-        toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
+        toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), 0, null, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime,deadlineTime);
         payFeeDetailMonthInnerServiceSMOImpl.savePayFeeDetailMonths(payFeeDetailMonthPos);
 
     }
@@ -227,7 +241,7 @@
             curMonthReceivedAmount = new BigDecimal(curDay).multiply(dayReceivedAmount).setScale(4, BigDecimal.ROUND_HALF_UP);
 
             // todo 淇濆瓨鏁版嵁鍒皃ay_fee_detail_month
-            toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
+            toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime,endTime);
 
             // todo 灏唖tartTime 淇敼涓� 涓嬫湀1鏃ユ椂闂�
             startMonthDayTime = firstMonthDayTime;
@@ -248,7 +262,7 @@
         curMonthReceivedAmount = new BigDecimal(curDay).multiply(dayReceivedAmount).setScale(4, BigDecimal.ROUND_HALF_UP);
 
         // todo 淇濆瓨鏁版嵁鍒皃ay_fee_detail_month
-        toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime);
+        toSavePayFeeDetailMonth(curMonthReceivableAmount.doubleValue(), curMonthReceivedAmount.doubleValue(), feeDetailDto, feeDto, payFeeMonthOwnerDto, payFeeDetailMonthPos, startMonthDayTime,endTime);
         payFeeDetailMonthInnerServiceSMOImpl.savePayFeeDetailMonths(payFeeDetailMonthPos);
 
     }
@@ -267,7 +281,8 @@
                                          FeeDto feeDto,
                                          PayFeeMonthOwnerDto payFeeMonthOwnerDto,
                                          List<PayFeeDetailMonthPo> payFeeDetailMonthPos,
-                                         Date curTime) {
+                                         Date curTime,
+                                         Date deadlineTime) {
 
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(curTime);
@@ -288,7 +303,7 @@
                 getDiscountAmount(Double.parseDouble(tmpPayFeeDetailMonthPo.getReceivableAmount()),
                         Double.parseDouble(tmpPayFeeDetailMonthPo.getReceivedAmount()),
                         calendar.getTime(), feeDto) + "");
-        tmpPayFeeDetailMonthPo.setMonthId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_monthId));
+        tmpPayFeeDetailMonthPo.setMonthId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_monthId,true));
         tmpPayFeeDetailMonthPo.setRemark("绋嬪簭璁$畻鐢熸垚");
         tmpPayFeeDetailMonthPo.setObjName(payFeeMonthOwnerDto.getObjName());
         tmpPayFeeDetailMonthPo.setObjId(payFeeMonthOwnerDto.getObjId());
@@ -296,6 +311,7 @@
         tmpPayFeeDetailMonthPo.setOwnerName(payFeeMonthOwnerDto.getOwnerName());
         tmpPayFeeDetailMonthPo.setLink(payFeeMonthOwnerDto.getLink());
         tmpPayFeeDetailMonthPo.setCurMonthTime(DateUtil.getFormatTimeStringB(calendar.getTime()));
+        tmpPayFeeDetailMonthPo.setDeadlineTime(DateUtil.getFormatTimeStringA(deadlineTime));
         if (feeDetailDto == null) {
             tmpPayFeeDetailMonthPo.setPayFeeTime(null);
         } else { // todo 浜よ垂璁板綍 淇濆瓨鏃�
@@ -307,7 +323,6 @@
         payFeeDetailMonthPos.add(tmpPayFeeDetailMonthPo);
 
     }
-
 
 
 }

--
Gitblit v1.8.0