Просмотр исходного кода

客户信息受理主要逻辑修改为支持批量操作

wuxw7 лет назад: 9
Родитель
Сommit
b784f8af38
20 измененных файлов с 890 добавлено и 374 удалено
  1. 5 0
      .idea/copyright/Java110CommonCopyRight.xml
  2. 337 319
      .idea/workspace.xml
  3. 14 2
      OrderService/src/main/java/com/java110/order/listener/CustDispatchListener.java
  4. 47 9
      OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java
  5. 3 7
      OrderService/src/test/java/com/java110/order/type/AppCustEvent.java
  6. 3 1
      OrderService/src/test/java/com/java110/order/type/AppEvent.java
  7. 98 0
      UserService/src/main/java/com/java110/user/rest/UserServiceRest.java
  8. 7 0
      UserService/src/main/java/com/java110/user/smo/IUserServiceSMO.java
  9. 55 0
      UserService/src/main/java/com/java110/user/smo/impl/UserServiceSMOImpl.java
  10. 32 1
      common/src/main/java/com/java110/common/util/Assert.java
  11. 11 5
      common/src/main/java/com/java110/common/util/ProtocolUtil.java
  12. 2 1
      config/src/main/resources/config/event.properties
  13. 10 0
      core/src/main/java/com/java110/core/base/smo/BaseServiceSMO.java
  14. 113 0
      core/src/main/java/com/java110/core/context/AppContext.java
  15. 21 6
      core/src/main/java/com/java110/core/event/AppCustEvent.java
  16. 16 1
      core/src/main/java/com/java110/core/event/AppEvent.java
  17. 32 7
      core/src/main/java/com/java110/core/event/AppEventPublishing.java
  18. 4 8
      core/src/main/java/com/java110/core/event/AppMerchantEvent.java
  19. 4 7
      core/src/main/java/com/java110/core/event/AppPayEvent.java
  20. 76 0
      feign/src/main/java/com/java110/feign/user/IUserService.java

+ 5 - 0
.idea/copyright/Java110CommonCopyRight.xml

@@ -0,0 +1,5 @@
+<component name="CopyrightManager">
+  <copyright>
+    <option name="myName" value="Java110CommonCopyRight" />
+  </copyright>
+</component>

Разница между файлами не показана из-за своего большого размера
+ 337 - 319
.idea/workspace.xml


+ 14 - 2
OrderService/src/main/java/com/java110/order/listener/CustDispatchListener.java

@@ -1,7 +1,9 @@
 package com.java110.order.listener;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.util.ProtocolUtil;
+import com.java110.core.context.AppContext;
 import com.java110.core.event.AppCustEvent;
 import com.java110.core.event.AppListener;
 import com.java110.core.event.Ordered;
@@ -10,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.Assert;
 
