From 8936415a62627e4552dc600e26d92039b26cedfa Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期四, 30 一月 2020 15:10:21 +0800
Subject: [PATCH] 加入费用项处理页面

---
 Api/src/main/java/com/java110/api/listener/fee/UpdateFeeConfigListener.java |  152 +++++++++++++++++---------------------------------
 1 files changed, 52 insertions(+), 100 deletions(-)

diff --git a/Api/src/main/java/com/java110/api/listener/fee/UpdateFeeConfigListener.java b/Api/src/main/java/com/java110/api/listener/fee/UpdateFeeConfigListener.java
index 32d5c4a..f3bf13b 100644
--- a/Api/src/main/java/com/java110/api/listener/fee/UpdateFeeConfigListener.java
+++ b/Api/src/main/java/com/java110/api/listener/fee/UpdateFeeConfigListener.java
@@ -2,45 +2,66 @@
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.java110.api.listener.AbstractServiceApiDataFlowListener;
-import com.java110.utils.constant.BusinessTypeConstant;
-import com.java110.utils.constant.CommonConstant;
-import com.java110.utils.constant.ServiceCodeConstant;
-import com.java110.utils.util.Assert;
+import com.java110.api.listener.AbstractServiceApiListener;
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
-import com.java110.core.smo.fee.IFeeConfigInnerServiceSMO;
-import com.java110.dto.FeeConfigDto;
 import com.java110.entity.center.AppService;
 import com.java110.event.service.api.ServiceDataFlowEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.constant.ServiceCodeFeeConfigConstant;
+import com.java110.utils.util.Assert;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 
-import java.util.List;
-
 /**
- * @ClassName SaveFeeConfigListener
- * @Description TODO
- * @Author wuxw
- * @Date 2019/6/1 20:51
- * @Version 1.0
- * add by wuxw 2019/6/1
- **/
+ * 淇濆瓨璐圭敤椤逛睛鍚�
+ * add by wuxw 2019-06-30
+ */
 @Java110Listener("updateFeeConfigListener")
-public class UpdateFeeConfigListener extends AbstractServiceApiDataFlowListener {
-    private static Logger logger = LoggerFactory.getLogger(UpdateFeeConfigListener.class);
+public class UpdateFeeConfigListener extends AbstractServiceApiListener {
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
 
+        Assert.hasKeyAndValue(reqJson, "configId", "璐圭敤椤笽D涓嶈兘涓虹┖");
+        Assert.hasKeyAndValue(reqJson, "feeTypeCd", "蹇呭~锛岃閫夋嫨璐圭敤绫诲瀷");
+        Assert.hasKeyAndValue(reqJson, "feeName", "蹇呭~锛岃濉啓鏀惰垂椤圭洰");
+        Assert.hasKeyAndValue(reqJson, "feeFlag", "蹇呭~锛岃閫夋嫨璐圭敤鏍囪瘑");
+        Assert.hasKeyAndValue(reqJson, "startTime", "蹇呭~锛岃閫夋嫨璁¤垂璧峰鏃堕棿");
+        Assert.hasKeyAndValue(reqJson, "endTime", "蹇呭~锛岃閫夋嫨璁¤垂缁堟鏃堕棿");
+        Assert.hasKeyAndValue(reqJson, "computingFormula", "蹇呭~锛岃濉啓闄勫姞璐圭敤");
+        Assert.hasKeyAndValue(reqJson, "squarePrice", "蹇呭~锛岃濉啓璁¤垂鍗曚环");
+        Assert.hasKeyAndValue(reqJson, "additionalAmount", "蹇呭~锛岃濉啓闄勫姞璐圭敤");
+        Assert.hasKeyAndValue(reqJson, "communityId", "鏈寘鍚皬鍖篒D");
 
-    @Autowired
-    private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        HttpHeaders header = new HttpHeaders();
+        context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
+        JSONArray businesses = new JSONArray();
+
+        AppService service = event.getAppService();
+
+        //娣诲姞鍗曞厓淇℃伅
+        businesses.add(updateFeeConfig(reqJson, context));
+
+        JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders());
+
+        //灏� rest header 淇℃伅浼犻�掑埌涓嬪眰鏈嶅姟涓幓
+        super.freshHttpHeader(header, context.getRequestCurrentHeaders());
+
+        ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj);
+
+        context.setResponseEntity(responseEntity);
+    }
 
     @Override
     public String getServiceCode() {
-        return ServiceCodeConstant.SERVICE_CODE_UPDATE_FEE_CONFIG;
+        return ServiceCodeFeeConfigConstant.UPDATE_FEECONFIG;
     }
 
     @Override
@@ -49,45 +70,19 @@
     }
 
     @Override
