From b6184e2ddf3db37a94f7efb3b619bbc64642a292 Mon Sep 17 00:00:00 2001
From: chengf <cgf12138@163.com>
Date: 星期二, 27 一月 2026 18:12:48 +0800
Subject: [PATCH] Z四

---
 service-fee/src/main/java/com/java110/fee/cmd/feeConfig/UpdateFeeConfigCmd.java |   77 ++++++++++++++++++++++++++++++++++----
 1 files changed, 68 insertions(+), 9 deletions(-)

diff --git a/service-fee/src/main/java/com/java110/fee/cmd/feeConfig/UpdateFeeConfigCmd.java b/service-fee/src/main/java/com/java110/fee/cmd/feeConfig/UpdateFeeConfigCmd.java
index 4e72702..ba60e74 100644
--- a/service-fee/src/main/java/com/java110/fee/cmd/feeConfig/UpdateFeeConfigCmd.java
+++ b/service-fee/src/main/java/com/java110/fee/cmd/feeConfig/UpdateFeeConfigCmd.java
@@ -2,13 +2,16 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.dto.fee.FeeConfigDto;
-import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
-import com.java110.intf.fee.IPayFeeConfigV1InnerServiceSMO;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.payFee.PayFeeRuleDto;
+import com.java110.intf.fee.*;
 import com.java110.po.fee.PayFeeConfigPo;
+import com.java110.po.fee.PayFeePo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -26,9 +29,17 @@
     @Autowired
     private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
 
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMO;
+
+    @Autowired
+    private IPayFeeRuleV1InnerServiceSMO payFeeRuleV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IPayFeeV1InnerServiceSMO payFeeV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
-
         Assert.hasKeyAndValue(reqJson, "configId", "璐圭敤椤笽D涓嶈兘涓虹┖");
         Assert.hasKeyAndValue(reqJson, "feeTypeCd", "蹇呭~锛岃閫夋嫨璐圭敤绫诲瀷");
         Assert.hasKeyAndValue(reqJson, "feeName", "蹇呭~锛岃濉啓鏀惰垂椤圭洰");
@@ -40,29 +51,77 @@
         Assert.hasKeyAndValue(reqJson, "additionalAmount", "蹇呭~锛岃濉啓闄勫姞璐圭敤");
         Assert.hasKeyAndValue(reqJson, "communityId", "鏈寘鍚皬鍖篒D");
         Assert.hasKeyAndValue(reqJson, "billType", "蹇呭~锛岃濉啓鍑鸿处绫诲瀷");
-
-
-
     }
 
     @Override
+    @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
         FeeConfigDto feeConfigDto = new FeeConfigDto();
         feeConfigDto.setCommunityId(reqJson.getString("communityId"));
         feeConfigDto.setConfigId(reqJson.getString("configId"));
         List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
         Assert.listOnlyOne(feeConfigDtos, "鏈壘鍒拌璐圭敤椤�");
+//        int validCount = feeInnerServiceSMO.countValidPayFeeByConfigId(reqJson.getString("configId"));
+//        if (validCount > 0) {
+//            throw new CmdException("鍏宠仈鐢熸晥涓垂鐢紝鏃犳硶淇敼锛岃鎾ら攢鍏宠仈璐圭敤鍚庨噸璇曪紒");
+//        }
         JSONObject businessFeeConfig = new JSONObject();
         businessFeeConfig.putAll(reqJson);
         businessFeeConfig.put("isDefault", feeConfigDtos.get(0).getIsDefault());
         PayFeeConfigPo payFeeConfigPo = BeanConvertUtil.covertBean(businessFeeConfig, PayFeeConfigPo.class);
-
+        if("NA".equals(payFeeConfigPo.getState())){
+            payFeeConfigPo.setState("N");
+        }
         int flag = payFeeConfigV1InnerServiceSMOImpl.updatePayFeeConfig(payFeeConfigPo);
-
         if (flag < 1) {
             throw new CmdException("淇敼璐圭敤椤瑰け璐�");
         }
-
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
+
+        //todo 缁撴潫璐圭敤
+        finishFee(reqJson,feeConfigDtos);
+
+        //todo 淇敼璐圭敤鏍囪瘑
+        if (!reqJson.containsKey("feeFlag")) {
+            return;
+        }
+        String feeFlag = reqJson.getString("feeFlag");
+        //todo 璇存槑娌℃湁淇敼璐圭敤椤规爣璇�
+        if (feeFlag.equals(feeConfigDtos.get(0).getFeeFlag())) {
+            return;
+        }
+
+        // todo 妫�鏌ユ槸鍚︿负璐﹀崟妯″紡锛屼篃灏辨槸鍦� poy_fee_rule 涓槸鍚︽湁鏁版嵁锛岃繖閲屾湁鏁版嵁涓嶈淇敼
+        PayFeeRuleDto payFeeRuleDto = new PayFeeRuleDto();
+        payFeeRuleDto.setConfigId(feeConfigDtos.get(0).getConfigId());
+        payFeeRuleDto.setCommunityId(reqJson.getString("communityId"));
+        int count = payFeeRuleV1InnerServiceSMOImpl.queryPayFeeRulesCount(payFeeRuleDto);
+        if (count > 0) {
+            return;
+        }
+
+        PayFeePo payFeePo = new PayFeePo();
+        payFeePo.setConfigId(feeConfigDtos.get(0).getConfigId());
+        payFeePo.setFeeFlag(reqJson.getString("feeFlag"));
+
+        payFeeV1InnerServiceSMOImpl.updatePayFee(payFeePo);
+    }
+
+    /**
+     * 缁撴潫璐圭敤
+     * @param reqJson
+     * @param feeConfigDtos
+     */
+    private void finishFee(JSONObject reqJson, List<FeeConfigDto> feeConfigDtos) {
+        String state = reqJson.getString("state");
+        if(!"NA".equals(state)){
+            return;
+        }
+        PayFeePo payFeePo = new PayFeePo();
+        payFeePo.setConfigId(feeConfigDtos.get(0).getConfigId());
+        payFeePo.setState(FeeDto.STATE_FINISH);
+
+        payFeeV1InnerServiceSMOImpl.updatePayFee(payFeePo);
+
     }
 }

--
Gitblit v1.8.0