+import java.util.List;
+
 /**
  * 客户信息调度
  * Created by wuxw on 2017/4/14.
@@ -26,12 +30,20 @@ public class CustDispatchListener implements AppListener<AppCustEvent> ,Ordered{
 
         //这里写 客户信息处理逻辑
 
-        String custInfo = event.getCustInfo();
+        AppContext context = event.getContext();
+
+        JSONArray dataCustInfos = event.getCustData();
+
+        JSONObject custInfoJson = new JSONObject();
+        custInfoJson.put("data",dataCustInfos.toJSONString());
+
+        String custInfo = custInfoJson.toJSONString();
+
 
         Assert.hasLength(custInfo,"没有需要处理的信息[custInfo="+custInfo+"]");
 
         //调用用户服务处理
-        String returnUser = iUserService.soUserService(custInfo);
+        String returnUser = iUserService.soUserServiceForOrderService(custInfo);
 
         JSONObject returnUserTmp = JSONObject.parseObject(returnUser);
 

+ 47 - 9
OrderService/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java

@@ -6,6 +6,7 @@ import com.java110.common.log.LoggerEngine;
 import com.java110.common.util.ProtocolUtil;
 import com.java110.config.properties.EventProperties;
 import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.core.context.AppContext;
 import com.java110.core.event.AppEventPublishing;
 import com.java110.entity.order.BusiOrder;
 import com.java110.entity.order.BusiOrderAttr;
@@ -21,6 +22,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import com.java110.common.util.Assert;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -127,11 +130,17 @@ public class OrderServiceSMOImpl extends BaseServiceSMO implements IOrderService
         //获取 订单项
         JSONArray busiOrderTmps = orderInfo.getJSONArray("busiOrder");
 
+        //存放busiOrder 的data节点
+
+        Map<String,JSONArray> datasTmp = new HashMap<String, JSONArray>();
+
         for(int busiOrderTmpsIndex = 0 ; busiOrderTmpsIndex < busiOrderTmps.size() ; busiOrderTmpsIndex++){
             JSONObject busiOrderJson = busiOrderTmps.getJSONObject(busiOrderTmpsIndex);
-            if (!busiOrderJson.containsKey("busiObj")){
+            /*if (!busiOrderJson.containsKey("busiObj")){
                 throw new IllegalArgumentException("请求报文中busiOrder 节点中没有对应的 busiObj 节点,请检查"+busiOrderJson);
-            }
+            }*/
+
+            Assert.isNull(busiOrderJson,"busiObj","请求报文中busiOrder 节点中没有对应的 busiObj 节点,请检查"+busiOrderJson);
 
             BusiOrder busiOrderObj = JSONObject.parseObject(busiOrderJson.getJSONObject("busiObj").toJSONString(),BusiOrder.class);
 
@@ -165,9 +174,11 @@ public class OrderServiceSMOImpl extends BaseServiceSMO implements IOrderService
                 }
             }
             //修改data节点下的boId,一般是没有这个值,所以直接新加就行了,不许判断是否已-开头
-            if (!busiOrderJson.containsKey("data")){
+           /* if (!busiOrderJson.containsKey("data")){
                 throw new IllegalArgumentException("请求报文中busiOrder 节点中没有对应的 data 节点,请检查"+busiOrderJson);
-            }
+            }*/
+
+            Assert.isNull(busiOrderJson,"data","请求报文中busiOrder 节点中没有对应的 data 节点,请检查"+busiOrderJson);
 
             //处理data 节点
             JSONObject data = busiOrderJson.getJSONObject("data");
@@ -189,17 +200,35 @@ public class OrderServiceSMOImpl extends BaseServiceSMO implements IOrderService
             //根据busiOrder 的  actionTypeCd 注册那个服务去处理
             String actionTypeCd = busiOrderObj.getActionTypeCd();
 
+            JSONArray dataJsonTmp = null;
+            if(!datasTmp.containsKey(actionTypeCd)){
+                dataJsonTmp = new JSONArray();
+            }else{
+                dataJsonTmp = datasTmp.get(actionTypeCd);
+            }
+            data.put("actionTypeCd",actionTypeCd);
+            dataJsonTmp.add(data);
+
+            datasTmp.put(actionTypeCd,dataJsonTmp);
+
+            /*
             try {
                 //发布事件
                 AppEventPublishing.multicastEvent(actionTypeCd,orderInfo.toJSONString(), data.toJSONString(),orderListTmp.getString("asyn"));
             }catch (Exception e){
                 //这里补偿事物
                 throw e;
-            }
-
+            }*/
 
         }
 
+        //创建上下文对象
+        AppContext context = createApplicationContext();
+
+        prepareContext(context, datasTmp);
+
+        AppEventPublishing.multicastEvent(context,datasTmp,orderListTmp.getString("asyn"));
+
         return ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_SUCCESS,"成功",JSONObject.parseObject(JSONObject.toJSONString(orderList)));
     }
 
