OrderServiceRest.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. package com.java110.order.rest;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.common.log.LoggerEngine;
  4. import com.java110.common.util.ProtocolUtil;
  5. import com.java110.core.base.controller.BaseController;
  6. import com.java110.entity.order.OrderList;
  7. import com.java110.order.smo.IOrderServiceSMO;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.util.Assert;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestParam;
  12. import org.springframework.web.bind.annotation.RestController;
  13. /**
  14. * 订单服务 提供类
  15. *
  16. * 主要提供订单相关服务
  17. * Created by wuxw on 2017/4/11.
  18. */
  19. @RestController
  20. public class OrderServiceRest extends BaseController {
  21. @Autowired
  22. IOrderServiceSMO iOrderServiceSMO;
  23. /**
  24. * 查询订单信息
  25. * 接口协议:
  26. * 请求报文
  27. * {'olId':'71234567','extSystemId':'','custId':'','channelId':''}
  28. *
  29. * 可以根据 购物车ID 或者 外部系统ID 或者 custId 或者 channelId
  30. *
  31. * 返回报文:
  32. * {
  33. "RESULT_CODE": "0000",
  34. "RESULT_MSG": "成功",
  35. "RESULT_INFO": {
  36. "orderLists": [
  37. {
  38. "channelId": "700212896",
  39. "remarks": "",
  40. "olId": "123456",
  41. "custId": "701008023904",
  42. "statusCd": "S",
  43. "reqTime": "20170411163709",
  44. "extSystemId": "310013698777",
  45. "olTypeCd": "15",
  46. "orderListAttrs": [
  47. {
  48. "olId": "123456",
  49. "attrCd": "712345",
  50. "value": "XXX",
  51. "name": "系统来源"
  52. }
  53. ],
  54. "busiOrders": [
  55. {
  56. "boId": "123456",
  57. "olId": "123456",
  58. "actionTypeCd": "C1",
  59. "status_cd": "0",
  60. "create_dt": "2017-04-16 22:58:03",
  61. "start_dt": "2017-04-16 22:58:03",
  62. "end_dt": "2017-04-16 22:58:03",
  63. "remark": "",
  64. "busiOrders": [
  65. {
  66. "boId": "123456",
  67. "attrCd": "712345",
  68. "value": "XXX",
  69. "name": "系统来源"
  70. }
  71. ]
  72. }
  73. ]
  74. }
  75. ]
  76. }
  77. }
  78. *
  79. * @param orderInfo
  80. * @return
  81. */
  82. @RequestMapping("/orderService/queryOrder")
  83. public String queryOrder(@RequestParam("orderInfo") String orderInfo) {
  84. LoggerEngine.debug("soOrderService入参:" + orderInfo);
  85. String resultUserInfo = null;
  86. JSONObject reqOrderJSON = null;
  87. try{
  88. reqOrderJSON = this.simpleValidateJSON(orderInfo);
  89. //校验 购物车ID 或者 外部系统ID 或者 custId 或者 channelId 中的一个是
  90. Assert.notNull(reqOrderJSON);
  91. if(!reqOrderJSON.containsKey("olId") && !reqOrderJSON.containsKey("extSystemId")
  92. && !reqOrderJSON.containsKey("custId") && !reqOrderJSON.containsKey("channelId")){
  93. throw new IllegalArgumentException("此接口只支持用olId,extSystemId,custId,channelId 来查询订单,当前请求报文为:"+orderInfo);
  94. }
  95. //转化为 对象
  96. OrderList orderListTmp = JSONObject.toJavaObject(reqOrderJSON, OrderList.class);
  97. resultUserInfo = iOrderServiceSMO.queryOrderInfo(orderListTmp);
  98. }catch (Exception e){
  99. LoggerEngine.error("查询失败,orderInfo = "+orderInfo,e);
  100. resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"查询失败,orderInfo = "+orderInfo+"失败原因:"+e,null);
  101. }finally {
  102. return resultUserInfo;
  103. }
  104. }
  105. /**
  106. * 订单统一处理接口
  107. *
  108. * orderListInfo 中字段 asyn 如果为 A 表示 异步处理订单,其他表同步处理订单
  109. * 接口协议
  110. * {
  111. "orderList": {
  112. "orderListAttrs": [
  113. {
  114. "attrCd": "40010026",
  115. "name": "购物车流水号",
  116. "value": "31201704110009114961"
  117. }
  118. ],"busiOrder": [
  119. {
  120. "data": {
  121. "boCust": [
  122. {
  123. "custId": "-1",
  124. "name": "S",
  125. "email": "-52",
  126. "cellphone": "17797173942",
  127. "realName": "wuxw",
  128. "sex": "1",
  129. "password": "123456",
  130. "lanId": "863010",
  131. "custAdress": "青海省西宁市城中区格兰小镇",
  132. "custType": "1",
  133. "openId": "",
  134. "state": "ADD"
  135. },
  136. {
  137. "custId": "123",
  138. "name": "S",
  139. "email": "-52",
  140. "cellphone": "17797173942",
  141. "realName": "wuxw",
  142. "sex": "1",
  143. "password": "123456",
  144. "lanId": "863010",
  145. "custAdress": "青海省西宁市城中区格兰小镇",
  146. "custType": "1",
  147. "openId": "",
  148. "state": "DEL"
  149. }
  150. ],
  151. "boCustAttr": [
  152. {
  153. "custId": "123",
  154. "prodId": "-1",
  155. "attrCd": "123344",
  156. "value": "1",
  157. "state": "ADD"
  158. },
  159. {
  160. "custId": "123",
  161. "prodId": "-1",
  162. "attrCd": "123345",
  163. "value": "1",
  164. "state": "DEL"
  165. }
  166. ]
  167. },
  168. "busiObj": {
  169. "name": "新建客户",
  170. "actionTypeCd": "C1",
  171. "actionClassCd": "1",
  172. "status_cd": "S",
  173. "start_dt": "2017-04-11",
  174. "end_dt": "2017-04-12",
  175. "remark": ""
  176. },
  177. "busiOrderAttrs": [
  178. {
  179. "attrCd": "40010026",
  180. "name": "购物车流水号",
  181. "value": "31201704110009114961"
  182. }
  183. ]
  184. }
  185. ],
  186. "orderListInfo": {
  187. "transactionId": "1000000200201704113137002690",
  188. "channelId": "700212896",
  189. "remarks": "",
  190. "olId": "-1",
  191. "custId": "701008023904",
  192. "statusCd": "S",
  193. "reqTime": "20170411163709",
  194. "extSystemId": "310013698777",
  195. "olTypeCd": "15",
  196. "asyn":"A"
  197. }
  198. }
  199. }
  200. * @param orderInfo
  201. * @return
  202. */
  203. @RequestMapping("/orderService/soOrderService")
  204. public String soOrderService(@RequestParam("orderInfo") String orderInfo){
  205. LoggerEngine.debug("soOrderService入参:" + orderInfo);
  206. String resultUserInfo = null;
  207. JSONObject reqOrderJSON = null;
  208. try{
  209. reqOrderJSON = this.simpleValidateJSON(orderInfo);
  210. if(reqOrderJSON == null || !reqOrderJSON.containsKey("orderList")){
  211. throw new IllegalArgumentException("请求参数为空 reqOrderJSON :"+reqOrderJSON);
  212. }
  213. resultUserInfo = iOrderServiceSMO.orderDispatch(reqOrderJSON.getJSONObject("orderList"));
  214. }catch (Exception e){
  215. LoggerEngine.error("订单受理出现异常:", e);
  216. resultUserInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"订单受理出现异常,"+e,null);
  217. }finally {
  218. return resultUserInfo;
  219. }
  220. }
  221. public IOrderServiceSMO getiOrderServiceSMO() {
  222. return iOrderServiceSMO;
  223. }
  224. public void setiOrderServiceSMO(IOrderServiceSMO iOrderServiceSMO) {
  225. this.iOrderServiceSMO = iOrderServiceSMO;
  226. }
  227. }