wuxw7
2018-07-04 9adbbca6d70de6f6a5095f1dad1c6dbb512b41f1
商户服务开发完成,待测试
9个文件已修改
6个文件已添加
1835 ■■■■ 已修改文件
StoreService/doc/deleteStoreInfo.json 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/doc/saveStoreInfo.json 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/doc/updateStoreInfo.json 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/src/main/java/com/java110/store/dao/IStoreServiceDao.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/src/main/java/com/java110/store/listener/AbstractStoreBusinessServiceDataFlowListener.java 184 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/src/main/java/com/java110/store/listener/DeleteStoreInfoListener.java 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/src/main/java/com/java110/store/listener/SaveStoreInfoListener.java 211 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/src/main/java/com/java110/store/listener/UpdateStoreInfoListener.java 322 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserService/src/main/java/com/java110/user/listener/SaveUserCredentialsListener.java 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserService/src/main/java/com/java110/user/listener/SaveUserInfoListener.java 181 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserService/src/main/java/com/java110/user/listener/SaveUserTagListener.java 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-config/src/main/resources/mapper/store/StoreServiceDaoImplMapper.xml 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-event/src/main/java/com/java110/event/service/AbstractBusinessServiceDataFlowListener.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StoreService/doc/deleteStoreInfo.json
New file
@@ -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": "具体值"
    }]
  }]
}
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",
StoreService/doc/updateStoreInfo.json
New file
@@ -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": "具体值"
    }]
  }]
}
StoreService/src/main/java/com/java110/store/dao/IStoreServiceDao.java
@@ -181,4 +181,5 @@
     * @throws DAOException
     */
    public void updateStoreCerdentailsInstance(Map info) throws DAOException;
}
StoreService/src/main/java/com/java110/store/listener/AbstractStoreBusinessServiceDataFlowListener.java
New file
@@ -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);
    }
}
StoreService/src/main/java/com/java110/store/listener/DeleteStoreInfoListener.java
New file
@@ -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;
    }
}
StoreService/src/main/java/com/java110/store/listener/SaveStoreInfoListener.java
@@ -2,19 +2,16 @@
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 @@
 */
@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 @@
        return ServiceCodeConstant.SERVICE_CODE_SAVE_STORE_INFO;
    }
    /**
     * 保存商户信息 business 表中
     * @param dataFlowContext 数据对象
     * @param business 当前业务对象
     */
    @Override
    public void soService(BusinessServiceDataFlowEvent event) {
        //这里处理业务逻辑数据
        DataFlowContext dataFlowContext = event.getDataFlowContext();
        doSaveStoreInfo(dataFlowContext);
    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);
        }
    }
    /**
     * 保存商户信息
     * 主要保存 businessStore,businessStoreAttr,businessStorePhoto,businessStoreCerdentials信息
     * @param dataFlowContext 数据流对象
     * business 数据转移到 instance
     * @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) {
        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"));
        }
        //商户属性
        List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info);
        if(storeAttrs != null && storeAttrs.size()>0){
            storeServiceDaoImpl.updateStoreAttrInstance(info);
        }
        //商户照片
        List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info);
        if(storePhotos != null && storePhotos.size()>0){
            storeServiceDaoImpl.updateStorePhotoInstance(info);
        }
        //商户属性
        List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info);
        if(storeCerdentialses != null && storeCerdentialses.size()>0){
            storeServiceDaoImpl.updateStoreCerdentailsInstance(info);
        }
    }
    /**
     * instance过程
     * @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 @@
        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 @@
        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 @@
        String storeId = GenerateCodeFactory.getStoreId();
        JSONObject businessStore = data.getJSONObject("businessStore");
        businessStore.put("storeId",storeId);
        if(data.containsKey("businessStorePhoto")) {
            JSONObject businessStorePhoto = data.getJSONObject("businessStorePhoto");
            businessStorePhoto.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")) {
            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);
            }
        }
    }
StoreService/src/main/java/com/java110/store/listener/UpdateStoreInfoListener.java
New file
@@ -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;
    }
}
UserService/src/main/java/com/java110/user/listener/SaveUserAddressListener.java
@@ -13,6 +13,7 @@
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 @@
 */