@@ -317,9 +346,18 @@ public class OrderServiceSMOImpl extends BaseServiceSMO implements IOrderService
 
         List<BusiOrder> busiOrders =  iOrderServiceDao.queryBusiOrderAndAttr(busiOrderTmp);
 
-        if(busiOrders == null || busiOrders.size() == 0){
-            throw new IllegalArgumentException("没有找到需要作废的订单,[oldOdId="+oldOlId+",actionTypeCd = "+actionTypeCd+"]");
-        }
+        Assert.isNull(busiOrders,"没有找到需要作废的订单,[oldOdId="+oldOlId+",actionTypeCd = "+actionTypeCd+"]");
+
+
+    }
+
+    private void prepareContext(AppContext context,Map<String,JSONArray> datasTmp){
+        Assert.isNull(context,"创建上下对象失败");
+
+        //这里将整个订单的data 信息存入 上下文对象中,以防后期使用无法获取
+
+        context.coverData(datasTmp);
+
     }
 
     public IPrimaryKeyService getiPrimaryKeyService() {

+ 3 - 7
OrderService/src/test/java/com/java110/order/type/AppCustEvent.java

@@ -1,5 +1,6 @@
 package com.java110.order.type;
 
+import com.java110.core.context.AppContext;
 import com.java110.core.event.AppEvent;
 
 /**
@@ -8,19 +9,14 @@ import com.java110.core.event.AppEvent;
  */
 public class AppCustEvent extends AppEvent {
 
-    private String custInfo;
     /**
      * Constructs a prototypical Event.
      *
      * @param source The object on which the Event initially occurred.
      * @throws IllegalArgumentException if source is null.
      */
-    public AppCustEvent(Object source,String custInfo) {
-        super(source);
-        this.custInfo = custInfo;
+    public AppCustEvent(Object source, AppContext context) {
+        super(source,context);
     }
 
-    public String getCustInfo() {
-        return custInfo;
-    }
 }

+ 3 - 1
OrderService/src/test/java/com/java110/order/type/AppEvent.java

@@ -1,5 +1,7 @@
 package com.java110.order.type;
 
+import com.java110.core.context.AppContext;
+
 import java.util.EventObject;
 
 /**
@@ -13,7 +15,7 @@ public class AppEvent extends EventObject {
      * @param source The object on which the Event initially occurred.
      * @throws IllegalArgumentException if source is null.
      */
-    public AppEvent(Object source) {
+    public AppEvent(AppContext source) {
         super(source);
     }
 }

+ 98 - 0
UserService/src/main/java/com/java110/user/rest/UserServiceRest.java

@@ -89,6 +89,104 @@ public class UserServiceRest extends BaseController implements IUserService {
         }
     }
 
+    /**
+     * 这个接口专门用于订单服务受理用,入参为 JSONObject
+     *
+     * 支持 多个 客户信息 受理
+     *
+     * 请求协议:
+     *
+     * {
+     "data": [
+     {
+     "actionTypeCd": "C1",
+     "boCust": [
+     {
+     "custId": "-1",
+     "name": "S",
+     "email": "-52",
+     "cellphone": "17797173942",
+     "realName": "wuxw",
+     "sex": "1",
+     "password": "123456",
+     "lanId": "863010",
+     "custAdress": "青海省西宁市城中区格兰小镇",
+     "custType": "1",
+     "openId": "",
+     "state": "ADD"
+     },
+     {
+     "custId": "123",
+     "name": "S",
+     "email": "-52",
+     "cellphone": "17797173942",
+     "realName": "wuxw",
+     "sex": "1",
+     "password": "123456",
+     "lanId": "863010",
+     "custAdress": "青海省西宁市城中区格兰小镇",
+     "custType": "1",
+     "openId": "",
+     "state": "DEL"
+     }
+     ],
+     "boCustAttr": [
+     {
+     "custId": "123",
+     "prodId": "-1",
+     "attrCd": "123344",
+     "value": "1",
+     "state": "ADD"
+     },
+     {
+     "custId": "123",
+     "prodId": "-1",
+     "attrCd": "123345",
+     "value": "1",
+     "state": "DEL"
+     }
+     ]
+     }
+     ]
+     }
+
+     *
+     * 返回协议:
+     *
+     * {
+     'RESULT_CODE': '0000',
+     'RESULT_MSG': '成功',
+     'RESULT_INFO': {}
+     }
+     * @param data
+     * @return
+     */
+    @Override
+    @RequestMapping("/userService/soUserServiceForOrderService")
+    public String soUserServiceForOrderService(@RequestParam("data") String data) {
+        LoggerEngine.debug("soUserService入参:" + data);
+
+        String resultUserInfo = null;
+
+        JSONObject reqUserJSON = null;
+        try {
+            reqUserJSON = this.simpleValidateJSON(data);
+            //1.0规则校验,报文是否合法
+
+
+            //2.0 受理客户信息
+            resultUserInfo = iUserServiceSMO.soUserServiceForOrderService(reqUserJSON);
+
+
+        } catch (Exception e) {
+            LoggerEngine.error("服务处理出现异常:", e);
+            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
+        } finally {
+            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
+            return resultUserInfo;
+        }
+    }
+
 
     /**
      * 客户信息处理

+ 7 - 0
UserService/src/main/java/com/java110/user/smo/IUserServiceSMO.java

@@ -24,6 +24,13 @@ public interface IUserServiceSMO {
      */
     public String soUserService(JSONObject userInfoJson) throws Exception;
 
+    /**
+     * 所有服务类(增删改查用户)
+     * @param userInfoJson
+     * @return
+     */
+    public String soUserServiceForOrderService(JSONObject userInfoJson) throws Exception;
+
     /**
      * 客户信息处理
      * 协议:

+ 55 - 0
UserService/src/main/java/com/java110/user/smo/impl/UserServiceSMOImpl.java

@@ -3,6 +3,7 @@ package com.java110.user.smo.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.log.LoggerEngine;
+import com.java110.common.util.Assert;
 import com.java110.common.util.ProtocolUtil;
 import com.java110.entity.user.BoCust;
 import com.java110.entity.user.BoCustAttr;
@@ -80,7 +81,11 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
 
     /**
      * 所有服务处理类
+     * {
      *
+     *     'boCust':[{}],
+     *     'boCustAttr':[{}]
+     * }
      * @param userInfoJson
      * @return
      */
@@ -138,6 +143,56 @@ public class UserServiceSMOImpl extends BaseServiceSMO implements IUserServiceSM
 
     }
 
