From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能

---
 service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java |  230 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 118 insertions(+), 112 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
old mode 100644
new mode 100755
index abd6e1f..e8a1962
--- 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,18 +7,19 @@
 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.parking.ParkingSpaceDto;
+import com.java110.dto.owner.OwnerDto;
 import com.java110.intf.common.ICarInoutInnerServiceSMO;
 import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
 import com.java110.intf.community.IRoomInnerServiceSMO;
 import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
 import com.java110.intf.fee.IFeeInnerServiceSMO;
-import com.java110.intf.user.IOwnerCarInnerServiceSMO;
 import com.java110.po.car.CarInoutPo;
+import com.java110.po.fee.FeeAttrPo;
 import com.java110.po.fee.PayFeeConfigPo;
 import com.java110.po.fee.PayFeeDetailPo;
 import com.java110.po.fee.PayFeePo;
@@ -161,7 +162,7 @@
         if (feeDtos == null || feeDtos.size() != 1) {
             throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏌ヨ璐圭敤淇℃伅澶辫触锛屾湭鏌ュ埌鏁版嵁鎴栨煡鍒板鏉℃暟鎹�");
         }
-        if (!businessFeeDetail.containsKey("state")) {
+        if (!businessFeeDetail.containsKey("state") || StringUtil.isEmpty(businessFeeDetail.getString("state"))) {
             businessFeeDetail.put("state", "1400");
         }
         feeDto = feeDtos.get(0);
@@ -169,7 +170,8 @@
         int hours = 0;
         Date targetEndTime = null;
         BigDecimal cycles = null;
-        BigDecimal feePrice = new BigDecimal(computeFeeSMOImpl.getFeePrice(feeDto));
+        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
+        BigDecimal feePrice = new BigDecimal(feePriceAll.get("feePrice").toString());
         if ("-101".equals(paramInJson.getString("cycles"))) {
             Date endTime = feeDto.getEndTime();
             Calendar endCalender = Calendar.getInstance();
@@ -191,22 +193,7 @@
         paramInJson.put("feeInfo", feeDto);
         business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeeDetailPo.class.getSimpleName(), businessFeeDetail);
         paramInJson.put("detailId", businessFeeDetail.getString("detailId"));
-        feeReceiptDetailPo.setAmount(businessFeeDetail.getString("receivedAmount"));
-        feeReceiptDetailPo.setCommunityId(feeDto.getCommunityId());
-        feeReceiptDetailPo.setCycle(businessFeeDetail.getString("cycles"));
-        feeReceiptDetailPo.setDetailId(businessFeeDetail.getString("detailId"));
-        feeReceiptDetailPo.setEndTime(businessFeeDetail.getString("endTime"));
-        feeReceiptDetailPo.setFeeId(feeDto.getFeeId());
-        feeReceiptDetailPo.setFeeName(StringUtil.isEmpty(feeDto.getImportFeeName()) ? feeDto.getFeeName() : feeDto.getImportFeeName());
-        feeReceiptDetailPo.setStartTime(businessFeeDetail.getString("startTime"));
-        feeReceiptDetailPo.setReceiptId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_receiptId));
-        computeFeeSMOImpl.freshFeeReceiptDetail(feeDto, feeReceiptDetailPo);
-        feeReceiptPo.setAmount(feeReceiptDetailPo.getAmount());
-        feeReceiptPo.setCommunityId(feeReceiptDetailPo.getCommunityId());
-        feeReceiptPo.setReceiptId(feeReceiptDetailPo.getReceiptId());
-        feeReceiptPo.setObjType(feeDto.getPayerObjType());
-        feeReceiptPo.setObjId(feeDto.getPayerObjId());
-        feeReceiptPo.setObjName(computeFeeSMOImpl.getFeeObjName(feeDto));
+
         return business;
     }
 
@@ -236,13 +223,14 @@
         if (feeDtos == null || feeDtos.size() != 1) {
             throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏌ヨ璐圭敤淇℃伅澶辫触锛屾湭鏌ュ埌鏁版嵁鎴栨煡鍒板鏉℃暟鎹�");
         }
-        if (!businessFeeDetail.containsKey("state")) {
+        if (!businessFeeDetail.containsKey("state") || StringUtil.isEmpty(businessFeeDetail.getString("state"))) {
             businessFeeDetail.put("state", "1400");
         }
         feeDto = feeDtos.get(0);
         businessFeeDetail.put("startTime", paramInJson.getString("startTime"));
         BigDecimal cycles = null;
-        BigDecimal feePrice = new BigDecimal(computeFeeSMOImpl.getFeePrice(feeDto));
+        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
+        BigDecimal feePrice = new BigDecimal(feePriceAll.get("feePrice").toString());
         Date endTime = feeDto.getEndTime();
         Calendar endCalender = Calendar.getInstance();
         endCalender.setTime(endTime);
@@ -269,6 +257,9 @@
         feeReceiptDetailPo.setReceiptId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_receiptId));
 
         computeFeeSMOImpl.freshFeeReceiptDetail(feeDto, feeReceiptDetailPo);