@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 @@
        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 节点,或没有子节点需要处理");
        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"));
        }
        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
                dataFlowContext.getParamOut()));
        dataFlowContext.addParamOut("userId",businessUser.getString("userId"));
        businessUser.put("bId",business.getbId());
        businessUser.put("operate", StatusConstant.OPERATE_ADD);
        //保存用户信息
        userServiceDaoImpl.saveBusinessUserAddress(businessUser);
    }
    /**
     * 撤单
     * @param business
     * 保存地址信息至instance
     * @param dataFlowContext 数据对象
     * @param business 当前业务对象
     */
    private void doDeleteInstanceUserAddress(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"));
        }
    }
    /**
     * instance过程
     * @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 @@
        }
        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() {
UserService/src/main/java/com/java110/user/listener/SaveUserCredentialsListener.java
@@ -11,6 +11,7 @@
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.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,79 +47,14 @@
        return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_CREDENTIALS;
    }
    /**
     * 保存用户证件信息
     * @param dataFlowContext 数据对象
     * @param business 当前业务对象
     */
    @Override
    public void soService(BusinessServiceDataFlowEvent event) {
        //这里处理业务逻辑数据
        DataFlowContext dataFlowContext = event.getDataFlowContext();
        doSaveUserCredentials(dataFlowContext);
    }
    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);
        }
        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
                dataFlowContext.getParamOut()));
    }
    /**
     * 撤单
     * @param business
     */
    private void doDeleteInstanceUserCredentials(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"));
        }
    }
    /**
     * instance过程
     * @param business
     */
    private void doSaveInstanceUserCredentials(DataFlowContext dataFlowContext, Business business) {
        JSONObject data = business.getDatas();
        Map info = new HashMap();
        info.put("bId",business.getbId());
        info.put("operate",StatusConstant.OPERATE_ADD);
        Map businessUserCredentials = userServiceDaoImpl.queryBusinessUserCredentials(info);
        if( businessUserCredentials != null && !businessUserCredentials.isEmpty()) {
            userServiceDaoImpl.saveUserCredentialsInstance(businessUserCredentials);
            dataFlowContext.addParamOut("userId",businessUserCredentials.get("user_id"));
            return ;
        }
        throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,"当前数据未找到business 数据"+info);
    }
    /**
     * 处理用户打标信息
     * @param business 业务信息
     */
    private void doSaveBusinessUserCredentials(DataFlowContext dataFlowContext, Business business) {
    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
        JSONObject data = business.getDatas();
        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
@@ -137,7 +73,51 @@
        businessUser.put("operate", StatusConstant.OPERATE_ADD);
        //保存用户信息
        userServiceDaoImpl.saveBusinessUserCredentials(businessUser);
    }
    /**
     * 保存用户证件信息至 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 businessUserCredentials = userServiceDaoImpl.queryBusinessUserCredentials(info);
        if( businessUserCredentials != null && !businessUserCredentials.isEmpty()) {
            userServiceDaoImpl.saveUserCredentialsInstance(businessUserCredentials);
            dataFlowContext.addParamOut("userId",businessUserCredentials.get("user_id"));
            return ;
        }
        throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,"当前数据未找到business 数据"+info);
    }
    /**
     * 作废用户证件信息
     * @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);
        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"));
        }
    }
    public IUserServiceDao getUserServiceDaoImpl() {
UserService/src/main/java/com/java110/user/listener/SaveUserInfoListener.java
@@ -8,15 +8,17 @@
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 @@
 */