-    public void soService(ServiceDataFlowEvent event) {
-
-        logger.debug("ServiceDataFlowEvent : {}", event);
-
-        DataFlowContext dataFlowContext = event.getDataFlowContext();
-        AppService service = event.getAppService();
-
-        String paramIn = dataFlowContext.getReqData();
-
-        //鏍¢獙鏁版嵁
-        validate(paramIn);
-        JSONObject paramObj = JSONObject.parseObject(paramIn);
-
-        HttpHeaders header = new HttpHeaders();
-        dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
-        JSONArray businesses = new JSONArray();
-
-        //娣诲姞鍗曞厓淇℃伅
-        businesses.add(modifyFeeConfig(paramObj, dataFlowContext));
-
-        JSONObject paramInObj = super.restToCenterProtocol(businesses, dataFlowContext.getRequestCurrentHeaders());
-
-        //灏� rest header 淇℃伅浼犻�掑埌涓嬪眰鏈嶅姟涓幓
-        super.freshHttpHeader(header, dataFlowContext.getRequestCurrentHeaders());
-
-        ResponseEntity<String> responseEntity = this.callService(dataFlowContext, service.getServiceCode(), paramInObj);
-
-        dataFlowContext.setResponseEntity(responseEntity);
-
+    public int getOrder() {
+        return DEFAULT_ORDER;
     }
 
+
     /**
-     * 娣诲姞灏忓尯妤间俊鎭�
+     * 娣诲姞璐圭敤椤逛俊鎭�
      *
      * @param paramInJson     鎺ュ彛璋冪敤鏀句紶鍏ュ叆鍙�
      * @param dataFlowContext 鏁版嵁涓婁笅鏂�
      * @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
      */
-    private JSONObject modifyFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+    private JSONObject updateFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext) {
 
 
         JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
@@ -96,52 +91,9 @@
         business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
         JSONObject businessFeeConfig = new JSONObject();
         businessFeeConfig.putAll(paramInJson);
+        //璁$畻 搴旀敹閲戦
         business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFeeConfig", businessFeeConfig);
-
         return business;
     }
 
-    /**
-     * 鏁版嵁鏍¢獙
-     *
-     * @param paramIn "communityId": "7020181217000001",
-     *                "memberId": "3456789",
-     *                "memberTypeCd": "390001200001"
-     */
-    private void validate(String paramIn) {
-        Assert.jsonObjectHaveKey(paramIn, "communityId", "璇锋眰鎶ユ枃涓湭鍖呭惈communityId鑺傜偣");
-        Assert.jsonObjectHaveKey(paramIn, "configId", "璇锋眰鎶ユ枃涓湭鍖呭惈communityId鑺傜偣");
-        Assert.jsonObjectHaveKey(paramIn, "squarePrice", "璇锋眰鎶ユ枃涓湭鍖呭惈squarePrice鑺傜偣");
-        Assert.jsonObjectHaveKey(paramIn, "additionalAmount", "璇锋眰鎶ユ枃涓湭鍖呭惈additionalAmount鑺傜偣");
-        Assert.jsonObjectHaveKey(paramIn, "feeTypeCd", "璇锋眰鎶ユ枃涓湭鍖呭惈feeTypeCd鑺傜偣");
-        JSONObject reqJson = JSONObject.parseObject(paramIn);
-        Assert.isMoney(reqJson.getString("squarePrice"), "squarePrice涓嶆槸鏈夋晥閲戦鏍煎紡");
-        Assert.isMoney(reqJson.getString("additionalAmount"), "additionalAmount涓嶆槸鏈夋晥閲戦鏍煎紡");
-        Assert.hasLength(reqJson.getString("communityId"), "灏忓尯ID閿欒");
-        Assert.hasLength(reqJson.getString("configId"), "configId閿欒");
-
-        FeeConfigDto feeConfigDto = new FeeConfigDto();
-        feeConfigDto.setCommunityId(reqJson.getString("communityId"));
-        feeConfigDto.setFeeTypeCd(reqJson.getString("feeTypeCd"));
-        //鏍¢獙灏忓尯妤糏D鍜屽皬鍖烘槸鍚︽湁瀵瑰簲鍏崇郴
-        List<FeeConfigDto> configDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
-
-        if (configDtos == null || configDtos.size() != 1) {
-            throw new IllegalArgumentException("涓嶅瓨鍦ㄦ敼璐圭敤閰嶇疆锛�" + JSONObject.toJSONString(feeConfigDto) + "锛変俊鎭�");
-        }
-
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-    public IFeeConfigInnerServiceSMO getFeeConfigInnerServiceSMOImpl() {
-        return feeConfigInnerServiceSMOImpl;
-    }
-
-    public void setFeeConfigInnerServiceSMOImpl(IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl) {
-        this.feeConfigInnerServiceSMOImpl = feeConfigInnerServiceSMOImpl;
-    }
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0