+        //鏌ヨ涓氫富淇℃伅
+        OwnerDto ownerDto = computeFeeSMOImpl.getFeeOwnerDto(feeDto);
+
         feeReceiptDetailPos.add(feeReceiptDetailPo);
         feeReceiptPo.setAmount(feeReceiptDetailPo.getAmount());
         feeReceiptPo.setCommunityId(feeReceiptDetailPo.getCommunityId());
@@ -276,6 +267,8 @@
         feeReceiptPo.setObjType(feeDto.getPayerObjType());
         feeReceiptPo.setObjId(feeDto.getPayerObjId());
         feeReceiptPo.setObjName(computeFeeSMOImpl.getFeeObjName(feeDto));
+        feeReceiptPo.setPayObjId(ownerDto.getOwnerId());
+        feeReceiptPo.setPayObjName(ownerDto.getName());
         feeReceiptPos.add(feeReceiptPo);
         return business;
     }
@@ -304,6 +297,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 * 1000L) {
+            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));
@@ -340,10 +337,13 @@
         if (FeeDto.FEE_FLAG_ONCE.equals(feeInfo.getFeeFlag())) { //缂磋垂缁撴潫
             feeMap.put("state", FeeDto.STATE_FINISH);
         }
+        Date maxEndTime = feeInfo.getConfigEndTime();
+        if(!FeeDto.FEE_FLAG_CYCLE.equals(feeInfo.getFeeFlag())){
+            maxEndTime = feeInfo.getDeadlineTime();
+        }
         try {
             Date endTime = DateUtil.getDateFromString(paramInJson.getString("endTime"), DateUtil.DATE_FORMATE_STRING_A);
-            Date configEndTime = feeInfo.getConfigEndTime();
-            if (endTime.getTime() >= configEndTime.getTime()) {
+            if (endTime.getTime() >= maxEndTime.getTime()) {
                 feeMap.put("state", FeeDto.STATE_FINISH);
             }
         } catch (ParseException e) {
@@ -395,7 +395,9 @@
         } else {
             endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
             if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
-                if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
+                if (feeDto.getDeadlineTime() != null) {
+                    endCalender.setTime(feeDto.getDeadlineTime());
+                } else if (!StringUtil.isEmpty(feeDto.getCurDegrees())) {
                     endCalender.setTime(feeDto.getCurReadingTime());
                 } else if (feeDto.getImportFeeEndTime() == null) {
                     endCalender.setTime(feeDto.getConfigEndTime());
@@ -406,90 +408,11 @@
         }
         businessFeeDetail.put("endTime", DateUtil.getFormatTimeString(endCalender.getTime(), DateUtil.DATE_FORMATE_STRING_A));
 
-        BigDecimal feePrice = new BigDecimal("0.00");
+        double feePrice = 0.0;
 
-        if ("3333".equals(feeDto.getPayerObjType())) { //鎴垮眿鐩稿叧
-            String computingFormula = feeDto.getComputingFormula();
-            if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
-                RoomDto roomDto = new RoomDto();
-                roomDto.setRoomId(feeDto.getPayerObjId());
-                roomDto.setCommunityId(feeDto.getCommunityId());
-                List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
-                if (roomDtos == null || roomDtos.size() != 1) {
-                    throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏈煡鍒版埧灞嬩俊鎭紝鏌ヨ澶氭潯鏁版嵁");
-                }
-                roomDto = roomDtos.get(0);
-                //feePrice = Double.parseDouble(feeDto.getSquarePrice()) * Double.parseDouble(roomDtos.get(0).getBuiltUpArea()) + Double.parseDouble(feeDto.getAdditionalAmount());
-                BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
-                BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(roomDtos.get(0).getBuiltUpArea()));
-                BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN);
-            } 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);
-            } else if ("4004".equals(computingFormula)) {
-                feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
-            } else if ("5005".equals(computingFormula)) {
-                if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
-                    //throw new IllegalArgumentException("鎶勮〃鏁版嵁寮傚父");
-                } else {
-                    BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
-                    BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
-                    BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                    BigDecimal sub = curDegree.subtract(preDegree);
-                    feePrice = sub.multiply(squarePrice)
-                            .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
-                }
-            } else if ("6006".equals(computingFormula)) {
-                feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
-            } else {
-                throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
-            }
-        } else if ("6666".equals(feeDto.getPayerObjType())) {//杞︿綅鐩稿叧
-            String computingFormula = feeDto.getComputingFormula();
-            if ("1001".equals(computingFormula)) { //闈㈢Н*鍗曚环+闄勫姞璐�
-                ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
-                parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
-                parkingSpaceDto.setPsId(feeDto.getPayerObjId());
-                List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
 
-                if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //鏁版嵁鏈夐棶棰�
-                    throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鏈煡鍒板仠杞︿綅淇℃伅锛屾煡璇㈠鏉℃暟鎹�");
-                }
-                //feePrice = Double.parseDouble(feeDto.getSquarePrice()) * Double.parseDouble(parkingSpaceDtos.get(0).getArea()) + Double.parseDouble(feeDto.getAdditionalAmount());
-                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);
-            } 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);
-            } else if ("5005".equals(computingFormula)) {
-                if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
-                    throw new IllegalArgumentException("鎶勮〃鏁版嵁寮傚父");
-                } else {
-                    BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
-                    BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
-                    BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
-                    BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-                    BigDecimal sub = curDegree.subtract(preDegree);
-                    feePrice = sub.multiply(squarePrice)
-                            .add(additionalAmount)
-                            .setScale(2, BigDecimal.ROUND_HALF_EVEN);
-                }
-            } else if ("6006".equals(computingFormula)) {
-                feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
-            } else if ("4004".equals(computingFormula)) {
-                feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
-            } else {
-                throw new IllegalArgumentException("鏆備笉鏀寔璇ョ被鍏紡");
-            }
-        }
-        BigDecimal receivableAmount = feePrice;
+        BigDecimal receivableAmount = new BigDecimal(feePriceAll.get("feePrice").toString());
         BigDecimal cycles = new BigDecimal(Double.parseDouble(paramInJson.getString("cycles")));
         double tmpReceivableAmount = cycles.multiply(receivableAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
         double discountPrice = paramInJson.getDouble("discountPrice");
@@ -522,13 +445,23 @@
         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 * 1000L) {
+            throw new IllegalArgumentException("缂磋垂瓒呰繃浜� 璐圭敤椤圭粨鏉熸椂闂�" + JSONObject.toJSONString(feeInfo) + "|||" + paramInJson.getString("cycles"));
+        }
         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;
     }