@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,113 +48,14 @@
        return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_INFO;
    }
    /**
     * 保存用户信息至 business表中
     * @param dataFlowContext 数据对象
     * @param business 当前业务对象
     */
    @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
     */
    private void doDeleteInstanceUserInfo(DataFlowContext dataFlowContext,Business business) {
        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"));
        }
        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);
        }
    }
    /**
     * instance过程
     * @param business
     */
    private void doSaveInstanceUserInfo(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);
        Map businessUser = userServiceDaoImpl.queryBusinessUserInfo(info);
        if( businessUser != null && !businessUser.isEmpty()) {
            userServiceDaoImpl.saveUserInfoInstance(businessUser);
            dataFlowContext.addParamOut("userId",businessUser.get("user_id"));
        }
        List<Map> businessUserAttrs = userServiceDaoImpl.queryBusinessUserInfoAttrs(info);
        if(businessUserAttrs != null && businessUserAttrs.size() > 0) {
            userServiceDaoImpl.saveUserAttrInstance(businessUser);
        }
    }
    /**
     * 保存数据至u_user 表中
     * @param business
     */
    private void doComplateUserInfo(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) {
    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
        JSONObject data = business.getDatas();
        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
@@ -175,11 +80,63 @@
        if(businessUser.containsKey("businessUserAttr")){
            doSaveUserAttrs(business);
        }
    }
        //userServiceDaoImpl.saveUserInfoInstance(businessUser);
    /**
     * 将 business的用户信息 保存至 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 businessUser = userServiceDaoImpl.queryBusinessUserInfo(info);
        if( businessUser != null && !businessUser.isEmpty()) {
            userServiceDaoImpl.saveUserInfoInstance(businessUser);
            dataFlowContext.addParamOut("userId",businessUser.get("user_id"));
        }
        List<Map> businessUserAttrs = userServiceDaoImpl.queryBusinessUserInfoAttrs(info);
        if(businessUserAttrs != null && businessUserAttrs.size() > 0) {
            userServiceDaoImpl.saveUserAttrInstance(businessUser);
        }
    }
    /**
     * 将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);
        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"));
        }
        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 @@
            userServiceDaoImpl.saveBusinessUserAttr(userAttr);
        }
        /*JSONObject attrInstance = new JSONObject();
        attrInstance.put("bId",business.getbId());
        userServiceDaoImpl.saveUserAttrInstance(attrInstance);*/
    }
    public IUserServiceDao getUserServiceDaoImpl() {
UserService/src/main/java/com/java110/user/listener/SaveUserTagListener.java
@@ -13,6 +13,7 @@
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 @@
 */
@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,79 +50,13 @@
        return ServiceCodeConstant.SERVICE_CODE_SAVE_USER_TAG;
    }
    /**
     * 用户打标信息保存至 business表中
     * @param dataFlowContext 数据对象
     * @param business 当前业务对象
     */
    @Override
    public void soService(BusinessServiceDataFlowEvent event) {
        //这里处理业务逻辑数据
        DataFlowContext dataFlowContext = event.getDataFlowContext();
        doSaveUserTag(dataFlowContext);
    }
    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);
        }
        dataFlowContext.setResJson(DataTransactionFactory.createBusinessResponseJson(dataFlowContext,ResponseConstant.RESULT_CODE_SUCCESS,"成功",
                dataFlowContext.getParamOut()));
    }
    /**
     * 撤单
     * @param business
     */
    private void doDeleteInstanceUserTag(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"));
        }
    }
    /**
     * instance过程
     * @param business
     */
    private void doSaveInstanceUserTag(DataFlowContext dataFlowContext, Business business) {
        JSONObject data = business.getDatas();
        Map info = new HashMap();
        info.put("bId",business.getbId());
        info.put("operate",StatusConstant.OPERATE_ADD);
        Map businessUserTag = userServiceDaoImpl.queryBusinessUserTag(info);
        if( businessUserTag != null && !businessUserTag.isEmpty()) {
            userServiceDaoImpl.saveUserTagInstance(businessUserTag);
            dataFlowContext.addParamOut("userId",businessUserTag.get("user_id"));
            return ;
        }
        throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,"当前数据未找到business 数据"+info);
    }
    /**
     * 处理用户打标信息
     * @param business 业务信息
     */
    private void doSaveBusinessUserTag(DataFlowContext dataFlowContext, Business business) {
    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
        JSONObject data = business.getDatas();
        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
@@ -140,7 +75,50 @@
        businessUser.put("operate", StatusConstant.OPERATE_ADD);
        //保存用户信息
        userServiceDaoImpl.saveBusinessUserTag(businessUser);
    }
    /**
     * 用户打标信息保存至 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 businessUserTag = userServiceDaoImpl.queryBusinessUserTag(info);
        if( businessUserTag != null && !businessUserTag.isEmpty()) {
            userServiceDaoImpl.saveUserTagInstance(businessUserTag);
            dataFlowContext.addParamOut("userId",businessUserTag.get("user_id"));
            return ;
        }
        throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,"当前数据未找到business 数据"+info);
    }
    /**
     * 作废 用户打标信息
     * @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);
        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"));
        }
    }
    public IUserServiceDao getUserServiceDaoImpl() {
java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java
@@ -90,6 +90,16 @@
     */
    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";
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,12 +141,19 @@
    <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>
@@ -150,7 +161,10 @@
    <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}
java110-event/src/main/java/com/java110/event/service/AbstractBusinessServiceDataFlowListener.java
New file
@@ -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);
}