From ee0df7b41ebb6534a33d1ba95fab86ab102facee Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期五, 30 七月 2021 08:44:39 +0800
Subject: [PATCH] 优化费用问题

---
 service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java |   61 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java b/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java
index c7bebc4..4c405d8 100755
--- a/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java
+++ b/service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java
@@ -7,12 +7,12 @@
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.smo.IComputeFeeSMO;
 import com.java110.dto.RoomDto;
+import com.java110.dto.contract.ContractDto;
 import com.java110.dto.fee.FeeConfigDto;
 import com.java110.dto.fee.FeeDto;
 import com.java110.dto.machine.CarInoutDto;
 import com.java110.dto.owner.OwnerCarDto;
 import com.java110.dto.owner.OwnerDto;
-import com.java110.dto.parking.ParkingSpaceDto;
 import com.java110.intf.common.ICarInoutInnerServiceSMO;
 import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
 import com.java110.intf.community.IRoomInnerServiceSMO;
@@ -295,6 +295,10 @@
             endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
         }
         feeInfo.setEndTime(endCalender.getTime());
+        //鍒ゆ柇 缁撴潫鏃堕棿 鏄惁澶т簬 璐圭敤椤� 缁撴潫鏃堕棿锛岃繖閲� 瀹归敊涓�涓嬶紝濡傛灉 璐圭敤缁撴潫鏃堕棿澶т簬 璐圭敤椤圭粨鏉熸椂闂� 30澶� 璧版姤閿� 灞炰簬澶氱即璐�
+        if (feeInfo.getEndTime().getTime() - feeInfo.getConfigEndTime().getTime() > 30 * 24 * 60 * 60 * 1000) {
+            throw new IllegalArgumentException("缂磋垂瓒呰繃浜� 璐圭敤椤圭粨鏉熸椂闂�");
+        }
         Map feeMap = BeanConvertUtil.beanCovertMap(feeInfo);
         feeMap.put("startTime", DateUtil.getFormatTimeString(feeInfo.getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
         feeMap.put("endTime", DateUtil.getFormatTimeString(feeInfo.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
@@ -372,7 +376,7 @@
         if (feeDtos == null || feeDtos.size() != 1) {
             throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏌ヨ璐圭敤淇℃伅澶辫触锛屾湭鏌ュ埌鏁版嵁鎴栨煡鍒板鏉℃暟鎹�");
         }
-        feeDto = feeDtos.get(0);
+
         paramInJson.put("feeInfo", feeDto);
         businessFeeDetail.put("startTime", DateUtil.getFormatTimeString(feeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
         Date endTime = feeDto.getEndTime();
@@ -386,9 +390,9 @@
         } else {
             endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
             if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
-                if(feeDto.getDeadlineTime() != null){
+                if (feeDto.getDeadlineTime() != null) {
                     endCalender.setTime(feeDto.getDeadlineTime());
-                }else if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
+                } else if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
                     endCalender.setTime(feeDto.getCurReadingTime());
                 } else if (feeDto.getImportFeeEndTime() == null) {
                     endCalender.setTime(feeDto.getConfigEndTime());
@@ -436,11 +440,20 @@
         endCalender.setTime(endTime);
         endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
         feeInfo.setEndTime(endCalender.getTime());
+        //鍒ゆ柇 缁撴潫鏃堕棿 鏄惁澶т簬 璐圭敤椤� 缁撴潫鏃堕棿锛岃繖閲� 瀹归敊涓�涓嬶紝濡傛灉 璐圭敤缁撴潫鏃堕棿澶т簬 璐圭敤椤圭粨鏉熸椂闂� 30澶� 璧版姤閿� 灞炰簬澶氱即璐�
+        if (feeInfo.getEndTime().getTime() - feeInfo.getConfigEndTime().getTime() > 30 * 24 * 60 * 60 * 1000) {
+            throw new IllegalArgumentException("缂磋垂瓒呰繃浜� 璐圭敤椤圭粨鏉熸椂闂�");
+        }
         Map feeMap = BeanConvertUtil.beanCovertMap(feeInfo);
         feeMap.put("startTime", DateUtil.getFormatTimeString(feeInfo.getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
         feeMap.put("endTime", DateUtil.getFormatTimeString(feeInfo.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
         businessFee.putAll(feeMap);
         business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessFee);
+
+        //涓哄仠杞﹁垂鍗曠嫭澶勭悊
+        paramInJson.put("carFeeEndTime", feeInfo.getEndTime());
+        paramInJson.put("carPayerObjType", feeInfo.getPayerObjType());
+        paramInJson.put("carPayerObjId", feeInfo.getPayerObjId());
         return business;
     }
 
@@ -668,6 +681,9 @@
         businessUnit.put("feeTypeCd", paramInJson.getString("feeTypeCd"));
         businessUnit.put("incomeObjId", paramInJson.getString("storeId"));
         businessUnit.put("amount", "-1.00");
+        if (paramInJson.containsKey("amount") && !StringUtil.isEmpty(paramInJson.getString("amount"))) {
+            businessUnit.put("amount", paramInJson.getString("amount"));
+        }
         businessUnit.put("startTime", time);
         businessUnit.put("endTime", time);
         businessUnit.put("communityId", paramInJson.getString("communityId"));
@@ -682,6 +698,43 @@
     }
 
     /**
+     * 娣诲姞鐗╀笟璐圭敤
+     *
+     * @param paramInJson     鎺ュ彛璋冪敤鏀句紶鍏ュ叆鍙�
+     * @param dataFlowContext 鏁版嵁涓婁笅鏂�
+     * @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
+     */
+    public JSONObject addContractFee(ContractDto contractDto, JSONObject paramInJson, DataFlowContext dataFlowContext) {
+        String time = DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A);
+        if (paramInJson.containsKey("feeEndDate")) {
+            time = paramInJson.getString("feeEndDate");
+        } else if (paramInJson.containsKey("startTime")) {
+            time = paramInJson.getString("startTime");
+        }
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_INFO);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONObject businessUnit = new JSONObject();
+        businessUnit.put("feeId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_feeId));
+        businessUnit.put("configId", paramInJson.getString("configId"));
+        businessUnit.put("feeTypeCd", paramInJson.getString("feeTypeCd"));
+        businessUnit.put("incomeObjId", paramInJson.getString("storeId"));
+        businessUnit.put("amount", "-1.00");
+        businessUnit.put("startTime", time);
+        businessUnit.put("endTime", time);
+        businessUnit.put("communityId", paramInJson.getString("communityId"));
+        businessUnit.put("payerObjId", contractDto.getContractId());
+        businessUnit.put("payerObjType", FeeDto.PAYER_OBJ_TYPE_CONTRACT);
+        businessUnit.put("feeFlag", paramInJson.getString("feeFlag"));
+        businessUnit.put("state", "2008001");
+        businessUnit.put("userId", dataFlowContext.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessUnit);
+        paramInJson.put("feeId", businessUnit.getString("feeId"));
+        return business;
+    }
+
+    /**
      * 娣诲姞璐圭敤椤逛俊鎭�
      *
      * @param paramInJson     鎺ュ彛璋冪敤鏀句紶鍏ュ叆鍙�

--
Gitblit v1.8.0