+
 
     public JSONObject modifyTempCarInout(JSONObject reqJson, DataFlowContext context) {
         FeeDto feeDto = (FeeDto) reqJson.get("feeInfo");
@@ -675,7 +608,7 @@
         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", "-1");
+        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"));
@@ -687,9 +620,29 @@
         businessUnit.put("payerObjType", FeeDto.PAYER_OBJ_TYPE_CAR);
         businessUnit.put("feeFlag", paramInJson.getString("feeFlag"));
         businessUnit.put("state", "2008001");
+        businessUnit.put("batchId", paramInJson.getString("batchId"));
         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;
+    }
+
+    @Override
+    public JSONObject addFeeAttr(JSONObject paramInJson, DataFlowContext dataFlowContext, String specCd, String value) {
+
+        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);
+        FeeAttrPo feeAttrPo = new FeeAttrPo();
+        feeAttrPo.setCommunityId(paramInJson.getString("communityId"));
+        feeAttrPo.setSpecCd(specCd);
+        feeAttrPo.setValue(value);
+        feeAttrPo.setFeeId(paramInJson.getString("feeId"));
+        feeAttrPo.setAttrId("-1");
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(FeeAttrPo.class.getSimpleName(), JSONObject.parseObject(JSONObject.toJSONString(feeAttrPo)));
+        return business;
+
     }
 
     /**
@@ -718,7 +671,55 @@
      * @param dataFlowContext 鏁版嵁涓婁笅鏂�
      * @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
      */
-    public JSONObject addRoomFee(RoomDto roomDto, JSONObject paramInJson, DataFlowContext dataFlowContext) {
+    public JSONObject addRoomFee(RoomDto roomDto, JSONObject paramInJson, DataFlowContext dataFlowContext) throws ParseException {
+        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");
+        }
+        //鑾峰彇璐圭敤鏍囪瘑
+        String feeFlag = paramInJson.getString("feeFlag");
+        //鏌ヨ璐圭敤椤�
+        FeeConfigDto feeConfigDto = new FeeConfigDto();
+        feeConfigDto.setConfigId(paramInJson.getString("configId"));
+        List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
+        Assert.listOnlyOne(feeConfigDtos, "鏌ヨ璐圭敤椤归敊璇紒");
+        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");
+        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"));
+        businessUnit.put("payerObjId", roomDto.getRoomId());
+        businessUnit.put("payerObjType", "3333");
+        businessUnit.put("feeFlag", paramInJson.getString("feeFlag"));
+        businessUnit.put("state", "2008001");
+        businessUnit.put("batchId", paramInJson.getString("batchId"));
+        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     鎺ュ彛璋冪敤鏀句紶鍏ュ叆鍙�
+     * @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");
@@ -730,20 +731,25 @@
         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", "-1");
+        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");
+        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"));
-        businessUnit.put("payerObjId", roomDto.getRoomId());
-        businessUnit.put("payerObjType", "3333");
+        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("batchId", paramInJson.getString("batchId"));
         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;
     }
 

--
Gitblit v1.8.0