Parcourir la source

商户服务开发完成,待测试

wuxw7 il y a 7 ans
Parent
commit
9adbbca6d7

+ 41 - 0
StoreService/doc/deleteStoreInfo.json

@@ -0,0 +1,41 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": [{
+    "serviceCode": "delete.store.info",
+    "serviceName": "修改商户信息",
+    "remark": "备注",
+    "datas": {
+      "businessStore": {
+        "storeId": "123456"
+      },
+      "businessStoreAttr": [{
+        "storeId": "123456",
+        "attrId":"1234546"
+      }],
+      "businessStorePhoto":[{
+        "storePhotoId":"12321",
+        "storeId": "123456"
+      }],
+      "businessStoreCerdentials":[{
+        "storeCerdentialsId":"123123",
+        "storeId": "123456"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }]
+}

+ 7 - 6
StoreService/doc/saveStoreInfo.json

@@ -27,13 +27,14 @@
         "storeTypeCd": "M",
         "nearbyLandmarks": "王府井内",
         "mapX": "101.801909",
-        "mapY": "36.597263",
-        "businessStoreAttr": [{
-          "attrId":"-1",
-          "specCd":"1001",
-          "value":"01"
-        }]
+        "mapY": "36.597263"
       },
+      "businessStoreAttr": [{
+        "storeId": "-1",
+        "attrId":"-1",
+        "specCd":"1001",
+        "value":"01"
+      }],
       "businessStorePhoto":[{
         "storePhotoId":"-1",
         "storeId":"-1",

+ 59 - 0
StoreService/doc/updateStoreInfo.json

@@ -0,0 +1,59 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": [{
+    "serviceCode": "update.store.info",
+    "serviceName": "修改商户信息",
+    "remark": "备注",
+    "datas": {
+      "businessStore": {
+        "storeId": "123456",
+        "userId": "用户ID",
+        "name": "齐天超时(王府井店)",
+        "address": "青海省西宁市城中区129号",
+        "password": "ERCBHDUYFJDNDHDJDNDJDHDUDHDJDDKDK",
+        "tel": "15897089471",
+        "storeTypeCd": "M",
+        "nearbyLandmarks": "王府井内",
+        "mapX": "101.801909",
+        "mapY": "36.597263"
+      },
+      "businessStoreAttr": [{
+        "storeId": "123456",
+        "attrId":"1234546",
+        "specCd":"1001",
+        "value":"01"
+      }],
+      "businessStorePhoto":[{
+        "storePhotoId":"12321",
+        "storeId": "123456",
+        "storePhotoTypeCd":"T",
+        "photo":"12345678.jpg"
+      }],
+      "businessStoreCerdentials":[{
+        "storeCerdentialsId":"123123",
+        "storeId": "123456",
+        "credentialsCd":"1",
+        "value":"632126XXXXXXXX2011",
+        "validityPeriod":"有效期,长期有效请写3000/01/01",
+        "positivePhoto":"正面照片地址,1234567.jpg",
+        "negativePhoto":"反面照片地址,没有不填写"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }]
+}

+ 1 - 0
StoreService/src/main/java/com/java110/store/dao/IStoreServiceDao.java

@@ -181,4 +181,5 @@ public interface IStoreServiceDao {
      * @throws DAOException
      */
     public void updateStoreCerdentailsInstance(Map info) throws DAOException;
+
 }

+ 184 - 0
StoreService/src/main/java/com/java110/store/listener/AbstractStoreBusinessServiceDataFlowListener.java

@@ -0,0 +1,184 @@
+package com.java110.store.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
+import com.java110.store.dao.IStoreServiceDao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * 商户 服务侦听 父类
+ * Created by wuxw on 2018/7/4.
+ */
+public abstract class AbstractStoreBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener{
+
+
+    /**
+     * 获取 DAO工具类
+     * @return
+     */
+    public abstract IStoreServiceDao getStoreServiceDaoImpl();
+
+    /**
+     * 刷新 businessStoreInfo 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     * @param businessStoreInfo
+     */
+    protected void flushBusinessStoreInfo(Map businessStoreInfo,String statusCd){
+        businessStoreInfo.put("newBId",businessStoreInfo.get("b_id"));
+        businessStoreInfo.put("storeId",businessStoreInfo.get("store_id"));
+        businessStoreInfo.put("userId",businessStoreInfo.get("user_id"));
+        businessStoreInfo.put("storeTypeCd",businessStoreInfo.get("store_type_cd"));
+        businessStoreInfo.put("nearbyLandmarks",businessStoreInfo.get("nearby_landmarks"));
+        businessStoreInfo.put("mapX",businessStoreInfo.get("map_x"));
+        businessStoreInfo.put("mapY",businessStoreInfo.get("map_y"));
+        businessStoreInfo.put("statusCd", statusCd);
+    }
+
+    /**
+        刷新 businessStoreAttr 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     * @param businessStoreAttr
+     * @param statusCd
+     */
+    protected void flushBusinessStoreAttr(Map businessStoreAttr,String statusCd){
+        businessStoreAttr.put("attrId",businessStoreAttr.get("attr_id"));
+        businessStoreAttr.put("specCd",businessStoreAttr.get("spec_cd"));
+        businessStoreAttr.put("storeId",businessStoreAttr.get("store_id"));
+        businessStoreAttr.put("newBId",businessStoreAttr.get("b_id"));
+        businessStoreAttr.put("statusCd",statusCd);
+    }
+
+    /**
+     * 刷新 businessStorePhoto 数据
+     * @param businessStorePhoto
+     * @param statusCd
+     */
+    protected void flushBusinessStorePhoto(Map businessStorePhoto,String statusCd){
+        businessStorePhoto.put("storeId",businessStorePhoto.get("store_id"));
+        businessStorePhoto.put("storePhotoId",businessStorePhoto.get("store_photo_id"));
+        businessStorePhoto.put("storePhotoTypeCd",businessStorePhoto.get("store_photo_type_cd"));
+        businessStorePhoto.put("newBId",businessStorePhoto.get("b_id"));
+        businessStorePhoto.put("statusCd",statusCd);
+    }
+
+    /**
+     * 刷新 businessStoreCerdentials 数据
+     * @param businessStoreCerdentials
+     * @param statusCd
+     */
+    protected void flushBusinessStoreCredentials(Map businessStoreCerdentials ,String statusCd){
+        businessStoreCerdentials.put("storeId",businessStoreCerdentials.get("store_id"));
+        businessStoreCerdentials.put("storeCerdentialsId",businessStoreCerdentials.get("store_cerdentials_id"));
+        businessStoreCerdentials.put("credentialsCd",businessStoreCerdentials.get("credentials_cd"));
+        businessStoreCerdentials.put("validityPeriod",businessStoreCerdentials.get("validity_period"));
+        businessStoreCerdentials.put("positivePhoto",businessStoreCerdentials.get("positive_photo"));
+        businessStoreCerdentials.put("negativePhoto",businessStoreCerdentials.get("negative_photo"));
+        businessStoreCerdentials.put("newBId",businessStoreCerdentials.get("b_id"));
+        businessStoreCerdentials.put("statusCd",statusCd);
+    }
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param businessStore 商户信息
+     */
+    protected void autoSaveDelBusinessStore(Business business, JSONObject businessStore){
+//自动插入DEL
+        Map info = new HashMap();
+        info.put("storeId",businessStore.getString("storeId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map currentStoreInfo = getStoreServiceDaoImpl().getStoreInfo(info);
+        if(currentStoreInfo == null || currentStoreInfo.isEmpty()){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        currentStoreInfo.put("bId",business.getbId());
+        currentStoreInfo.put("storeId",currentStoreInfo.get("store_id"));
+        currentStoreInfo.put("userId",currentStoreInfo.get("user_id"));
+        currentStoreInfo.put("storeTypeCd",currentStoreInfo.get("store_type_cd"));
+        currentStoreInfo.put("nearbyLandmarks",currentStoreInfo.get("nearby_landmarks"));
+        currentStoreInfo.put("mapX",currentStoreInfo.get("map_x"));
+        currentStoreInfo.put("mapY",currentStoreInfo.get("map_y"));
+        currentStoreInfo.put("operate",StatusConstant.OPERATE_DEL);
+        getStoreServiceDaoImpl().saveBusinessStoreInfo(currentStoreInfo);
+    }
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param business 当前业务
+     * @param storeAttr 商户属性
+     */
+    protected void autoSaveDelBusinessStoreAttr(Business business, JSONObject storeAttr){
+        Map info = new HashMap();
+        info.put("attrId",storeAttr.getString("attrId"));
+        info.put("storeId",storeAttr.getString("storeId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        List<Map> currentStoreAttrs = getStoreServiceDaoImpl().getStoreAttrs(info);
+        if(currentStoreAttrs == null || currentStoreAttrs.size() != 1){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        Map currentStoreAttr = currentStoreAttrs.get(0);
+        currentStoreAttr.put("bId",business.getbId());
+        currentStoreAttr.put("attrId",currentStoreAttr.get("attr_id"));
+        currentStoreAttr.put("storeId",currentStoreAttr.get("store_id"));
+        currentStoreAttr.put("specCd",currentStoreAttr.get("spec_cd"));
+        currentStoreAttr.put("operate",StatusConstant.OPERATE_DEL);
+        getStoreServiceDaoImpl().saveBusinessStoreAttr(currentStoreAttr);
+    }
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param business
+     * @param businessStorePhoto 商户照片
+     */
+    protected void autoSaveDelBusinessStorePhoto(Business business,JSONObject businessStorePhoto){
+       Map info = new HashMap();
+        info.put("storePhotoId",businessStorePhoto.getString("storePhotoId"));
+        info.put("storeId",businessStorePhoto.getString("storeId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        List<Map> currentStorePhotos = getStoreServiceDaoImpl().getStorePhoto(info);
+        if(currentStorePhotos == null || currentStorePhotos.size() != 1){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        Map currentStorePhoto = currentStorePhotos.get(0);
+        currentStorePhoto.put("bId",business.getbId());
+        currentStorePhoto.put("storePhotoId",currentStorePhoto.get("store_photo_id"));
+        currentStorePhoto.put("storeId",currentStorePhoto.get("store_id"));
+        currentStorePhoto.put("storePhotoTypeCd",currentStorePhoto.get("store_photo_type_cd"));
+        currentStorePhoto.put("operate",StatusConstant.OPERATE_DEL);
+        getStoreServiceDaoImpl().saveBusinessStorePhoto(currentStorePhoto);
+    }
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param business
+     * @param businessStoreCerdentials 商户证件
+     */
+    protected void autoSaveDelBusinessStoreCerdentials(Business business,JSONObject businessStoreCerdentials){
+        Map info = new HashMap();
+        info.put("storeCerdentialsId",businessStoreCerdentials.getString("storeCerdentialsId"));
+        info.put("storeId",businessStoreCerdentials.getString("storeId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        List<Map> currentStoreCerdentailses = getStoreServiceDaoImpl().getStoreCerdentials(info);
+        if(currentStoreCerdentailses == null || currentStoreCerdentailses.size() != 1){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        Map currentStoreCerdentials = currentStoreCerdentailses.get(0);
+
+        currentStoreCerdentials.put("bId",business.getbId());
+        currentStoreCerdentials.put("storeCerdentialsId",currentStoreCerdentials.get("store_cerdentials_id"));
+        currentStoreCerdentials.put("storeId",currentStoreCerdentials.get("store_id"));
+        currentStoreCerdentials.put("credentialsCd",currentStoreCerdentials.get("credentials_cd"));
+        currentStoreCerdentials.put("validityPeriod",currentStoreCerdentials.get("validity_period"));
+        currentStoreCerdentials.put("positivePhoto",currentStoreCerdentials.get("positive_photo"));
+        currentStoreCerdentials.put("negativePhoto",currentStoreCerdentials.get("negative_photo"));
+        currentStoreCerdentials.put("operate",StatusConstant.OPERATE_DEL);
+        getStoreServiceDaoImpl().saveBusinessStoreAttr(currentStoreCerdentials);
+    }
+}

+ 293 - 0
StoreService/src/main/java/com/java110/store/listener/DeleteStoreInfoListener.java

@@ -0,0 +1,293 @@
+package com.java110.store.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.store.dao.IStoreServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 删除商户信息 侦听
+ *
+ * 处理节点
+ * 1、businessStore:{} 商户基本信息节点
+ * 2、businessStoreAttr:[{}] 商户属性信息节点
+ * 3、businessStorePhoto:[{}] 商户照片信息节点
+ * 4、businessStoreCerdentials:[{}] 商户证件信息节点
+ * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E5%88%A0%E9%99%A4%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("deleteStoreInfoListener")
+@Transactional
+public class DeleteStoreInfoListener extends AbstractStoreBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteStoreInfoListener.class);
+    @Autowired
+    IStoreServiceDao storeServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_DELETE_STORE_INFO;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessStore 节点 按理这里不应该处理,程序上支持,以防真有这种业务
+        if(data.containsKey("businessStore")){
+            JSONObject businessStore = data.getJSONObject("businessStore");
+            doBusinessStore(business,businessStore);
+            dataFlowContext.addParamOut("storeId",businessStore.getString("storeId"));
+        }
+
+        if(data.containsKey("businessStoreAttr")){
+            JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr");
+            doSaveBusinessStoreAttrs(business,businessStoreAttrs);
+        }
+
+        if(data.containsKey("businessStorePhoto")){
+            JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto");
+            doBusinessStorePhoto(business,businessStorePhotos);
+        }
+
+        if(data.containsKey("businessStoreCerdentials")){
+            JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials");
+            doBusinessStoreCerdentials(business,businessStoreCerdentialses);
+        }
+    }
+
+    /**
+     * 删除 instance数据
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+
+        Map paramIn = new HashMap();
+        paramIn.put("bId",bId);
+        paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+        //商户信息
+        Map storeInfo = storeServiceDaoImpl.getStoreInfo(info);
+        if(storeInfo != null && !storeInfo.isEmpty()){
+            paramIn.put("storeId",storeInfo.get("store_id").toString());
+            storeServiceDaoImpl.updateStoreInfoInstance(paramIn);
+            dataFlowContext.addParamOut("storeId",storeInfo.get("store_id"));
+        }
+
+        //商户属性
+        List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info);
+        if(storeAttrs != null && storeAttrs.size()>0){
+            storeServiceDaoImpl.updateStoreAttrInstance(paramIn);
+        }
+
+        //商户照片
+        List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info);
+        if(storePhotos != null && storePhotos.size()>0){
+            storeServiceDaoImpl.updateStorePhotoInstance(paramIn);
+        }
+
+        //商户属性
+        List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info);
+        if(storeCerdentialses != null && storeCerdentialses.size()>0){
+            storeServiceDaoImpl.updateStoreCerdentailsInstance(paramIn);
+        }
+    }
+
+    /**
+     * 撤单
+     * 从business表中查询到DEL的数据 将instance中的数据更新回来
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+        //商户信息
+        Map storeInfo = storeServiceDaoImpl.getStoreInfo(info);
+        if(storeInfo != null && !storeInfo.isEmpty()){
+
+            //商户信息
+            Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStoreInfo == null || businessStoreInfo.isEmpty()){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store),程序内部异常,请检查! "+delInfo);
+            }
+
+            flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID);
+            storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo);
+            dataFlowContext.addParamOut("storeId",storeInfo.get("store_id"));
+        }
+
+        //商户属性
+        List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info);
+        if(storeAttrs != null && storeAttrs.size()>0){
+
+            List<Map> businessStoreAttrs = storeServiceDaoImpl.getBusinessStoreAttrs(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStoreAttrs == null || businessStoreAttrs.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_attr),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessStoreAttr : businessStoreAttrs) {
+                flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr);
+            }
+        }
+
+        //商户照片
+        List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info);
+        if(storePhotos != null && storePhotos.size()>0){
+            List<Map> businessStorePhotos = storeServiceDaoImpl.getBusinessStorePhoto(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStorePhotos == null || businessStorePhotos.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_photo),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessStorePhoto : businessStorePhotos) {
+                flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto);
+            }
+        }
+
+        //商户属性
+        List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info);
+        if(storeCerdentialses != null && storeCerdentialses.size()>0){
+            List<Map> businessStoreCerdentialses = storeServiceDaoImpl.getBusinessStoreCerdentials(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStoreCerdentialses == null || businessStoreCerdentialses.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_cerdentials),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessStoreCerdentials : businessStoreCerdentialses) {
+                flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials);
+            }
+        }
+    }
+
+    /**
+     * 保存商户照片
+     * @param business 业务对象
+     * @param businessStorePhotos 商户照片
+     */
+    private void doBusinessStorePhoto(Business business, JSONArray businessStorePhotos) {
+
+        Map info = null;
+        Map currentStorePhoto = null;
+        for(int businessStorePhotoIndex = 0 ;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) {
+            JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex);
+            Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
+
+            if (businessStorePhoto.getLong("storePhotoId") < 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto);
+            }
+
+            autoSaveDelBusinessStorePhoto(business,businessStorePhoto);
+        }
+    }
+
+    /**
+     * 处理 businessStore 节点
+     * @param business 总的数据节点
+     * @param businessStore 商户节点
+     */
+    private void doBusinessStore(Business business,JSONObject businessStore){
+
+        Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点");
+
+        if(businessStore.getLong("storeId") < 0){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore);
+        }
+        //自动插入DEL
+        autoSaveDelBusinessStore(business,businessStore);
+    }
+
+
+
+    /**
+     * 保存商户属性信息
+     * @param business 当前业务
+     * @param businessStoreAttrs 商户属性
+     */
+    private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreAttrs){
+        JSONObject data = business.getDatas();
+
+        for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){
+            JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex);
+            Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点");
+            if(storeAttr.getLong("attrId") < 0){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr);
+            }
+
+            autoSaveDelBusinessStoreAttr(business,storeAttr);
+        }
+    }
+
+
+    /**
+     * 保存 商户证件 信息
+     * @param business 当前业务
+     * @param businessStoreCerdentialses 商户证件
+     */
+    private void doBusinessStoreCerdentials(Business business, JSONArray businessStoreCerdentialses) {
+
+        Map info = null;
+        Map currentStoreCerdentials = null;
+        for(int businessStoreCerdentialsIndex = 0 ; businessStoreCerdentialsIndex < businessStoreCerdentialses.size() ; businessStoreCerdentialsIndex ++) {
+            JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex);
+            Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
+
+            if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials);
+            }
+
+            autoSaveDelBusinessStoreCerdentials(business,businessStoreCerdentials);
+        }
+    }
+
+    public IStoreServiceDao getStoreServiceDaoImpl() {
+        return storeServiceDaoImpl;
+    }
+
+    public void setStoreServiceDaoImpl(IStoreServiceDao storeServiceDaoImpl) {
+        this.storeServiceDaoImpl = storeServiceDaoImpl;
+    }
+}

+ 82 - 109
StoreService/src/main/java/com/java110/store/listener/SaveStoreInfoListener.java

@@ -2,19 +2,16 @@ package com.java110.store.listener;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.java110.common.constant.ResponseConstant;
 import com.java110.common.constant.ServiceCodeConstant;
 import com.java110.common.constant.StatusConstant;
-import com.java110.common.log.LoggerEngine;
 import com.java110.common.util.Assert;
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
-import com.java110.core.factory.DataTransactionFactory;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.entity.center.Business;
-import com.java110.event.service.BusinessServiceDataFlowEvent;
-import com.java110.event.service.BusinessServiceDataFlowListener;
 import com.java110.store.dao.IStoreServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -28,7 +25,9 @@ import java.util.Map;
  */
 @Java110Listener("saveStoreInfoListener")
 @Transactional
-public class SaveStoreInfoListener extends LoggerEngine implements BusinessServiceDataFlowListener{
+public class SaveStoreInfoListener extends AbstractStoreBusinessServiceDataFlowListener{
+
+    private final static Logger logger = LoggerFactory.getLogger(SaveStoreInfoListener.class);
 
     @Autowired
     IStoreServiceDao storeServiceDaoImpl;
@@ -43,81 +42,46 @@ public class SaveStoreInfoListener extends LoggerEngine implements BusinessServi
         return ServiceCodeConstant.SERVICE_CODE_SAVE_STORE_INFO;
     }
 
-    @Override
-    public void soService(BusinessServiceDataFlowEvent event) {
-        //这里处理业务逻辑数据
-        DataFlowContext dataFlowContext = event.getDataFlowContext();
-        doSaveStoreInfo(dataFlowContext);
-    }
-
     /**
-     * 保存商户信息
-     * 主要保存 businessStore,businessStoreAttr,businessStorePhoto,businessStoreCerdentials信息
-     * @param dataFlowContext 数据流对象
+     * 保存商户信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveStoreInfo(DataFlowContext dataFlowContext){
-        String businessType = dataFlowContext.getOrder().getBusinessType();
-        Business business = dataFlowContext.getCurrentBusiness();
-        // Instance 过程
-        if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(businessType)){
-            doSaveInstanceStoreInfo(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(businessType)){ // Business过程
-            doSaveBusinessStoreInfo(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_DELETE.equals(businessType)){ //撤单过程
-            doDeleteInstanceStoreInfo(dataFlowContext,business);
-        }
-
-        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
-                dataFlowContext.getParamOut()));
-    }
-
-    /**
-     * 撤单
-     * @param business
-     */
-    private void doDeleteInstanceStoreInfo(DataFlowContext dataFlowContext, Business business) {
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
 
-        String bId = business.getbId();
-        //Assert.hasLength(bId,"请求报文中没有包含 bId");
-        Map info = new HashMap();
-        info.put("bId",bId);
-        //商户信息
-        Map storeInfo = storeServiceDaoImpl.getStoreInfo(info);
-        if(storeInfo != null && !storeInfo.isEmpty()){
-            info.put("bId",bId);
-            info.put("storeId",storeInfo.get("store_id").toString());
-            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
-            storeServiceDaoImpl.updateStoreInfoInstance(info);
-            dataFlowContext.addParamOut("storeId",storeInfo.get("store_id"));
+        //处理 businessStore 节点
+        if(data.containsKey("businessStore")){
+            JSONObject businessStore = data.getJSONObject("businessStore");
+            doBusinessStore(business,businessStore);
+            dataFlowContext.addParamOut("storeId",businessStore.getString("storeId"));
         }
 
-        //商户属性
-        List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info);
-        if(storeAttrs != null && storeAttrs.size()>0){
-            storeServiceDaoImpl.updateStoreAttrInstance(info);
+        if(data.containsKey("businessStoreAttr")){
+            JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr");
+            doSaveBusinessStoreAttrs(business,businessStoreAttrs);
         }
 
-        //商户照片
-        List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info);
-        if(storePhotos != null && storePhotos.size()>0){
-            storeServiceDaoImpl.updateStorePhotoInstance(info);
+        if(data.containsKey("businessStorePhoto")){
+            JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto");
+            doBusinessStorePhoto(business,businessStorePhotos);
         }
 
-        //商户属性
-        List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info);
-        if(storeCerdentialses != null && storeCerdentialses.size()>0){
-            storeServiceDaoImpl.updateStoreCerdentailsInstance(info);
+        if(data.containsKey("businessStoreCerdentials")){
+            JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials");
+            doBusinessStoreCerdentials(business,businessStoreCerdentialses);
         }
-
-
     }
 
     /**
-     * instance过程
-     * @param business
+     * business 数据转移到 instance
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveInstanceStoreInfo(DataFlowContext dataFlowContext, Business business) {
-
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
         JSONObject data = business.getDatas();
 
         Map info = new HashMap();
@@ -145,51 +109,48 @@ public class SaveStoreInfoListener extends LoggerEngine implements BusinessServi
         if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){
             storeServiceDaoImpl.saveStoreCerdentialsInstance(info);
         }
-
     }
 
     /**
-     * 保存数据至u_user 表中
-     * @param business
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doComplateUserInfo(DataFlowContext dataFlowContext,Business business) {
-        /*String bId = business.getbId();
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
         Map paramIn = new HashMap();
         paramIn.put("bId",bId);
-        paramIn.put("statusCd",StatusConstant.STATUS_CD_VALID);
-        storeServiceDaoImpl.updateUserInfoInstance(paramIn);
-        storeServiceDaoImpl.updateUserAttrInstance(paramIn);*/
-    }
-
-    /**
-     * 处理商户信息
-     * @param business
-     */
-    private void doSaveBusinessStoreInfo(DataFlowContext dataFlowContext, Business business) {
-
-        JSONObject data = business.getDatas();
-
-        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
-
-        //处理 businessStore 节点
-        if(data.containsKey("businessStore")){
-            JSONObject businessStore = data.getJSONObject("businessStore");
-            doBusinessStore(business,businessStore);
-            dataFlowContext.addParamOut("storeId",businessStore.getString("storeId"));
+        paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+        //商户信息
+        Map storeInfo = storeServiceDaoImpl.getStoreInfo(info);
+        if(storeInfo != null && !storeInfo.isEmpty()){
+            paramIn.put("storeId",storeInfo.get("store_id").toString());
+            storeServiceDaoImpl.updateStoreInfoInstance(paramIn);
+            dataFlowContext.addParamOut("storeId",storeInfo.get("store_id"));
         }
 
-        if(data.containsKey("businessStorePhoto")){
-            JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto");
-            doBusinessStorePhoto(business,businessStorePhotos);
+        //商户属性
+        List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info);
+        if(storeAttrs != null && storeAttrs.size()>0){
+            storeServiceDaoImpl.updateStoreAttrInstance(paramIn);
         }
 
-        if(data.containsKey("businessStoreCerdentials")){
-            JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials");
-            doBusinessStoreCerdentials(business,businessStoreCerdentialses);
+        //商户照片
+        List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info);
+        if(storePhotos != null && storePhotos.size()>0){
+            storeServiceDaoImpl.updateStorePhotoInstance(paramIn);
         }
 
-
-        //storeServiceDaoImpl.saveUserInfoInstance(businessUser);
+        //商户属性
+        List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info);
+        if(storeCerdentialses != null && storeCerdentialses.size()>0){
+            storeServiceDaoImpl.updateStoreCerdentailsInstance(paramIn);
+        }
     }
 
     /**
@@ -233,11 +194,7 @@ public class SaveStoreInfoListener extends LoggerEngine implements BusinessServi
         businessStore.put("operate", StatusConstant.OPERATE_ADD);
         //保存商户信息
         storeServiceDaoImpl.saveBusinessStoreInfo(businessStore);
-        //保存 商户属性信息
-        if(businessStore.containsKey("businessStoreAttr")){
-            JSONArray businessStoreAttrs = businessStore.getJSONArray("businessStoreAttr");
-            doSaveBusinessStoreAttrs(business,businessStoreAttrs);
-        }
+
     }
 
 
@@ -300,13 +257,29 @@ public class SaveStoreInfoListener extends LoggerEngine implements BusinessServi
         String storeId = GenerateCodeFactory.getStoreId();
         JSONObject businessStore = data.getJSONObject("businessStore");
         businessStore.put("storeId",storeId);
+        //刷商户属性
+        if(data.containsKey("businessStoreAttr")) {
+            JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr");
+            for(int businessStoreAttrIndex = 0;businessStoreAttrIndex < businessStoreAttrs.size();businessStoreAttrIndex++) {
+                JSONObject businessStoreAttr = businessStoreAttrs.getJSONObject(businessStoreAttrIndex);
+                businessStoreAttr.put("storeId", storeId);
+            }
+        }
+        //刷 是商户照片 的 storeId
         if(data.containsKey("businessStorePhoto")) {
-            JSONObject businessStorePhoto = data.getJSONObject("businessStorePhoto");
-            businessStorePhoto.put("storeId", storeId);
+            JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto");
+            for(int businessStorePhotoIndex = 0;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) {
+                JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex);
+                businessStorePhoto.put("storeId", storeId);
+            }
         }
+        //刷 商户证件 的storeId
         if(data.containsKey("businessStoreCerdentials")) {
-            JSONObject businessStoreCerdentials = data.getJSONObject("businessStoreCerdentials");
-            businessStoreCerdentials.put("storeId", storeId);
+            JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials");
+            for(int businessStoreCerdentialsIndex = 0;businessStoreCerdentialsIndex < businessStoreCerdentialses.size();businessStoreCerdentialsIndex++) {
+                JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex);
+                businessStoreCerdentials.put("storeId", storeId);
+            }
         }
     }
 

+ 322 - 0
StoreService/src/main/java/com/java110/store/listener/UpdateStoreInfoListener.java

@@ -0,0 +1,322 @@
+package com.java110.store.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.store.dao.IStoreServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 修改商户信息 侦听
+ *
+ * 处理节点
+ * 1、businessStore:{} 商户基本信息节点
+ * 2、businessStoreAttr:[{}] 商户属性信息节点
+ * 3、businessStorePhoto:[{}] 商户照片信息节点
+ * 4、businessStoreCerdentials:[{}] 商户证件信息节点
+ * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E4%BF%AE%E6%94%B9%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("updateStoreInfoListener")
+@Transactional
+public class UpdateStoreInfoListener extends AbstractStoreBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(UpdateStoreInfoListener.class);
+    @Autowired
+    IStoreServiceDao storeServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_UPDATE_STORE_INFO;
+    }
+
+    /**
+     * business过程
+     * @param dataFlowContext
+     * @param business
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessStore 节点
+        if(data.containsKey("businessStore")){
+            JSONObject businessStore = data.getJSONObject("businessStore");
+            doBusinessStore(business,businessStore);
+            dataFlowContext.addParamOut("storeId",businessStore.getString("storeId"));
+        }
+
+        if(data.containsKey("businessStoreAttr")){
+            JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr");
+            doSaveBusinessStoreAttrs(business,businessStoreAttrs);
+        }
+
+        if(data.containsKey("businessStorePhoto")){
+            JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto");
+            doBusinessStorePhoto(business,businessStorePhotos);
+        }
+
+        if(data.containsKey("businessStoreCerdentials")){
+            JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials");
+            doBusinessStoreCerdentials(business,businessStoreCerdentialses);
+        }
+    }
+
+
+    /**
+     * business to instance 过程
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_ADD);
+
+        //商户信息
+        Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(info);
+        if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) {
+            flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID);
+            storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo);
+            dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id"));
+        }
+        //商户属性
+        List<Map> businessStoreAttrs = storeServiceDaoImpl.getBusinessStoreAttrs(info);
+        if(businessStoreAttrs != null && businessStoreAttrs.size() > 0) {
+            for(Map businessStoreAttr : businessStoreAttrs) {
+                flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr);
+            }
+        }
+        //商户照片
+        List<Map> businessStorePhotos = storeServiceDaoImpl.getBusinessStorePhoto(info);
+        if(businessStorePhotos != null && businessStorePhotos.size() >0){
+            for(Map businessStorePhoto : businessStorePhotos) {
+                flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto);
+            }
+        }
+        //商户证件
+        List<Map> businessStoreCerdentialses = storeServiceDaoImpl.getBusinessStoreCerdentials(info);
+        if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){
+            for(Map businessStoreCerdentials : businessStoreCerdentialses) {
+                flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials);
+            }
+        }
+    }
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+        //商户信息
+        Map storeInfo = storeServiceDaoImpl.getStoreInfo(info);
+        if(storeInfo != null && !storeInfo.isEmpty()){
+
+            //商户信息
+            Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStoreInfo == null || businessStoreInfo.isEmpty()){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store),程序内部异常,请检查! "+delInfo);
+            }
+
+            flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID);
+            storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo);
+            dataFlowContext.addParamOut("storeId",storeInfo.get("store_id"));
+        }
+
+        //商户属性
+        List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info);
+        if(storeAttrs != null && storeAttrs.size()>0){
+
+            List<Map> businessStoreAttrs = storeServiceDaoImpl.getBusinessStoreAttrs(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStoreAttrs == null || businessStoreAttrs.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_attr),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessStoreAttr : businessStoreAttrs) {
+                flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr);
+            }
+        }
+
+        //商户照片
+        List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info);
+        if(storePhotos != null && storePhotos.size()>0){
+            List<Map> businessStorePhotos = storeServiceDaoImpl.getBusinessStorePhoto(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStorePhotos == null || businessStorePhotos.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_photo),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessStorePhoto : businessStorePhotos) {
+                flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto);
+            }
+        }
+
+        //商户属性
+        List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info);
+        if(storeCerdentialses != null && storeCerdentialses.size()>0){
+            List<Map> businessStoreCerdentialses = storeServiceDaoImpl.getBusinessStoreCerdentials(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessStoreCerdentialses == null || businessStoreCerdentialses.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_cerdentials),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessStoreCerdentials : businessStoreCerdentialses) {
+                flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_VALID);
+                storeServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials);
+            }
+        }
+    }
+
+    /**
+     * 保存商户照片
+     * @param business 业务对象
+     * @param businessStorePhotos 商户照片
+     */
+    private void doBusinessStorePhoto(Business business, JSONArray businessStorePhotos) {
+
+
+        for(int businessStorePhotoIndex = 0 ;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) {
+            JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex);
+            Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
+
+            if (businessStorePhoto.getLong("storePhotoId") < 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto);
+            }
+
+            //自动保存DEL信息
+            autoSaveDelBusinessStorePhoto(business,businessStorePhoto);
+
+            businessStorePhoto.put("bId", business.getbId());
+            businessStorePhoto.put("operate", StatusConstant.OPERATE_ADD);
+            //保存商户信息
+            storeServiceDaoImpl.saveBusinessStorePhoto(businessStorePhoto);
+        }
+    }
+
+    /**
+     * 处理 businessStore 节点
+     * @param business 总的数据节点
+     * @param businessStore 商户节点
+     */
+    private void doBusinessStore(Business business,JSONObject businessStore){
+
+        Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点");
+
+        if(businessStore.getLong("storeId") < 0){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore);
+        }
+        //自动保存DEL
+        autoSaveDelBusinessStore(business,businessStore);
+
+        businessStore.put("bId",business.getbId());
+        businessStore.put("operate", StatusConstant.OPERATE_ADD);
+        //保存商户信息
+        storeServiceDaoImpl.saveBusinessStoreInfo(businessStore);
+
+    }
+
+
+
+    /**
+     * 保存商户属性信息
+     * @param business 当前业务
+     * @param businessStoreAttrs 商户属性
+     */
+    private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreAttrs){
+        JSONObject data = business.getDatas();
+
+
+        for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){
+            JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex);
+            Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点");
+            if(storeAttr.getLong("attrId") < 0){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr);
+            }
+            //自动保存DEL数据
+            autoSaveDelBusinessStoreAttr(business,storeAttr);
+
+            storeAttr.put("bId",business.getbId());
+            storeAttr.put("storeId",storeAttr.getString("storeId"));
+            storeAttr.put("operate", StatusConstant.OPERATE_ADD);
+
+            storeServiceDaoImpl.saveBusinessStoreAttr(storeAttr);
+        }
+    }
+
+
+    /**
+     * 保存 商户证件 信息
+     * @param business 当前业务
+     * @param businessStoreCerdentialses 商户证件
+     */
+    private void doBusinessStoreCerdentials(Business business, JSONArray businessStoreCerdentialses) {
+
+        for(int businessStoreCerdentialsIndex = 0 ; businessStoreCerdentialsIndex < businessStoreCerdentialses.size() ; businessStoreCerdentialsIndex ++) {
+            JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex);
+            Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
+
+            if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials);
+            }
+
+            autoSaveDelBusinessStoreCerdentials(business,businessStoreCerdentials);
+
+            businessStoreCerdentials.put("bId", business.getbId());
+            businessStoreCerdentials.put("operate", StatusConstant.OPERATE_ADD);
+            //保存商户信息
+            storeServiceDaoImpl.saveBusinessStoreCerdentials(businessStoreCerdentials);
+        }
+    }
+
+    public IStoreServiceDao getStoreServiceDaoImpl() {
+        return storeServiceDaoImpl;
+    }
+
+    public void setStoreServiceDaoImpl(IStoreServiceDao storeServiceDaoImpl) {
+        this.storeServiceDaoImpl = storeServiceDaoImpl;
+    }
+
+
+
+}

