wuxw7
2018-07-04 9adbbca6d70de6f6a5095f1dad1c6dbb512b41f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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);
}