MerchantServiceRest.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. package com.java110.merchant.rest;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.common.log.LoggerEngine;
  4. import com.java110.common.util.Assert;
  5. import com.java110.common.util.ProtocolUtil;
  6. import com.java110.core.base.controller.BaseController;
  7. import com.java110.entity.merchant.Merchant;
  8. import com.java110.feign.merchant.IMerchantService;
  9. import com.java110.merchant.smo.IMerchantServiceSMO;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.RestController;
  14. /**
  15. * 用户服务提供类
  16. * Created by wuxw on 2017/4/5.
  17. */
  18. @RestController
  19. public class MerchantServiceRest extends BaseController implements IMerchantService {
  20. @Autowired
  21. IMerchantServiceSMO iMerchantServiceSMO;
  22. /**
  23. * 通过Merchant对象中数据查询用户信息
  24. * 如,用户ID,名称
  25. * @param data
  26. * @return
  27. */
  28. @RequestMapping("/merchantService/queryMerchantInfo")
  29. public String queryMerchantInfo(@RequestParam("data") String data){
  30. LoggerEngine.debug("queryMerchantInfo入参:" + data);
  31. String resultMerchantInfo = null;
  32. JSONObject reqMerchantJSON = null;
  33. try {
  34. reqMerchantJSON = this.simpleValidateJSON(data);
  35. Merchant oldMerchant = new Merchant();
  36. oldMerchant.setMerchantId(reqMerchantJSON.getString("merchantId"));
  37. resultMerchantInfo = iMerchantServiceSMO.queryMerchant(oldMerchant);
  38. } catch (Exception e) {
  39. LoggerEngine.error("服务处理出现异常:", e);
  40. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
  41. } finally {
  42. LoggerEngine.debug("用户服务操作客户出参:" + resultMerchantInfo);
  43. return resultMerchantInfo;
  44. }
  45. }
  46. /**
  47. * 用户服务信息受理
  48. * 协议:
  49. * {
  50. * 'boMerchant':[{}],
  51. * 'boMerchantAttr':[{}]
  52. * }
  53. * @param data
  54. * @return
  55. */
  56. @RequestMapping("/merchantService/soMerchantService")
  57. public String soMerchantService(@RequestParam("data") String data){
  58. LoggerEngine.debug("soMerchantService入参:" + data);
  59. String resultMerchantInfo = null;
  60. JSONObject reqMerchantJSON = null;
  61. try {
  62. reqMerchantJSON = this.simpleValidateJSON(data);
  63. //1.0规则校验,报文是否合法
  64. //2.0 受理客户信息
  65. resultMerchantInfo = iMerchantServiceSMO.soMerchantService(reqMerchantJSON);
  66. } catch (Exception e) {
  67. LoggerEngine.error("服务处理出现异常:", e);
  68. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
  69. } finally {
  70. LoggerEngine.debug("用户服务操作客户出参:" + resultMerchantInfo);
  71. return resultMerchantInfo;
  72. }
  73. }
  74. /**
  75. * 这个接口专门用于订单服务受理用,入参为 JSONObject
  76. *
  77. * 支持 多个 客户信息 受理
  78. *
  79. * 请求协议:
  80. *
  81. * {
  82. "data":
  83. {
  84. "boMerchant": [
  85. {
  86. "merchantId": "-1",
  87. "name": "S",
  88. "email": "-52",
  89. "cellphone": "17797173942",
  90. "realName": "wuxw",
  91. "sex": "1",
  92. "password": "123456",
  93. "lanId": "863010",
  94. "merchantAdress": "青海省西宁市城中区格兰小镇",
  95. "merchantType": "1",
  96. "openId": "",
  97. "state": "ADD"
  98. },
  99. {
  100. "merchantId": "123",
  101. "name": "S",
  102. "email": "-52",
  103. "cellphone": "17797173942",
  104. "realName": "wuxw",
  105. "sex": "1",
  106. "password": "123456",
  107. "lanId": "863010",
  108. "merchantAdress": "青海省西宁市城中区格兰小镇",
  109. "merchantType": "1",
  110. "openId": "",
  111. "state": "DEL"
  112. }
  113. ],
  114. "boMerchantAttr": [
  115. {
  116. "merchantId": "123",
  117. "prodId": "-1",
  118. "attrCd": "123344",
  119. "value": "1",
  120. "state": "ADD"
  121. },
  122. {
  123. "merchantId": "123",
  124. "prodId": "-1",
  125. "attrCd": "123345",
  126. "value": "1",
  127. "state": "DEL"
  128. }
  129. ]
  130. }
  131. }
  132. *
  133. * 返回协议:
  134. *
  135. * {
  136. 'RESULT_CODE': '0000',
  137. 'RESULT_MSG': '成功',
  138. 'RESULT_INFO': {}
  139. }
  140. * @param data
  141. * @return
  142. */
  143. @Override
  144. @RequestMapping("/merchantService/soMerchantServiceForOrderService")
  145. public String soMerchantServiceForOrderService(@RequestParam("data") String data) {
  146. LoggerEngine.debug("soMerchantService入参:" + data);
  147. String resultMerchantInfo = null;
  148. JSONObject reqMerchantJSON = null;
  149. try {
  150. reqMerchantJSON = this.simpleValidateJSON(data);
  151. //1.0规则校验,报文是否合法
  152. //2.0 受理客户信息
  153. resultMerchantInfo = iMerchantServiceSMO.soMerchantServiceForOrderService(reqMerchantJSON);
  154. } catch (Exception e) {
  155. LoggerEngine.error("服务处理出现异常:", e);
  156. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
  157. } finally {
  158. LoggerEngine.debug("用户服务操作客户出参:" + resultMerchantInfo);
  159. return resultMerchantInfo;
  160. }
  161. }
  162. /**
  163. * 客户信息处理
  164. * 协议:
  165. *{
  166. * boMerchant:[{},{}]
  167. * }
  168. * @param data
  169. * @return
  170. * @throws Exception
  171. */
  172. @RequestMapping("/merchantService/soBoMerchant")
  173. public String soBoMerchant(@RequestParam("data") String data ) {
  174. LoggerEngine.debug("soBoMerchant入参:" + data);
  175. String resultMerchantInfo = null;
  176. JSONObject reqMerchantJSON = null;
  177. try {
  178. reqMerchantJSON = this.simpleValidateJSON(data);
  179. resultMerchantInfo = iMerchantServiceSMO.soBoMerchant(data);
  180. }catch (Exception e){
  181. LoggerEngine.error("服务处理出现异常:", e);
  182. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常:"+e,null);
  183. } finally {
  184. LoggerEngine.debug("用户服务操作客户出参:" + resultMerchantInfo);
  185. return resultMerchantInfo;
  186. }
  187. }
  188. /**
  189. * 客户信息属性处理
  190. * 协议:
  191. *{
  192. * boMerchantAttr:[{},{}]
  193. * }
  194. * @param data
  195. * @return
  196. * @throws Exception
  197. */
  198. @RequestMapping("/merchantService/soBoMerchantAttr")
  199. public String soBoMerchantAttr(@RequestParam("data") String data) {
  200. LoggerEngine.debug("soBoMerchantAttr入参:" + data);
  201. String resultMerchantInfo = null;
  202. JSONObject reqMerchantJSON = null;
  203. try {
  204. reqMerchantJSON = this.simpleValidateJSON(data);
  205. resultMerchantInfo = iMerchantServiceSMO.soBoMerchantAttr(data);
  206. }catch (Exception e){
  207. LoggerEngine.error("服务处理出现异常:", e);
  208. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
  209. } finally {
  210. LoggerEngine.debug("用户服务操作客户出参:" + resultMerchantInfo);
  211. return resultMerchantInfo;
  212. }
  213. }
  214. /**
  215. * 作废订单,根据boId作废订单
  216. *
  217. * 接口协议:
  218. *
  219. * { 'data': [
  220. {
  221. 'olId': '123456',
  222. 'boId': '222222',
  223. 'actionTypeCd': 'C1'
  224. },
  225. {
  226. 'olId': '123456',
  227. 'boId': '222222',
  228. 'actionTypeCd': 'C1'
  229. },
  230. {
  231. 'olId': '123456',
  232. 'boId': '222222',
  233. 'actionTypeCd': 'C1'
  234. }
  235. ] }
  236. * @param data
  237. * @return
  238. */
  239. @RequestMapping("/merchantService/soDeleteMerchantService")
  240. public String soDeleteMerchantService(@RequestParam("data") String data){
  241. LoggerEngine.debug("作废订单入参:"+data);
  242. String resultMerchantInfo = null;
  243. JSONObject reqParam = null;
  244. try{
  245. reqParam = this.simpleValidateJSON(data);
  246. Assert.isNotNull(reqParam,"data","传入报文错误,没有包含data节点"+reqParam);
  247. resultMerchantInfo = iMerchantServiceSMO.soDeleteMerchantInfo(reqParam.getJSONArray("data"));
  248. }catch (Exception e){
  249. LoggerEngine.error("服务处理出现异常:", e);
  250. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e+data,null);
  251. }finally {
  252. LoggerEngine.debug("作废订单出参:" + resultMerchantInfo);
  253. return resultMerchantInfo;
  254. }
  255. }
  256. @RequestMapping("/merchantService/queryMerchantInfoByOlId")
  257. public String queryMerchantInfoByOlId(@RequestParam("busiOrder") String busiOrder){
  258. LoggerEngine.debug("queryMerchantInfoByOlId入参:" + busiOrder);
  259. String resultMerchantInfo = null;
  260. try {
  261. this.simpleValidateJSON(busiOrder);
  262. resultMerchantInfo = iMerchantServiceSMO.queryMerchantInfoByOlId(busiOrder);
  263. } catch (Exception e) {
  264. LoggerEngine.error("服务处理出现异常:", e);
  265. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
  266. } finally {
  267. LoggerEngine.debug("用户服务操作客户出参:" + resultMerchantInfo);
  268. return resultMerchantInfo;
  269. }
  270. }
  271. @RequestMapping("/merchantService/queryNeedDeleteMerchantInfoByOlId")
  272. public String queryNeedDeleteMerchantInfoByOlId(@RequestParam("busiOrder") String busiOrder){
  273. LoggerEngine.debug("queryMerchantInfoByOlId入参:" + busiOrder);
  274. String resultMerchantInfo = null;
  275. try {
  276. this.simpleValidateJSON(busiOrder);
  277. resultMerchantInfo = iMerchantServiceSMO.queryNeedDeleteMerchantInfoByOlId(busiOrder);
  278. } catch (Exception e) {
  279. LoggerEngine.error("服务处理出现异常:", e);
  280. resultMerchantInfo = ProtocolUtil.createResultMsg(ProtocolUtil.RETURN_MSG_ERROR,"服务处理出现异常"+e,null);
  281. } finally {
  282. LoggerEngine.debug("用户服务操作客户出参:" + resultMerchantInfo);
  283. return resultMerchantInfo;
  284. }
  285. }
  286. public IMerchantServiceSMO getiMerchantServiceSMO() {
  287. return iMerchantServiceSMO;
  288. }
  289. public void setiMerchantServiceSMO(IMerchantServiceSMO iMerchantServiceSMO) {
  290. this.iMerchantServiceSMO = iMerchantServiceSMO;
  291. }
  292. }