+ 44 - 65
UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java

@@ -13,6 +13,7 @@ import com.java110.core.context.DataFlowContext;
 import com.java110.core.factory.DataTransactionFactory;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
 import com.java110.event.service.BusinessServiceDataFlowEvent;
 import com.java110.event.service.BusinessServiceDataFlowListener;
 import com.java110.user.dao.IUserServiceDao;
@@ -32,7 +33,7 @@ import java.util.Map;
  */
 @Java110Listener(name = "saveUserAddressListener")
 @Transactional
-public class SaveUserAddressListener implements BusinessServiceDataFlowListener{
+public class SaveUserAddressListener extends AbstractBusinessServiceDataFlowListener {
 
     private final static Logger logger = LoggerFactory.getLogger(SaveUserAddressListener.class);
 
@@ -49,58 +50,40 @@ public class SaveUserAddressListener implements BusinessServiceDataFlowListener{
         return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_ADDRESS;
     }
 
+    /**
+     * 用户地址信息保存至 business表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
     @Override
-    public void soService(BusinessServiceDataFlowEvent event) {
-        //这里处理业务逻辑数据
-        DataFlowContext dataFlowContext = event.getDataFlowContext();
-        doSaveUserAddress(dataFlowContext);
-    }
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
 
-    private void doSaveUserAddress(DataFlowContext dataFlowContext){
-        String businessType = dataFlowContext.getOrder().getBusinessType();
-        Business business = dataFlowContext.getCurrentBusiness();
-        //Assert.hasLength(business.getbId(),"bId 不能为空");
-        // Instance 过程
-        if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(businessType)){
-            //doComplateUserInfo(business);
-            doSaveInstanceUserAddress(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(businessType)){ // Business过程
-            doSaveBusinessUserAddress(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_DELETE.equals(businessType)){ //撤单过程
-            doDeleteInstanceUserAddress(dataFlowContext,business);
-        }
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
 
-        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
-                dataFlowContext.getParamOut()));
-    }
+        Assert.jsonObjectHaveKey(data,"businessUserAddress","datas 节点下没有包含 businessUser 节点");
 
-    /**
-     * 撤单
-     * @param business
-     */
-    private void doDeleteInstanceUserAddress(DataFlowContext dataFlowContext, Business business) {
+        JSONObject businessUser = data.getJSONObject("businessUserAddress");
 
-        String bId = business.getbId();
-        //Assert.hasLength(bId,"请求报文中没有包含 bId");
-        Map info = new HashMap();
-        info.put("bId",bId);
-        Map userAddress = userServiceDaoImpl.queryBusinessUserAddress(info);
-        if(userAddress != null && !userAddress.isEmpty()){
-            info.put("bId",bId);
-            info.put("userId",userAddress.get("user_id").toString());
-            info.put("addressId",userAddress.get("address_id").toString());
-            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
-            userServiceDaoImpl.updateUserAddressInstance(userAddress);
-            dataFlowContext.addParamOut("userId",userAddress.get("user_id"));
+        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
+
+        if(businessUser.getLong("userId") <= 0){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"用户地址(saveUserAddress)保存失败,userId 不正确"+businessUser.getInteger("userId"));
         }
+        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
+        businessUser.put("bId",business.getbId());
+        businessUser.put("operate", StatusConstant.OPERATE_ADD);
+        //保存用户信息
+        userServiceDaoImpl.saveBusinessUserAddress(businessUser);
     }
 
     /**
-     * instance过程
-     * @param business
+     * 保存地址信息至instance
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveInstanceUserAddress(DataFlowContext dataFlowContext, Business business) {
-
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
         JSONObject data = business.getDatas();
 
         Map info = new HashMap();
@@ -114,33 +97,29 @@ public class SaveUserAddressListener implements BusinessServiceDataFlowListener{
         }
 
         throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,"当前数据未找到business 数据"+info);
+
     }
 
     /**
-     * 处理用户地址信息
-     * @param business 业务信息
+     * 作废用户地址信息(instance)
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveBusinessUserAddress(DataFlowContext dataFlowContext, Business business) {
-
-        JSONObject data = business.getDatas();
-
-        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
-
-        Assert.jsonObjectHaveKey(data,"businessUserAddress","datas 节点下没有包含 businessUser 节点");
-
-        JSONObject businessUser = data.getJSONObject("businessUserAddress");
-
-        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
-
-        if(businessUser.getLong("userId") <= 0){
-           throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"用户地址(saveUserAddress)保存失败,userId 不正确"+businessUser.getInteger("userId"));
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        Map userAddress = userServiceDaoImpl.queryBusinessUserAddress(info);
+        if(userAddress != null && !userAddress.isEmpty()){
+            info.put("bId",bId);
+            info.put("userId",userAddress.get("user_id").toString());
+            info.put("addressId",userAddress.get("address_id").toString());
+            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+            userServiceDaoImpl.updateUserAddressInstance(userAddress);
+            dataFlowContext.addParamOut("userId",userAddress.get("user_id"));
         }
-        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
-        businessUser.put("bId",business.getbId());
-        businessUser.put("operate", StatusConstant.OPERATE_ADD);
-        //保存用户信息
-        userServiceDaoImpl.saveBusinessUserAddress(businessUser);
-
     }
 
     public IUserServiceDao getUserServiceDaoImpl() {

+ 46 - 66
UserService/src/main/java/com/java110/user/listener/SaveUserCredentialsListener.java

@@ -11,6 +11,7 @@ import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
 import com.java110.core.factory.DataTransactionFactory;
 import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
 import com.java110.event.service.BusinessServiceDataFlowEvent;
 import com.java110.event.service.BusinessServiceDataFlowListener;
 import com.java110.user.dao.IUserServiceDao;
@@ -24,12 +25,12 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * 保存 用户信息 侦听
+ * 保存 用户证件 侦听
  * Created by wuxw on 2018/5/18.
  */
 @Java110Listener("saveUserCredentialsListener")
 @Transactional
-public class SaveUserCredentialsListener extends LoggerEngine implements BusinessServiceDataFlowListener{
+public class SaveUserCredentialsListener extends AbstractBusinessServiceDataFlowListener {
 
     private final static Logger logger = LoggerFactory.getLogger(SaveUserCredentialsListener.class);
 
@@ -46,58 +47,41 @@ public class SaveUserCredentialsListener extends LoggerEngine implements Busines
         return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_CREDENTIALS;
     }
 
+
+    /**
+     * 保存用户证件信息
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
     @Override
-    public void soService(BusinessServiceDataFlowEvent event) {
-        //这里处理业务逻辑数据
-        DataFlowContext dataFlowContext = event.getDataFlowContext();
-        doSaveUserCredentials(dataFlowContext);
-    }
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
 
-    private void doSaveUserCredentials(DataFlowContext dataFlowContext){
-        String businessType = dataFlowContext.getOrder().getBusinessType();
-        Business business = dataFlowContext.getCurrentBusiness();
-        //Assert.hasLength(business.getbId(),"bId 不能为空");
-        // Instance 过程
-        if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(businessType)){
-            //doComplateUserInfo(business);
-            doSaveInstanceUserCredentials(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(businessType)){ // Business过程
-            doSaveBusinessUserCredentials(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_DELETE.equals(businessType)){ //撤单过程
-            doDeleteInstanceUserCredentials(dataFlowContext,business);
-        }
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
 
-        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
-                dataFlowContext.getParamOut()));
-    }
+        Assert.jsonObjectHaveKey(data,"businessUserCredentials","datas 节点下没有包含 businessUser 节点");
 
-    /**
-     * 撤单
-     * @param business
-     */
-    private void doDeleteInstanceUserCredentials(DataFlowContext dataFlowContext, Business business) {
+        JSONObject businessUser = data.getJSONObject("businessUserCredentials");
 
-        String bId = business.getbId();
-        //Assert.hasLength(bId,"请求报文中没有包含 bId");
-        Map info = new HashMap();
-        info.put("bId",bId);
-        Map userCredentials = userServiceDaoImpl.queryBusinessUserCredentials(info);
-        if(userCredentials != null && !userCredentials.isEmpty()){
-            info.put("bId",bId);
-            info.put("userId",userCredentials.get("user_id").toString());
-            info.put("credentialsId",userCredentials.get("credentials_id").toString());
-            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
-            userServiceDaoImpl.updateUserCredentialsInstance(userCredentials);
-            dataFlowContext.addParamOut("userId",userCredentials.get("user_id"));
+        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
+
+        if(businessUser.getLong("userId") <= 0){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"用户打标(saveUserCredentials)保存失败,userId 不正确"+businessUser.getInteger("userId"));
         }
+        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
+        businessUser.put("bId",business.getbId());
+        businessUser.put("operate", StatusConstant.OPERATE_ADD);
+        //保存用户信息
+        userServiceDaoImpl.saveBusinessUserCredentials(businessUser);
     }
 
     /**
-     * instance过程
-     * @param business
+     * 保存用户证件信息至 instance中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveInstanceUserCredentials(DataFlowContext dataFlowContext, Business business) {
-
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
         JSONObject data = business.getDatas();
 
         Map info = new HashMap();
@@ -111,33 +95,29 @@ public class SaveUserCredentialsListener extends LoggerEngine implements Busines
         }
 
         throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,"当前数据未找到business 数据"+info);
+
     }
 
     /**
-     * 处理用户打标信息
-     * @param business 业务信息
+     * 作废用户证件信息
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveBusinessUserCredentials(DataFlowContext dataFlowContext, Business business) {
-
-        JSONObject data = business.getDatas();
-
-        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
-
-        Assert.jsonObjectHaveKey(data,"businessUserCredentials","datas 节点下没有包含 businessUser 节点");
-
-        JSONObject businessUser = data.getJSONObject("businessUserCredentials");
-
-        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
-
-        if(businessUser.getLong("userId") <= 0){
-            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"用户打标(saveUserCredentials)保存失败,userId 不正确"+businessUser.getInteger("userId"));
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        Map userCredentials = userServiceDaoImpl.queryBusinessUserCredentials(info);
+        if(userCredentials != null && !userCredentials.isEmpty()){
+            info.put("bId",bId);
+            info.put("userId",userCredentials.get("user_id").toString());
+            info.put("credentialsId",userCredentials.get("credentials_id").toString());
+            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+            userServiceDaoImpl.updateUserCredentialsInstance(userCredentials);
+            dataFlowContext.addParamOut("userId",userCredentials.get("user_id"));
         }
-        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
-        businessUser.put("bId",business.getbId());
-        businessUser.put("operate", StatusConstant.OPERATE_ADD);
-        //保存用户信息
-        userServiceDaoImpl.saveBusinessUserCredentials(businessUser);
-
     }
 
     public IUserServiceDao getUserServiceDaoImpl() {

+ 59 - 106
UserService/src/main/java/com/java110/user/listener/SaveUserInfoListener.java

@@ -8,15 +8,17 @@ import com.java110.common.constant.StatusConstant;
 import com.java110.common.log.LoggerEngine;
 import com.java110.common.util.Assert;
 import com.java110.core.annotation.Java110Listener;
-import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.context.DataFlowContext;
 import com.java110.core.factory.DataTransactionFactory;
+import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
 import com.java110.event.service.BusinessServiceDataFlowEvent;
 import com.java110.event.service.BusinessServiceDataFlowListener;
 import com.java110.user.dao.IUserServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.HashMap;
@@ -29,7 +31,9 @@ import java.util.Map;
  */
 @Java110Listener("saveUserInfoListener")
 @Transactional
-public class SaveUserInfoListener extends LoggerEngine implements BusinessServiceDataFlowListener{
+public class SaveUserInfoListener  extends AbstractBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(SaveUserInfoListener.class);
 
     @Autowired
     IUserServiceDao userServiceDaoImpl;
@@ -44,78 +48,49 @@ public class SaveUserInfoListener extends LoggerEngine implements BusinessServic
         return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_INFO;
     }
 
-    @Override
-    public void soService(BusinessServiceDataFlowEvent event) {
-        //这里处理业务逻辑数据
-        DataFlowContext dataFlowContext = event.getDataFlowContext();
-        doSaveUserInfo(dataFlowContext);
-    }
-
-    private void doSaveUserInfo(DataFlowContext dataFlowContext){
-        String businessType = dataFlowContext.getOrder().getBusinessType();
-        Business business = dataFlowContext.getCurrentBusiness();
-        //Assert.hasLength(business.getbId(),"bId 不能为空");
-        // Instance 过程
-        if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(businessType)){
-            //doComplateUserInfo(business);
-            doSaveInstanceUserInfo(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(businessType)){ // Business过程
-            doSaveBusinessUserInfo(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_DELETE.equals(businessType)){ //撤单过程
-            doDeleteInstanceUserInfo(dataFlowContext,business);
-        }
-
-        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
-                dataFlowContext.getParamOut()));
-    }
 
     /**
-     * 撤单
-     * @param business
+     * 保存用户信息至 business表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doDeleteInstanceUserInfo(DataFlowContext dataFlowContext,Business business) {
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
 
-        String bId = business.getbId();
-        //Assert.hasLength(bId,"请求报文中没有包含 bId");
-        Map info = new HashMap();
-        info.put("bId",bId);
-        Map userInfo = userServiceDaoImpl.queryUserInfo(info);
-        if(userInfo != null && !userInfo.isEmpty()){
-            info.put("bId",bId);
-            info.put("userId",userInfo.get("user_id").toString());
-            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
-            userServiceDaoImpl.updateUserInfoInstance(userInfo);
-            dataFlowContext.addParamOut("userId",userInfo.get("user_id"));
-        }
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
 
-        info.clear();
-        info.put("bId",bId);
+        Assert.jsonObjectHaveKey(data,"businessUser","datas 节点下没有包含 businessUser 节点");
 
-        List<Map> userAttrs = userServiceDaoImpl.queryUserInfoAttrs(info);
+        JSONObject businessUser = data.getJSONObject("businessUser");
 
-        if(userAttrs != null && userAttrs.size() >0){
-            info.put("bId",bId);
-            //info.put("userId",userInfo.get("user_id").toString());
-            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
-            userServiceDaoImpl.updateUserAttrInstance(info);
-        }
+        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
 
+        if(businessUser.getInteger("userId") < 0){
+            //生成userId
+            String userId = GenerateCodeFactory.getUserId();
+            businessUser.put("userId",userId);
+        }
+        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
+        businessUser.put("bId",business.getbId());
+        businessUser.put("operate", StatusConstant.OPERATE_ADD);
+        //保存用户信息
+        userServiceDaoImpl.saveBusinessUserInfo(businessUser);
 
+        if(businessUser.containsKey("businessUserAttr")){
+            doSaveUserAttrs(business);
+        }
     }
 
     /**
-     * instance过程
-     * @param business
+     * 将 business的用户信息 保存至 instance表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveInstanceUserInfo(DataFlowContext dataFlowContext,Business business) {
-
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
         JSONObject data = business.getDatas();
 
-        //Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
-
-        //Assert.jsonObjectHaveKey(data,"businessUser","datas 节点下没有包含 businessUser 节点");
-
-        //JSONObject businessUser = data.getJSONObject("businessUser");
         Map info = new HashMap();
         info.put("bId",business.getbId());
         info.put("operate",StatusConstant.OPERATE_ADD);
@@ -129,57 +104,39 @@ public class SaveUserInfoListener extends LoggerEngine implements BusinessServic
             userServiceDaoImpl.saveUserAttrInstance(businessUser);
         }
 
-
     }
 
     /**
-     * 保存数据至u_user 表中
-     * @param business
+     * 将instance 作废
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doComplateUserInfo(DataFlowContext dataFlowContext,Business business) {
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
         String bId = business.getbId();
-        Map paramIn = new HashMap();
-        paramIn.put("bId",bId);
-        paramIn.put("statusCd",StatusConstant.STATUS_CD_VALID);
-        userServiceDaoImpl.updateUserInfoInstance(paramIn);
-        userServiceDaoImpl.updateUserAttrInstance(paramIn);
-    }
-
-    /**
-     * 处理用户信息
-     * @param business
-     */
-    private void doSaveBusinessUserInfo(DataFlowContext dataFlowContext,Business business) {
-
-        JSONObject data = business.getDatas();
-
-        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
-
-        Assert.jsonObjectHaveKey(data,"businessUser","datas 节点下没有包含 businessUser 节点");
-
-        JSONObject businessUser = data.getJSONObject("businessUser");
-
-        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
-
-        if(businessUser.getInteger("userId") < 0){
-            //生成userId
-            String userId = GenerateCodeFactory.getUserId();
-            businessUser.put("userId",userId);
-        }
-        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
-        businessUser.put("bId",business.getbId());
-        businessUser.put("operate", StatusConstant.OPERATE_ADD);
-        //保存用户信息
-        userServiceDaoImpl.saveBusinessUserInfo(businessUser);
-
-        if(businessUser.containsKey("businessUserAttr")){
-            doSaveUserAttrs(business);
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        Map userInfo = userServiceDaoImpl.queryUserInfo(info);
+        if(userInfo != null && !userInfo.isEmpty()){
+            info.put("bId",bId);
+            info.put("userId",userInfo.get("user_id").toString());
+            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+            userServiceDaoImpl.updateUserInfoInstance(info);
+            dataFlowContext.addParamOut("userId",userInfo.get("user_id"));
         }
 
-        //userServiceDaoImpl.saveUserInfoInstance(businessUser);
-
+        info.clear();
+        info.put("bId",bId);
 
+        List<Map> userAttrs = userServiceDaoImpl.queryUserInfoAttrs(info);
 
+        if(userAttrs != null && userAttrs.size() >0){
+            info.put("bId",bId);
+            //info.put("userId",userInfo.get("user_id").toString());
+            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+            userServiceDaoImpl.updateUserAttrInstance(info);
+        }
     }
 
     private void doSaveUserAttrs(Business business){
@@ -201,10 +158,6 @@ public class SaveUserInfoListener extends LoggerEngine implements BusinessServic
 
             userServiceDaoImpl.saveBusinessUserAttr(userAttr);
         }
-
-        /*JSONObject attrInstance = new JSONObject();
-        attrInstance.put("bId",business.getbId());
-        userServiceDaoImpl.saveUserAttrInstance(attrInstance);*/
     }
 
     public IUserServiceDao getUserServiceDaoImpl() {

+ 43 - 65
UserService/src/main/java/com/java110/user/listener/SaveUserTagListener.java

@@ -13,6 +13,7 @@ import com.java110.core.context.DataFlowContext;
 import com.java110.core.factory.DataTransactionFactory;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.entity.center.Business;
+import com.java110.event.service.AbstractBusinessServiceDataFlowListener;
 import com.java110.event.service.BusinessServiceDataFlowEvent;
 import com.java110.event.service.BusinessServiceDataFlowListener;
 import com.java110.user.dao.IUserServiceDao;
@@ -32,7 +33,7 @@ import java.util.Map;
  */
 @Java110Listener("saveUserTagListener")
 @Transactional
-public class SaveUserTagListener extends LoggerEngine implements BusinessServiceDataFlowListener{
+public class SaveUserTagListener extends AbstractBusinessServiceDataFlowListener {
 
     private final static Logger logger = LoggerFactory.getLogger(SaveUserTagListener.class);
 
@@ -49,58 +50,40 @@ public class SaveUserTagListener extends LoggerEngine implements BusinessService
         return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_TAG;
     }
 
+    /**
+     * 用户打标信息保存至 business表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
     @Override
-    public void soService(BusinessServiceDataFlowEvent event) {
-        //这里处理业务逻辑数据
-        DataFlowContext dataFlowContext = event.getDataFlowContext();
-        doSaveUserTag(dataFlowContext);
-    }
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
 
-    private void doSaveUserTag(DataFlowContext dataFlowContext){
-        String businessType = dataFlowContext.getOrder().getBusinessType();
-        Business business = dataFlowContext.getCurrentBusiness();
-        //Assert.hasLength(business.getbId(),"bId 不能为空");
-        // Instance 过程
-        if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(businessType)){
-            //doComplateUserInfo(business);
-            doSaveInstanceUserTag(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(businessType)){ // Business过程
-            doSaveBusinessUserTag(dataFlowContext,business);
-        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_DELETE.equals(businessType)){ //撤单过程
-            doDeleteInstanceUserTag(dataFlowContext,business);
-        }
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
 
-        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
-                dataFlowContext.getParamOut()));
-    }
+        Assert.jsonObjectHaveKey(data,"businessUserTag","datas 节点下没有包含 businessUser 节点");
 
-    /**
-     * 撤单
-     * @param business
-     */
-    private void doDeleteInstanceUserTag(DataFlowContext dataFlowContext, Business business) {
+        JSONObject businessUser = data.getJSONObject("businessUserTag");
 
-        String bId = business.getbId();
-        //Assert.hasLength(bId,"请求报文中没有包含 bId");
-        Map info = new HashMap();
-        info.put("bId",bId);
-        Map userTag = userServiceDaoImpl.queryBusinessUserTag(info);
-        if(userTag != null && !userTag.isEmpty()){
-            info.put("bId",bId);
-            info.put("userId",userTag.get("user_id").toString());
-            info.put("tagId",userTag.get("tag_id").toString());
-            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
-            userServiceDaoImpl.updateUserTagInstance(userTag);
-            dataFlowContext.addParamOut("userId",userTag.get("user_id"));
+        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
+
+        if(businessUser.getLong("userId") <= 0){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"用户打标(saveUserTag)保存失败,userId 不正确"+businessUser.getInteger("userId"));
         }
+        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
+        businessUser.put("bId",business.getbId());
+        businessUser.put("operate", StatusConstant.OPERATE_ADD);
+        //保存用户信息
+        userServiceDaoImpl.saveBusinessUserTag(businessUser);
     }
 
     /**
-     * instance过程
-     * @param business
+     * 用户打标信息保存至 Instance中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveInstanceUserTag(DataFlowContext dataFlowContext, Business business) {
-
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
         JSONObject data = business.getDatas();
 
         Map info = new HashMap();
@@ -117,30 +100,25 @@ public class SaveUserTagListener extends LoggerEngine implements BusinessService
     }
 
     /**
-     * 处理用户打标信息
-     * @param business 业务信息
+     * 作废 用户打标信息
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
      */
-    private void doSaveBusinessUserTag(DataFlowContext dataFlowContext, Business business) {
-
-        JSONObject data = business.getDatas();
-
-        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
-
-        Assert.jsonObjectHaveKey(data,"businessUserTag","datas 节点下没有包含 businessUser 节点");
-
-        JSONObject businessUser = data.getJSONObject("businessUserTag");
-
-        Assert.jsonObjectHaveKey(businessUser,"userId","businessUser 节点下没有包含 userId 节点");
-
-        if(businessUser.getLong("userId") <= 0){
-            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"用户打标(saveUserTag)保存失败,userId 不正确"+businessUser.getInteger("userId"));
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        Map userTag = userServiceDaoImpl.queryBusinessUserTag(info);
+        if(userTag != null && !userTag.isEmpty()){
+            info.put("bId",bId);
+            info.put("userId",userTag.get("user_id").toString());
+            info.put("tagId",userTag.get("tag_id").toString());
+            info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+            userServiceDaoImpl.updateUserTagInstance(userTag);
+            dataFlowContext.addParamOut("userId",userTag.get("user_id"));
         }
-        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
-        businessUser.put("bId",business.getbId());
-        businessUser.put("operate", StatusConstant.OPERATE_ADD);
-        //保存用户信息
-        userServiceDaoImpl.saveBusinessUserTag(businessUser);
-
     }
 
     public IUserServiceDao getUserServiceDaoImpl() {

+ 10 - 0
java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java

@@ -90,6 +90,16 @@ public class ServiceCodeConstant {
      */
     public static final String SERVICE_CODE_SAVE_STORE_INFO = "save.store.info";
 
+    /**
+     * 修改商户信息
+     */
+    public static final String SERVICE_CODE_UPDATE_STORE_INFO = "update.store.info";
+
+    /**
+     * 删除商户信息
+     */
+    public static final String SERVICE_CODE_DELETE_STORE_INFO = "delete.store.info";
+
 
 
 

+ 85 - 5
java110-config/src/main/resources/mapper/store/StoreServiceDaoImplMapper.xml

@@ -124,7 +124,11 @@
     <select id="getStoreInfo" parameterType="Map" resultType="Map">
         select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd
         from s_store s
-        where s.status_cd = '0'
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and s.status_cd = #{statusCd}
+        </if>
+
         <if test="bId != null and bId !=''">
             and s.b_id = #{bId}
         </if>
@@ -137,20 +141,30 @@
     <select id="getStoreAttr" parameterType="Map" resultType="Map">
         select sa.b_id,sa.attr_id,sa.store_id,sa.spec_cd,sa.value,sa.status_cd
         from s_store_attr sa
-        where sa.status_cd = '0'
+        where
+        1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sa.status_cd = #{statusCd}
+        </if>
         <if test="bId != null and bId !=''">
             and sa.b_id = #{bId}
         </if>
         <if test="storeId != null and storeId !=''">
             and sa.store_id = #{storeId}
         </if>
+        <if test="attrId != null and attrId != ''">
+            and sa.attr_id = #{attrId}
+        </if>
     </select>
 
     <!-- 查询商户照片信息 add by wuxw 2018-07-03 -->
     <select id="getStorePhoto" parameterType="Map" resultType="Map">
         select sp.store_photo_id,sp.b_id,sp.store_id,sp.store_photo_type_cd,sp.photo,sp.status_cd
         from s_store_photo sp
-        where sp.status_cd = '0'
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sp.status_cd = #{statusCd}
+        </if>
         <if test="bId != null and bId !=''">
             and sp.b_id = #{bId}
         </if>
@@ -163,7 +177,10 @@
     <select id="getStoreCerdentials" parameterType="Map" resultType="Map">
         select sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.status_cd
         from s_store_cerdentials sc
-        where sc.status_cd = '0'
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sc.status_cd = #{statusCd}
+        </if>
         <if test="bId != null and bId !=''">
             and sc.b_id = #{bId}
         </if>
@@ -176,6 +193,33 @@
     <!-- 修改商户信息 add by wuxw 2018-07-03 -->
     <update id="updateStoreInfoInstance" parameterType="Map">
         update s_store s set s.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,s.b_id = #{newBId}
+        </if>
+        <if test="userId != null and userId != ''">
+            ,s.user_id = #{userId}
+        </if>
+        <if test="name != null and name != ''">
+            ,s.name = #{name}
+        </if>
+        <if test="address != null and address != ''">
+            ,s.address = #{address}
+        </if>
+        <if test="tel != null and tel != ''">
+            ,s.tel = #{tel}
+        </if>
+        <if test="storeTypeCd != null and storeTypeCd != ''">
+            ,s.store_type_cd = #{storeTypeCd}
+        </if>
+        <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
+            ,s.nearby_landmarks = #{nearbyLandmarks}
+        </if>
+        <if test="mapX != null and mapX != ''">
+            ,s.map_x = #{mapX}
+        </if>
+        <if test="mapY != null and mapY != ''">
+            ,s.map_y = #{mapY}
+        </if>
         where 1=1
         <if test="bId != null and bId !=''">
             and s.b_id = #{bId}
@@ -188,6 +232,12 @@
     <!-- 修改商户属性信息 add by wuxw 2018-07-03 -->
     <update id="updateStoreAttrInstance" parameterType="Map">
         update s_store_attr sa set sa.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sa.b_id = #{newBId}
+        </if>
+        <if test="value != null and value != ''">
+            ,sa.value = #{value}
+        </if>
         where 1=1
         <if test="bId != null and bId !=''">
             and sa.b_id = #{bId}
@@ -198,11 +248,23 @@
         <if test="specCd != null and specCd !=''">
             and sa.spec_cd = #{specCd}
         </if>
+        <if test="attrId != null and attrId !=''">
+            and sa.attr_id = #{attrId}
+        </if>
     </update>
 
     <!-- 修改商户照片信息 add by wuxw 2018-07-03 -->
     <update id="updateStorePhotoInstance" parameterType="Map">
         update s_store_photo sp set sp.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sp.b_id = #{newBId}
+        </if>
+        <if test="storePhotoTypeCd != null and storePhotoTypeCd != ''">
+            ,sp.store_photo_type_cd = #{storePhotoTypeCd}
+        </if>
+        <if test="photo != null and photo != ''">
+            ,sp.photo = #{photo}
+        </if>
         where 1=1
         <if test="bId != null and bId !=''">
             and sp.b_id = #{bId}
@@ -216,8 +278,26 @@
     </update>
 
     <!-- 修改商户证件信息 add by wuxw 2018-07-03 -->
-    <update id="updateStoreCerdentialsInstance" parameterType="Map">
+    <update id="updateStoreCerdentailsInstance" parameterType="Map">
         update s_store_cerdentials sc set sc.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sc.b_id = #{newBId}
+        </if>
+        <if test="credentialsCd != null and credentialsCd != ''">
+            ,sc.credentials_cd = #{credentialsCd}
+        </if>
+        <if test="value != null and value != ''">
+            ,sc.value = #{value}
+        </if>
+        <if test="validityPeriod != null and validityPeriod != ''">
+            ,sc.validity_period = #{validityPeriod}
+        </if>
+        <if test="positivePhoto != null and positivePhoto != ''">
+            ,sc.positive_photo = #{positivePhoto}
+        </if>
+        <if test="negativePhoto != null and negativePhoto != ''">
+            ,sc.negative_photo = #{negativePhoto}
+        </if>
         where 1=1
         <if test="bId != null and bId !=''">
             and sc.b_id = #{bId}

+ 63 - 0
java110-event/src/main/java/com/java110/event/service/AbstractBusinessServiceDataFlowListener.java

@@ -0,0 +1,63 @@
+package com.java110.event.service;
+
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.factory.DataTransactionFactory;
+import com.java110.entity.center.Business;
+
+/**
+ * BusinessServiceDataFlowListener 抽象类
+ * Created by wuxw on 2018/7/3.
+ */
+public abstract class AbstractBusinessServiceDataFlowListener implements BusinessServiceDataFlowListener{
+
+    @Override
+    public void soService(BusinessServiceDataFlowEvent event) {
+        //这里处理业务逻辑数据
+        DataFlowContext dataFlowContext = event.getDataFlowContext();
+        doSaveStoreInfo(dataFlowContext);
+    }
+
+    /**
+     * 修改商户信息
+     * 主要保存 businessStore,businessStoreAttr,businessStorePhoto,businessStoreCerdentials信息
+     * @param dataFlowContext 数据流对象
+     */
+    private void doSaveStoreInfo(DataFlowContext dataFlowContext){
+        String businessType = dataFlowContext.getOrder().getBusinessType();
+        Business business = dataFlowContext.getCurrentBusiness();
+        // Instance 过程
+        if(StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(businessType)){
+            doBusinessToInstance(dataFlowContext,business);
+        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(businessType)){ // Business过程
+            doSaveBusiness(dataFlowContext,business);
+        }else if(StatusConstant.REQUEST_BUSINESS_TYPE_DELETE.equals(businessType)){ //撤单过程
+            doRecover(dataFlowContext,business);
+        }
+        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext, ResponseConstant.RESULT_CODE_SUCCESS,"成功",
+                dataFlowContext.getParamOut()));
+    }
+
+
+    /**
+     * 保存数据至 business表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    protected abstract void doSaveBusiness(DataFlowContext dataFlowContext,Business business);
+
+    /**
+     * 将business 数据 同步到 business
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    protected abstract void doBusinessToInstance(DataFlowContext dataFlowContext,Business business);
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    protected abstract void doRecover(DataFlowContext dataFlowContext,Business business);
+}