+    /**
+     *
+     * 请求报文为:
+     *
+     * {
+     "data": [
+     {
+     "actionTypeCd": "C1",
+     "boCust": [{},{}],
+     "boCustAttr": [{ }, {}]
+     },
+     {
+     "actionTypeCd": "C1",
+     "boCust": [{},{}],
+     "boCustAttr": [{ }, {}]
+     }
+     ]
+     }
+     * @param userInfoJson
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public String soUserServiceForOrderService(JSONObject userInfoJson) throws Exception {
+
+        Assert.isNull(userInfoJson,"data","请求报文缺少 data 节点,请检查");
+
+        JSONArray custInfos = userInfoJson.getJSONArray("data");
+
+        Assert.isNull(custInfos,"请求报文中data节点,没有子节点,data子节点应该为JSONArray,custInfos="+custInfos);
+
+        JSONArray resultInfos = new JSONArray();
+        for(int custInfoIndex = 0 ;custInfoIndex < custInfos.size();custInfoIndex ++){
+            JSONObject custInfoJson = custInfos.getJSONObject(custInfoIndex);
+            String soUserServiceResult = this.soUserService(custInfoJson);
+            JSONObject resultInfo = new JSONObject();
+
+            if(!ProtocolUtil.validateReturnJson(soUserServiceResult,resultInfo)){
+                throw new RuntimeException("客户信息受理失败,原因为:"+resultInfo.getString(ProtocolUtil.RESULT_MSG));
+            }
+
+            resultInfos.add(resultInfo.getJSONObject(ProtocolUtil.RESULT_INFO));
+        }
+        JSONObject custInfoJ = new JSONObject();
+
+        custInfoJ.put("data",resultInfos);
+
+        return ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_SUCCESS,"成功",custInfoJ);
+    }
+
     /**
      * {
      *     boCust:[{},{}]

+ 32 - 1
common/src/main/java/com/java110/common/util/Assert.java

@@ -3,6 +3,9 @@ package com.java110.common.util;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 自定义 断言
  * Created by wuxw on 2017/4/22.
@@ -32,8 +35,36 @@ public class Assert extends org.springframework.util.Assert{
 
         Assert.isNull(jsonArray,message);
 
-        if(jsonArray.size() == 0 ){
+        if(jsonArray.size() < 1 ){
+            throw new IllegalArgumentException(message) ;
+        }
+    }
+
+    /**
+     * 判断list 是否为空
+     * @param targetList
+     * @param message
+     */
+    public static void isNull(List<?> targetList , String message){
+
+        Assert.isNull(targetList,message);
+
+        if(targetList.size()< 1){
             throw new IllegalArgumentException(message) ;
         }
     }
