|
@@ -2,19 +2,16 @@ package com.java110.store.listener;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.java110.common.constant.ResponseConstant;
|
|
|
|
|
import com.java110.common.constant.ServiceCodeConstant;
|
|
import com.java110.common.constant.ServiceCodeConstant;
|
|
|
import com.java110.common.constant.StatusConstant;
|
|
import com.java110.common.constant.StatusConstant;
|
|
|
-import com.java110.common.log.LoggerEngine;
|
|
|
|
|
import com.java110.common.util.Assert;
|
|
import com.java110.common.util.Assert;
|
|
|
import com.java110.core.annotation.Java110Listener;
|
|
import com.java110.core.annotation.Java110Listener;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
-import com.java110.core.factory.DataTransactionFactory;
|
|
|
|
|
import com.java110.core.factory.GenerateCodeFactory;
|
|
import com.java110.core.factory.GenerateCodeFactory;
|
|
|
import com.java110.entity.center.Business;
|
|
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 com.java110.store.dao.IStoreServiceDao;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -28,7 +25,9 @@ import java.util.Map;
|
|
|
*/
|
|
*/
|
|
|
@Java110Listener("saveStoreInfoListener")
|
|
@Java110Listener("saveStoreInfoListener")
|
|
|
@Transactional
|
|
@Transactional
|
|
|
-public class SaveStoreInfoListener extends LoggerEngine implements BusinessServiceDataFlowListener{
|
|
|
|
|
|
|
+public class SaveStoreInfoListener extends AbstractStoreBusinessServiceDataFlowListener{
|
|
|
|
|
+
|
|
|
|
|
+ private final static Logger logger = LoggerFactory.getLogger(SaveStoreInfoListener.class);
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
IStoreServiceDao storeServiceDaoImpl;
|
|
IStoreServiceDao storeServiceDaoImpl;
|
|
@@ -43,81 +42,46 @@ public class SaveStoreInfoListener extends LoggerEngine implements BusinessServi
|
|
|
return ServiceCodeConstant.SERVICE_CODE_SAVE_STORE_INFO;
|
|
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();
|
|
JSONObject data = business.getDatas();
|
|
|
|
|
|
|
|
Map info = new HashMap();
|
|
Map info = new HashMap();
|
|
@@ -145,51 +109,48 @@ public class SaveStoreInfoListener extends LoggerEngine implements BusinessServi
|
|
|
if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){
|
|
if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){
|
|
|
storeServiceDaoImpl.saveStoreCerdentialsInstance(info);
|
|
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();
|
|
Map paramIn = new HashMap();
|
|
|
paramIn.put("bId",bId);
|
|
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);
|
|
businessStore.put("operate", StatusConstant.OPERATE_ADD);
|
|
|
//保存商户信息
|
|
//保存商户信息
|
|
|
storeServiceDaoImpl.saveBusinessStoreInfo(businessStore);
|
|
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();
|
|
String storeId = GenerateCodeFactory.getStoreId();
|
|
|
JSONObject businessStore = data.getJSONObject("businessStore");
|
|
JSONObject businessStore = data.getJSONObject("businessStore");
|
|
|
businessStore.put("storeId",storeId);
|
|
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")) {
|
|
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")) {
|
|
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);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|