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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
package com.java110.user.rest;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.common.log.LoggerEngine;
import com.java110.common.util.Assert;
import com.java110.common.util.ProtocolUtil;
import com.java110.core.base.controller.BaseController;
import com.java110.entity.user.Cust;
import com.java110.feign.user.IUserService;
import com.java110.user.smo.IUserServiceSMO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * 用户服务提供类
 * Created by wuxw on 2017/4/5.
 */
@RestController
public class UserServiceRest extends BaseController implements IUserService {
 
    @Autowired
    IUserServiceSMO iUserServiceSMO;
 
    /**
     * 通过User对象中数据查询用户信息
     * 如,用户ID,名称
     * @param data
     * @return
     */
    @RequestMapping("/userService/queryUserInfo")
    public String queryUserInfo(@RequestParam("data") String data){
        LoggerEngine.debug("queryUserInfo入参:" + data);
 
 
        String resultUserInfo = null;
 
        JSONObject reqUserJSON = null;
        try {
            reqUserJSON = this.simpleValidateJSON(data);
            Cust oldCust = new Cust();
            oldCust.setCustId(reqUserJSON.getString("custId"));
            resultUserInfo = iUserServiceSMO.queryCust(oldCust);
 
        } catch (Exception e) {
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
        } finally {
            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
    /**
     * 根据购物车信息查询
     *
     * 这里返回data信息
     * @param busiOrder
     * @return
     */
    @Override
    @RequestMapping("/userService/queryCustInfoByOlId")
    public String queryCustInfoByOlId(@RequestParam("busiOrder") String busiOrder) {
 
 
        LoggerEngine.debug("queryUserInfo入参:" + busiOrder);
 
 
        String resultUserInfo = null;
 
        try {
             this.simpleValidateJSON(busiOrder);
            resultUserInfo = iUserServiceSMO.queryCustInfoByOlId(busiOrder);
 
        } catch (Exception e) {
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
        } finally {
            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
    /**
     * 根据购物车信息查询 需要作废的发起的报文
     *
     * 这里返回data信息
     * @param busiOrder
     * @return
     */
    @Override
    @RequestMapping("/userService/queryNeedDeleteCustInfoByOlId")
    public String queryNeedDeleteCustInfoByOlId(@RequestParam("busiOrder")  String busiOrder) {
 
 
        LoggerEngine.debug("queryUserInfo入参:" + busiOrder);
 
 
        String resultUserInfo = null;
 
        try {
            this.simpleValidateJSON(busiOrder);
            resultUserInfo = iUserServiceSMO.queryNeedDeleteCustInfoByOlId(busiOrder);
 
        } catch (Exception e) {
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
        } finally {
            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
 
    /**
     * 用户服务信息受理
     * 协议:
     * {
     *     'boCust':[{}],
     *     'boCustAttr':[{}]
     * }
     * @param data
     * @return
     */
    @RequestMapping("/userService/soUserService")
    public String soUserService(@RequestParam("data") String data){
 
        LoggerEngine.debug("soUserService入参:" + data);
 
        String resultUserInfo = null;
 
        JSONObject reqUserJSON = null;
        try {
            reqUserJSON = this.simpleValidateJSON(data);
            //1.0规则校验,报文是否合法
 
            //2.0 受理客户信息
            resultUserInfo = iUserServiceSMO.soUserService(reqUserJSON);
 
        } catch (Exception e) {
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
        } finally {
            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
 
    /**
     * 这个接口专门用于订单服务受理用,入参为 JSONObject
     *
     * 支持 多个 客户信息 受理
     *
     * 请求协议:
     *
     * {
     "data": [
     {
     "actionTypeCd": "C1",
     "boCust": [
     {
     "custId": "-1",
     "name": "S",
     "email": "-52",
     "cellphone": "17797173942",
     "realName": "wuxw",
     "sex": "1",
     "password": "123456",
     "lanId": "863010",
     "custAdress": "青海省西宁市城中区格兰小镇",
     "custType": "1",
     "openId": "",
     "state": "ADD"
     },
     {
     "custId": "123",
     "name": "S",
     "email": "-52",
     "cellphone": "17797173942",
     "realName": "wuxw",
     "sex": "1",
     "password": "123456",
     "lanId": "863010",
     "custAdress": "青海省西宁市城中区格兰小镇",
     "custType": "1",
     "openId": "",
     "state": "DEL"
     }
     ],
     "boCustAttr": [
     {
     "custId": "123",
     "prodId": "-1",
     "attrCd": "123344",
     "value": "1",
     "state": "ADD"
     },
     {
     "custId": "123",
     "prodId": "-1",
     "attrCd": "123345",
     "value": "1",
     "state": "DEL"
     }
     ]
     }
     ]
     }
 
     *
     * 返回协议:
     *
     * {
     'RESULT_CODE': '0000',
     'RESULT_MSG': '成功',
     'RESULT_INFO': {}
     }
     * @param data
     * @return
     */
    @Override
    @RequestMapping("/userService/soUserServiceForOrderService")
    public String soUserServiceForOrderService(@RequestParam("data") String data) {
        LoggerEngine.debug("soUserService入参:" + data);
 
        String resultUserInfo = null;
 
        JSONObject reqUserJSON = null;
        try {
            reqUserJSON = this.simpleValidateJSON(data);
            //1.0规则校验,报文是否合法
 
 
            //2.0 受理客户信息
            resultUserInfo = iUserServiceSMO.soUserServiceForOrderService(reqUserJSON);
 
 
        } catch (Exception e) {
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
        } finally {
            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
 
    /**
     * 客户信息处理
     * 协议:
     *{
     *     boCust:[{},{}]
     * }
     * @param data
     * @return
     * @throws Exception
     */
    @RequestMapping("/userService/soBoCust")
    public String soBoCust(@RequestParam("data") String data ) {
        LoggerEngine.debug("soBoCust入参:" + data);
 
        String resultUserInfo = null;
 
        JSONObject reqUserJSON = null;
        try {
            reqUserJSON = this.simpleValidateJSON(data);
            resultUserInfo = iUserServiceSMO.soBoCust(data);
        }catch (Exception e){
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常:"+e,null);
        } finally {
            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
    /**
     * 客户信息属性处理
     * 协议:
     *{
     *     boCustAttr:[{},{}]
     * }
     * @param data
     * @return
     * @throws Exception
     */
    @RequestMapping("/userService/soBoCustAttr")
    public String soBoCustAttr(@RequestParam("data") String data) {
        LoggerEngine.debug("soBoCustAttr入参:" + data);
 
        String resultUserInfo = null;
 
        JSONObject reqUserJSON = null;
        try {
            reqUserJSON = this.simpleValidateJSON(data);
            resultUserInfo = iUserServiceSMO.soBoCustAttr(data);
        }catch (Exception e){
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
        } finally {
            LoggerEngine.debug("用户服务操作客户出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
 
    /**
     * 作废订单,根据boId作废订单
     *
     * 接口协议:
     *
     * { 'data': [
 
     {
     'olId': '123456',
     'boId': '222222',
     'actionTypeCd': 'C1'
     },
     {
     'olId': '123456',
     'boId': '222222',
     'actionTypeCd': 'C1'
     },
     {
     'olId': '123456',
     'boId': '222222',
     'actionTypeCd': 'C1'
     }
     ] }
     * @param data
     * @return
     */
    @RequestMapping("/userService/soDeleteCustService")
    public String soDeleteCustService(@RequestParam("data") String data){
 
        LoggerEngine.debug("作废订单入参:"+data);
 
        String resultUserInfo = null;
 
        JSONObject reqParam = null;
 
        try{
            reqParam = this.simpleValidateJSON(data);
 
            Assert.isNull(reqParam,"data","传入报文错误,没有包含data节点"+reqParam);
 
            resultUserInfo = iUserServiceSMO.soDeleteCustInfo(reqParam.getJSONArray("data"));
 
        }catch (Exception e){
            LoggerEngine.error("服务处理出现异常:", e);
            resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e+data,null);
        }finally {
            LoggerEngine.debug("作废订单出参:" + resultUserInfo);
            return resultUserInfo;
        }
    }
 
 
    public IUserServiceSMO getiUserServiceSMO() {
        return iUserServiceSMO;
    }
 
    public void setiUserServiceSMO(IUserServiceSMO iUserServiceSMO) {
        this.iUserServiceSMO = iUserServiceSMO;
    }
}