+
+    /**
+     * 校验map 中是否有值
+     * @param targetMap
+     * @param message
+     */
+    public static void hasSize(Map<?,?> targetMap, String message){
+        Assert.isNull(targetMap,message);
+
+        if(targetMap.size() < 1){
+            throw new IllegalArgumentException(message);
+        }
+
+    }
 }

+ 11 - 5
common/src/main/java/com/java110/common/util/ProtocolUtil.java

@@ -51,6 +51,12 @@ public class ProtocolUtil {
 
     public static final String SERVICE_CODE_ADD_OFFER = "FS_007"; //销售品订购
 
+    public static final String RESULT_CODE = "RESULT_CODE"; //接口返回 编码key
+
+    public static final String RESULT_MSG = "RESULT_MSG"; // 接口返回 描述key
+
+    public static final String RESULT_INFO = "RESULT_INFO"; //接口返回 信息 key
+
 
     private static JSONObject tcpContJson = null;
 
@@ -328,9 +334,9 @@ public class ProtocolUtil {
      */
     public static String createResultMsg(String resultCode, String resultMsg, JSONObject resultInfo) {
         JSONObject data = new JSONObject();
-        data.put("RESULT_CODE", resultCode);
-        data.put("RESULT_MSG", resultMsg);
-        data.put("RESULT_INFO", resultInfo);
+        data.put(RESULT_CODE, resultCode);
+        data.put(RESULT_MSG, resultMsg);
+        data.put(RESULT_INFO, resultInfo);
         return data.toString();
     }
 
@@ -345,11 +351,11 @@ public class ProtocolUtil {
         try{
              paramJson = JSONObject.parseObject(returnJsonParam);
 
-            if(paramJson == null || !paramJson.containsKey("RESULT_CODE")){
+            if(paramJson == null || !paramJson.containsKey(RESULT_CODE)){
                 return false;
             }
 
-            if(ProtocolUtil.RETURN_MSG_SUCCESS.equals(paramJson.getString("RESULT_CODE"))){
+            if(ProtocolUtil.RETURN_MSG_SUCCESS.equals(paramJson.getString(RESULT_CODE))){
                 return true;
             }
 

+ 2 - 1
config/src/main/resources/config/event.properties

@@ -3,4 +3,5 @@ java110.event.properties.orderDispatchListener=\
   com.java110.order.listener.MerchantDispatchListener
 
 java110.event.properties.orderDispatchEvent=\
-  C1::com.java110.order.type.AppCustEvent
+  C1::com.java110.order.type.AppCustEvent,\
+  C2::com.java110.order.type.AppCustEvent

+ 10 - 0
core/src/main/java/com/java110/core/base/smo/BaseServiceSMO.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.java110.common.log.LoggerEngine;
 import com.java110.common.util.ProtocolUtil;
 import com.java110.core.base.AppBase;
+import com.java110.core.context.AppContext;
 import com.java110.feign.base.IPrimaryKeyService;
 import org.apache.commons.lang3.math.NumberUtils;
 
@@ -50,6 +51,15 @@ public class BaseServiceSMO extends AppBase {
     }
 
 
+    /**
+     * 创建上下文对象
+     * @return
+     */
+    protected AppContext createApplicationContext(){
+        return AppContext.newInstance();
+    }
+
+
 
 
 

+ 113 - 0
core/src/main/java/com/java110/core/context/AppContext.java

@@ -0,0 +1,113 @@
+package com.java110.core.context;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 应用上下文对象
+ * Created by wuxw on 2017/4/22.
+ */
+public class AppContext {
+
+
+    /**
+     * olId 主键前缀
+     */
+    public final static String PREFIX_OLID = "OLID_";
+
+    /**
+     * custId 主键前缀
+     */
+    public final static String PREFIX_CUSTID = "CUSTID_";
+
+
+    /**
+     * 为了满足 一个单子上有 多个 olId,custId 不同的处理,
+     * key 为 olId,custId 默认 前缀加 请求时的 值 如 OLID_-1
+     * value 通过生单后生成的 值 如 12345678
+     *
+     * 后期取值时通过订单原始请求报文中 olId,custId 对应的值 从map 中获取
+     */
+    private Map<String,String> keyIdMap = null;
+
+
+
+
+    /**
+     * 存放订单data节点
+     */
+    private  Map<String,JSONArray> datas = null;
+
+
+    public static AppContext newInstance(){
+        AppContext context = new AppContext();
+        context.keyIdMap = new HashMap<String,String>();
+        context.datas = new HashMap<String, JSONArray>();
+        return context;
+    }
+
+
+    /**
+     * 添加 数据
+     * @param data
+     */
+    public void addData(String actionTypeCd , JSONArray data){
+        synchronized (datas){
+            datas.put(actionTypeCd,data);
+        }
+    }
+
+    public void coverData(Map<String,JSONArray> datas){
+        this.datas = datas;
+    }
+
+    /**
+     * 获取 所有数据
+     * @return
+     */
+    public Map<String,JSONArray> getAllDatas(){
+        return datas;
+    }
+
+    /**
+     * 根据 动作类型获取 数据
+     * @param actionTypeCd
+     * @return
+     */
+    public JSONArray getDatasByActionTypeCd(String actionTypeCd){
+        return datas.get(actionTypeCd);
+    }
+
+    /**
+     *
+     * 根据 原始的olId的值获取新生成的值
+     * @param originalKeyIdValue 原始的olId 值 如请求订单中的olId 为 -1 这里就写-1
+     * @param defalutValue 如果获取不到对应的值则返回默认值
+     * @return
+     */
+    public String getKeyId(String originalKeyIdValue,String defalutValue){
+        if(keyIdMap.containsKey(originalKeyIdValue)){
+            return keyIdMap.get(originalKeyIdValue);
+        }
+
+        return defalutValue;
+    }
+
+    /**
+     * 设置新生成的主键值
+     * @param prefix
+     * @param originalKeyIdValue
+     * @param newValue
+     */
+    public void setKeyId(String prefix,String originalKeyIdValue,String newValue){
+        keyIdMap.put(prefix+originalKeyIdValue,newValue);
+    }
+
+
+
+}

+ 21 - 6
core/src/main/java/com/java110/core/event/AppCustEvent.java

@@ -1,24 +1,39 @@
 package com.java110.core.event;
 
+import com.alibaba.fastjson.JSONArray;
+import com.java110.App;
+import com.java110.core.context.AppContext;
+
 /**
  * 客户事件
  * Created by wuxw on 2017/4/14.
  */
 public class AppCustEvent extends AppEvent {
 
-    private String custInfo;
+    JSONArray custData = null;
+
+    /**
+     * 初始化客户事件
+     * @param source
+     * @param context
+     * @param custData
+     */
+    public AppCustEvent(Object source,AppContext context,JSONArray custData){
+        super(source,context);
+        this.custData = custData;
+    }
+
     /**
      * Constructs a prototypical Event.
      *
      * @param source The object on which the Event initially occurred.
      * @throws IllegalArgumentException if source is null.
      */
-    public AppCustEvent(Object source,String custInfo) {
-        super(source);
-        this.custInfo = custInfo;
+    public AppCustEvent(Object source, AppContext context) {
+        this(source, context,null);
     }
 
-    public String getCustInfo() {
-        return custInfo;
+    public JSONArray getCustData() {
+        return custData;
     }
 }

+ 16 - 1
core/src/main/java/com/java110/core/event/AppEvent.java

@@ -1,5 +1,7 @@
 package com.java110.core.event;
 
+import com.java110.core.context.AppContext;
+
 import java.util.EventObject;
 
 /**
@@ -7,13 +9,26 @@ import java.util.EventObject;
  * Created by wuxw on 2017/4/14.
  */
 public class AppEvent extends EventObject {
+
+    private AppContext context;
+
+
     /**
      * Constructs a prototypical Event.
      *
      * @param source The object on which the Event initially occurred.
      * @throws IllegalArgumentException if source is null.
      */
-    public AppEvent(Object source) {
+    public AppEvent(Object source,AppContext context) {
         super(source);
+        this.context= context;
+    }
+
+    public AppContext getContext() {
+        return context;
+    }
+
+    public void setContext(AppContext context) {
+        this.context = context;
     }
 }

+ 32 - 7
core/src/main/java/com/java110/core/event/AppEventPublishing.java

@@ -1,19 +1,17 @@
 package com.java110.core.event;
 
+import com.alibaba.fastjson.JSONArray;
 import com.java110.common.log.LoggerEngine;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.util.Assert;
+import com.java110.common.util.Assert;
+import com.java110.core.context.AppContext;
+
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadPoolExecutor;
 
 /**
  * 事件发布侦听
@@ -66,6 +64,7 @@ public class AppEventPublishing extends LoggerEngine{
     /**
      * 根据是否实现了某个接口,返回侦听
      * @param interfaceClassName
+     * @since 1.7
      * @return
      */
     public static List<AppListener<?>> getListeners(String interfaceClassName){
@@ -152,6 +151,32 @@ public class AppEventPublishing extends LoggerEngine{
 
     }
 
+    /**
+     * 一次发布同一个动作的 订单数据,避免多次调用子服务,印象性能
+     * @param context 上下文对象
+     * @param data 封装了 data节点 的数据
+     * @throws Exception
+     */
+    public static void multicastEvent(AppContext context, Map<String,JSONArray> data, String asyn) throws Exception{
+        Assert.hasSize(data,"订单调度时,没有可处理的数据,data="+data);
+
+       Set<String> keys =  data.keySet();
+
+       for(String key : keys){
+           Class<AppEvent> appEvent = getEvent(key);
+
+           Class[] parameterTypes={Object.class,AppContext.class,JSONArray.class};
+
+           Constructor constructor = appEvent.getClass().getConstructor(parameterTypes);
+           Object[] parameters={null,context,data.get(key)};
+           AppEvent targetAppEvent = (AppEvent)constructor.newInstance(parameters);
+
+           multicastEvent(targetAppEvent,asyn);
+       }
+
+
+    }
+
 
     /**
      * 发布事件

+ 4 - 8
core/src/main/java/com/java110/core/event/AppMerchantEvent.java

@@ -1,24 +1,20 @@
 package com.java110.core.event;
 
+import com.java110.core.context.AppContext;
+
 /**
  * 商户事件
  * Created by wuxw on 2017/4/14.
  */
 public class AppMerchantEvent extends AppEvent {
 
-    private String merchantInfo;
     /**
      * Constructs a prototypical Event.
      *
      * @param source The object on which the Event initially occurred.
      * @throws IllegalArgumentException if source is null.
      */
-    public AppMerchantEvent(Object source,String merchantInfo) {
-        super(source);
-        this.merchantInfo = merchantInfo;
-    }
-
-    public String getMerchantInfo() {
-        return merchantInfo;
+    public AppMerchantEvent(Object source, AppContext context) {
+        super(source,context);
     }
 }

+ 4 - 7
core/src/main/java/com/java110/core/event/AppPayEvent.java

@@ -1,5 +1,7 @@
 package com.java110.core.event;
 
+import com.java110.core.context.AppContext;
+
 /**
  *
  * 支付事件
@@ -7,19 +9,14 @@ package com.java110.core.event;
  */
 public class AppPayEvent extends AppEvent {
 
-    private String payInfo;
     /**
      * Constructs a prototypical Event.
      *
      * @param source The object on which the Event initially occurred.
      * @throws IllegalArgumentException if source is null.
      */
-    public AppPayEvent(Object source,String payInfo) {
-        super(source);
-        this.payInfo= payInfo;
+    public AppPayEvent(Object source, AppContext context) {
+        super(source,context);
     }
 
-    public String getPayInfo() {
-        return payInfo;
-    }
 }

+ 76 - 0
feign/src/main/java/com/java110/feign/user/IUserService.java

@@ -40,6 +40,82 @@ public interface IUserService {
     public String soUserService(@RequestParam("data") String data);
 
 
+    /**
+     * 这个接口专门用于订单服务受理用,入参为 JSONArray
+     *
+     * 支持 多个 客户信息 受理
+     *
+     * 请求协议:
+     *
+     * {
+     "data": [
+     {
+     "actionTypeCd": "C1",
+     "boCust": [
+     {
+     "custId": "-1",
+     "name": "S",
+     "email": "-52",
+     "cellphone": "17797173942",
+     "realName": "wuxw",
+     "sex": "1",
+     "password": "123456",
+     "lanId": "863010",
+     "custAdress": "青海省西宁市城中区格兰小镇",
+     "custType": "1",
+     "openId": "",
+     "state": "ADD"
+     },
+     {
+     "custId": "123",
+     "name": "S",
+     "email": "-52",
+     "cellphone": "17797173942",
+     "realName": "wuxw",
+     "sex": "1",
+     "password": "123456",
+     "lanId": "863010",
+     "custAdress": "青海省西宁市城中区格兰小镇",
+     "custType": "1",
+     "openId": "",
+     "state": "DEL"
+     }
+     ],
+     "boCustAttr": [
+     {
+     "custId": "123",
+     "prodId": "-1",
+     "attrCd": "123344",
+     "value": "1",
+     "state": "ADD"
+     },
+     {
+     "custId": "123",
+     "prodId": "-1",
+     "attrCd": "123345",
+     "value": "1",
+     "state": "DEL"
+     }
+     ]
+     }
+     ]
+     }
+
+     *
+     * 返回协议:
+     *
+     * {
+     'RESULT_CODE': '0000',
+     'RESULT_MSG': '成功',
+     'RESULT_INFO': {}
+     }
+     * @param data
+     * @return
+     */
+    @RequestMapping("/userService/soUserServiceForOrderService")
+    public String soUserServiceForOrderService(@RequestParam("data") String data);
+
+
     /**
      * 客户信息处理
      * 协议: