Client.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. package com.ydd.third.delivery;
  2. import com.ydd.third.common.exception.BusinessException;
  3. import com.ydd.third.common.utils.StringUtils;
  4. import com.ydd.third.common.vo.ResObject;
  5. import com.ydd.third.common.vo.shop.*;
  6. import com.ydd.third.common.vo.vo.order.*;
  7. import com.ydd.third.delivery.aipt.AiptClient;
  8. import com.ydd.third.delivery.dada.DadaClient;
  9. import com.ydd.third.delivery.dianwoda.DianwodaClient;
  10. import com.ydd.third.delivery.fengniao.FengniaoClient;
  11. import com.ydd.third.delivery.huolala.HuolalaClient;
  12. import com.ydd.third.delivery.kuaifu.KfClient;
  13. import com.ydd.third.delivery.meituan.MeituanClient;
  14. import com.ydd.third.delivery.shansong.ShansongClient;
  15. import com.ydd.third.delivery.shansong.ShansongSHClient;
  16. import com.ydd.third.delivery.shunfeng.ShunfengClient;
  17. import com.ydd.third.delivery.uupt.UuptClient;
  18. import lombok.extern.slf4j.Slf4j;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.stereotype.Service;
  21. /**
  22. * @ClassName Client
  23. * @Deacription TODO
  24. * @Author peakren
  25. * @Date 2/4/21 10:20 PM
  26. * @Version 1.0
  27. **/
  28. @Slf4j
  29. @Service("deliverClient")
  30. public class Client {
  31. @Autowired
  32. MeituanClient dMeituanClient;
  33. @Autowired
  34. DadaClient dadaClient;
  35. // @Autowired
  36. // FengniaoClient fengniaoClient;
  37. @Autowired
  38. FengniaoClient fengniaoClient;
  39. @Autowired
  40. ShunfengClient shunfengClient;
  41. @Autowired
  42. ShansongSHClient shansongSHClient;
  43. @Autowired
  44. ShansongClient shansongClient;
  45. @Autowired
  46. DianwodaClient dianwodaClient;
  47. @Autowired
  48. UuptClient uuptClient;
  49. @Autowired
  50. AiptClient aiptClient;
  51. @Autowired
  52. KfClient kfClient;
  53. @Autowired
  54. HuolalaClient huolalaClient;
  55. /**
  56. * 下订单
  57. *
  58. * @param order
  59. * @return
  60. */
  61. public ResObject<OrderResultVo> createOrder(OrderVo order) {
  62. // 声明公共参数,RequestSysParams构造方法接收两个参数,第一个为signkey,第二个为appAuthToken
  63. String client = order.getLbClient();
  64. if (StringUtils.isBlank(client)) {
  65. throw new BusinessException("未指定lbClient参数");
  66. }
  67. ResObject<OrderResultVo> res;
  68. if (client.equals("meituan")) {
  69. res = dMeituanClient.createOrder(order);
  70. } else if (client.equals("meituanzb")) {
  71. res = dMeituanClient.createOrderZb(order);
  72. } else if (client.equals("dada")) {
  73. res = dadaClient.createOrder(order);
  74. //res = dadaClient.reAddOrder(order);
  75. }else if (client.equals("dadayz")) {
  76. res = dadaClient.createOrder(order);
  77. } else if (client.equals("fengniao")) {
  78. // res = fengniaoClient.createOrder(order);
  79. res = fengniaoClient.createOrder(order);
  80. } else if (client.equals("shansong")) {
  81. if (order.getIsMine() == 1) {
  82. res = shansongClient.createOrder(order);
  83. } else {
  84. res = shansongSHClient.createOrder(order);
  85. }
  86. } else if (client.equals("shunfeng")) {
  87. res = shunfengClient.createOrder(order);
  88. } else if (client.equals("dwd")) {
  89. res = dianwodaClient.dianwodaOrderCreate(order);
  90. } else if (client.equals("uupt")) {
  91. res = uuptClient.createOrder(order);
  92. } else if (client.equals("aipt")) {
  93. res = aiptClient.createOrder(order);
  94. } else if (client.equals("kuanfu")) {
  95. res = kfClient.createOrder(order);
  96. }else if (client.equals("huolala")){
  97. res = huolalaClient.createOrder(order);
  98. }
  99. else {
  100. throw new BusinessException("lbClient参数不正确");
  101. }
  102. return res;
  103. }
  104. /**
  105. * 查询订单运费/预下单
  106. *
  107. * @param order
  108. * @return
  109. */
  110. public ResObject<OrderResultVo> queryOrderDeliverFee(OrderVo order) {
  111. // 声明公共参数,RequestSysParams构造方法接收两个参数,第一个为signkey,第二个为appAuthToken
  112. String client = order.getLbClient(); // jsonParams.getString("lb_client");
  113. if (StringUtils.isBlank(client)) {
  114. throw new BusinessException("未指定lb_client参数");
  115. }
  116. ResObject<OrderResultVo> res = null;
  117. if (client.equals("meituan")) {
  118. res = dMeituanClient.queryOrderDeliverFee(order);
  119. } else if (client.equals("meituanzb")) {
  120. res = dMeituanClient.queryOrderDeliverZbFee(order);
  121. } else if (client.equals("dada")) {
  122. res = dadaClient.queryOrderDeliverFee(order);
  123. } else if (client.equals("dadayz")) {
  124. res = dadaClient.queryOrderDeliverFee(order);
  125. } else if (client.equals("fengniao")) {
  126. //res = fengniaoClient.queryPrice(jsonParamsStr);
  127. res = fengniaoClient.queryOrderDeliverFee(order);
  128. } else if (client.equals("shansong")) {
  129. //res = shansongClient.orderCalculate(order); //订单计费
  130. if (order.getIsMine() == 1) {
  131. res = shansongClient.queryOrderDeliverFee(order); //订单计费
  132. } else {
  133. res = shansongSHClient.queryOrderDeliverFee(order); //订单计费
  134. }
  135. } else if (client.equals("shunfeng")) {
  136. res = shunfengClient.queryOrderDeliverFee(order);
  137. } else if (client.equals("dwd")) {
  138. res = dianwodaClient.dianwodaEstimateCost(order);
  139. } else if (client.equals("uupt")) {
  140. res = uuptClient.queryOrderDeliverFee(order);
  141. } else if (client.equals("aipt")) {
  142. res = aiptClient.queryOrderDeliverFee(order);
  143. } else if (client.equals("kuanfu")){
  144. res = kfClient.queryOrderDeliverFee(order);
  145. } else if (client.equals("huolala")){
  146. res =huolalaClient.queryOrderDeliverFee(order);
  147. }
  148. else {
  149. throw new BusinessException("lbClient参数不正确");
  150. }
  151. return res;
  152. }
  153. /**
  154. * 取消订单
  155. *
  156. * @param cancelOrderVo
  157. * @return
  158. */
  159. public ResObject<CancelOrderResultVo> cancelOrder(CancelOrderVo cancelOrderVo) {
  160. String client = cancelOrderVo.getLbClient();
  161. if (StringUtils.isBlank(client)) {
  162. throw new BusinessException("未指定lbClient参数");
  163. }
  164. ResObject<CancelOrderResultVo> res = null;
  165. if (client.equals("meituan")) {
  166. res = dMeituanClient.cancelOrder(cancelOrderVo);
  167. } else if (client.equals("meituanzb")) {
  168. res = dMeituanClient.cancelZbOrder(cancelOrderVo);
  169. } else if (client.equals("dada")) {
  170. res = dadaClient.cancelOrder(cancelOrderVo);
  171. } else if (client.equals("dadayz")) {
  172. res = dadaClient.cancelOrder(cancelOrderVo);
  173. } else if (client.equals("fengniao")) {
  174. // res = fengniaoClient.cancelOrder(cancelOrderVo);
  175. res = fengniaoClient.cancelOrder(cancelOrderVo);
  176. } else if (client.equals("shansong")) {
  177. if (cancelOrderVo.getIsShansongSH()) {
  178. res = shansongClient.cancelOrder(cancelOrderVo);//商户,老吴命名错误
  179. } else {
  180. res = shansongSHClient.cancelOrder(cancelOrderVo);
  181. }
  182. } else if (client.equals("shunfeng")) {
  183. res = shunfengClient.cancelOrder(cancelOrderVo);
  184. } else if (client.equals("dwd")) {
  185. res = dianwodaClient.dianwodaCancelOrder(cancelOrderVo);
  186. } else if (client.equals("uupt")) {
  187. res = uuptClient.cancelOrder(cancelOrderVo);
  188. } else if (client.equals("aipt")) {
  189. res = aiptClient.cancelOrder(cancelOrderVo);
  190. } else if (client.equals("kuanfu")) {
  191. res = kfClient.cancelOrder(cancelOrderVo);
  192. } else if (client.equals("huolala")){
  193. res =huolalaClient.cancelOrder(cancelOrderVo);
  194. }
  195. else {
  196. throw new BusinessException("lbClient参数不正确");
  197. }
  198. return res;
  199. }
  200. /**
  201. * 增加小费
  202. *
  203. * @param orderTipsVo
  204. * @return
  205. */
  206. public ResObject<OrderTipsResultVo> orderAddTip(OrderTipsVo orderTipsVo) {
  207. String client = orderTipsVo.getLbClient();
  208. if (StringUtils.isBlank(client)) {
  209. throw new BusinessException("未指定lbClient参数");
  210. }
  211. ResObject<OrderTipsResultVo> res = null;
  212. if (client.equals("meituan")) {
  213. // res = dMeituanClient.orderAddTip(orderTipsVo);
  214. res = new ResObject<>();
  215. res.setCode(1);
  216. res.setMsg("美团配送不支持加小费接口");
  217. } else if (client.equals("dada")) {
  218. res = dadaClient.orderAddTip(orderTipsVo);
  219. } else if (client.equals("dadayz")) {
  220. res = dadaClient.orderAddTip(orderTipsVo);
  221. } else if (client.equals("fengniao")) {
  222. res = fengniaoClient.orderAddTip(orderTipsVo);
  223. } else if (client.equals("shansong")) {
  224. if (orderTipsVo.getIsShansongSH()) {
  225. res = shansongClient.orderAddTip(orderTipsVo); //加价接口
  226. } else {
  227. res = shansongSHClient.orderAddTip(orderTipsVo); //加价接口
  228. }
  229. } else if (client.equals("shunfeng")) {
  230. res = shunfengClient.orderAddTip(orderTipsVo);
  231. } else if (client.equals("dwd")) {
  232. res = dianwodaClient.dianwodaAddTips(orderTipsVo);
  233. } else if (client.equals("uupt")) {
  234. res = uuptClient.orderAddTip(orderTipsVo);
  235. } else if (client.equals("kuanfu")) {
  236. res = kfClient.orderAddTip(orderTipsVo);
  237. } else if (client.equals("huolala")){
  238. res =huolalaClient.orderAddTip(orderTipsVo);
  239. }
  240. else {
  241. throw new BusinessException("lbClient参数不正确");
  242. }
  243. return res;
  244. }
  245. /**
  246. * 订单查询
  247. *
  248. * @param orderQueryVo
  249. * @return
  250. */
  251. public ResObject<OrderQueryResultVo> queryOrderInfo(OrderQueryVo orderQueryVo) {
  252. String client = orderQueryVo.getLbClient();
  253. if (StringUtils.isBlank(client)) {
  254. throw new BusinessException("未指定lbClient参数");
  255. }
  256. ResObject<OrderQueryResultVo> res;
  257. if (client.equals("meituan")) {
  258. res = dMeituanClient.queryOrderInfo(orderQueryVo);
  259. } else if (client.equals("dada")) {
  260. res = dadaClient.queryOrderInfo(orderQueryVo);
  261. } else if (client.equals("dadayz")) {
  262. res = dadaClient.queryOrderInfo(orderQueryVo);
  263. } else if (client.equals("fengniao")) {
  264. // res = fengniaoClient.queryOrder(orderQueryVo);
  265. res = fengniaoClient.queryOrderInfo(orderQueryVo);
  266. } else if (client.equals("shansong")) {
  267. if (orderQueryVo.getIsShansongSH()) {
  268. res = shansongClient.queryOrderInfo(orderQueryVo);
  269. } else {
  270. res = shansongSHClient.queryOrderInfo(orderQueryVo);
  271. }
  272. } else if (client.equals("shunfeng")) {
  273. res = shunfengClient.queryOrderInfo(orderQueryVo);
  274. } else if (client.equals("dwd")) {
  275. res = dianwodaClient.dianwodaOrderQuery(orderQueryVo);
  276. } else if (client.equals("uupt")) {
  277. res = uuptClient.queryOrderInfo(orderQueryVo);
  278. } else if (client.equals("aipt")) {
  279. res = aiptClient.queryOrderInfo(orderQueryVo);
  280. }else if (client.equals("kuanfu")) {
  281. res = kfClient.queryOrderInfo(orderQueryVo);
  282. }else if (client.equals("huolala")) {
  283. res = huolalaClient.queryOrderInfo(orderQueryVo);
  284. } else {
  285. throw new BusinessException("lbClient参数不正确");
  286. }
  287. return res;
  288. }
  289. /**
  290. * 获取骑手当前位置(信息)
  291. *
  292. * @param riderLocationVo
  293. * @return
  294. */
  295. public ResObject<RiderLocationResultVo> getRiderLocation(RiderLocationVo riderLocationVo) {
  296. String client = riderLocationVo.getLbClient();
  297. if (StringUtils.isBlank(client)) {
  298. throw new BusinessException("未指定lbClient参数");
  299. }
  300. ResObject<RiderLocationResultVo> res = null;
  301. if (client.equals("meituan")) {
  302. res = dMeituanClient.getRiderLocation(riderLocationVo);
  303. } else if (client.equals("dada")) {
  304. riderLocationVo.setIsDirectDelivery(0);
  305. res = dadaClient.getRiderLocation(riderLocationVo);
  306. } else if (client.equals("dadayz")) {
  307. riderLocationVo.setIsDirectDelivery(1);
  308. res = dadaClient.getRiderLocation(riderLocationVo);
  309. } else if (client.equals("fengniao")) {
  310. //res = fengniaoClient.queryCarrier(riderLocationVo);
  311. res = fengniaoClient.getRiderLocation(riderLocationVo);
  312. } else if (client.equals("shansong")) {
  313. if (riderLocationVo.getIsShansongSH()) {
  314. res = shansongClient.getRiderLocation(riderLocationVo); //加价接口
  315. } else {
  316. res = shansongSHClient.getRiderLocation(riderLocationVo); //加价接口
  317. }
  318. } else if (client.equals("shunfeng")) {
  319. res = shunfengClient.getRiderLocation(riderLocationVo);
  320. } else if (client.equals("dwd")) {
  321. res = dianwodaClient.dianwodaQueryPosition(riderLocationVo);
  322. } else {
  323. throw new BusinessException("lbClient参数不正确");
  324. }
  325. return res;
  326. }
  327. /**
  328. * 创建门店
  329. *
  330. * @param shopVo
  331. * @return
  332. */
  333. public ResObject<ShopResultVo> createShop(ShopVo shopVo) {
  334. String client = shopVo.getLbClient();
  335. if (StringUtils.isBlank(client)) {
  336. throw new BusinessException("未指定lbClient参数");
  337. }
  338. ResObject<ShopResultVo> res = null;
  339. if (client.equals("meituan")) {
  340. res = dMeituanClient.createShop(shopVo);
  341. } else if (client.equals("meituanzb")) {
  342. res = new ResObject<>();
  343. res.setCode(1);
  344. res.setMsg("众包没有相应的接口");
  345. } else if (client.equals("dada")) {
  346. shopVo.setIsDirectDelivery(0);
  347. res = dadaClient.createShop(shopVo);
  348. } else if (client.equals("dadayz")) {
  349. shopVo.setIsDirectDelivery(1);
  350. res = dadaClient.createShop(shopVo);
  351. } else if (client.equals("fengniao")) {
  352. //res =fengniaoClient.addChainStore(shopVo);
  353. res = fengniaoClient.createShop(shopVo);
  354. } else if (client.equals("shansong")) {
  355. if (shopVo.getIsShansongSH()) {
  356. res = shansongClient.createShop(shopVo);
  357. } else {
  358. res = shansongSHClient.createShop(shopVo);
  359. }
  360. } else if (client.equals("shunfeng")) {
  361. res = new ResObject<>();
  362. res.setCode(1);
  363. res.setMsg("顺丰没有相应的接口");
  364. //顺丰没有相应的接口
  365. // return null;
  366. } else if (client.equals("uupt")) {
  367. res = new ResObject<>();
  368. res.setCode(1);
  369. res.setMsg("UU跑腿没有相应的接口");
  370. } else if (client.equals("kuanfu")) {
  371. res = new ResObject<>();
  372. res.setCode(1);
  373. res.setMsg("快服没有相应的接口");
  374. } else if (client.equals("dwd")) {
  375. res = dianwodaClient.dianwodaCreateShop(shopVo);
  376. } else if (client.equals("huolala")) {
  377. res = new ResObject<>();
  378. res.setCode(1);
  379. res.setMsg("货拉拉没有相应的接口");
  380. } else {
  381. //顺丰没有相应的接口
  382. throw new BusinessException("lbClient参数不正确");
  383. }
  384. return res;
  385. }
  386. /**
  387. * 更新门店
  388. *
  389. * @param shopVo
  390. * @return
  391. */
  392. public ResObject<ShopResultVo> updateShop(ShopVo shopVo) {
  393. String client = shopVo.getLbClient();
  394. if (StringUtils.isBlank(client)) {
  395. throw new BusinessException("未指定lbClient参数");
  396. }
  397. ResObject<ShopResultVo> res = null;
  398. if (client.equals("meituan")) {
  399. res = dMeituanClient.updateShop(shopVo);
  400. }else if (client.equals("meituanzb")) {
  401. res = new ResObject<>();
  402. res.setCode(1);
  403. res.setMsg("众包没有相应的接口");
  404. } else if (client.equals("dada")) {
  405. shopVo.setIsDirectDelivery(0);
  406. res = dadaClient.updateShop(shopVo);
  407. } else if (client.equals("dadayz")) {
  408. shopVo.setIsDirectDelivery(1);
  409. res = dadaClient.updateShop(shopVo);
  410. } else if (client.equals("fengniao")) {
  411. res = fengniaoClient.updateShop(shopVo);
  412. } else if (client.equals("shansong")) {
  413. if (shopVo.getIsShansongSH()) {
  414. res = shansongClient.createShop(shopVo);
  415. } else {
  416. res = shansongSHClient.createShop(shopVo);
  417. }
  418. } else if (client.equals("shunfeng")) {
  419. res = new ResObject<>();
  420. res.setCode(1);
  421. res.setMsg("顺丰没有相应的接口");
  422. //顺丰没有相应的接口
  423. } else if (client.equals("huolala")) {
  424. res = new ResObject<>();
  425. res.setCode(1);
  426. res.setMsg("货拉拉没有相应的接口");
  427. //顺丰没有相应的接口
  428. } else {
  429. throw new BusinessException("lb_client参数不正确");
  430. }
  431. return res;
  432. }
  433. /**
  434. * 查询门店
  435. *
  436. * @param shopQueryVo
  437. * @return
  438. */
  439. public ResObject<ShopQueryResultVo> queryShop(ShopQueryVo shopQueryVo) {
  440. //JSONObject jsonParams = JSONObject.parseObject(jsonParamsStr);
  441. String client = shopQueryVo.getLbClient();
  442. if (StringUtils.isBlank(client)) {
  443. throw new BusinessException("未指定lbClient参数");
  444. }
  445. ResObject<ShopQueryResultVo> res = null;
  446. if (client.equals("meituan")) {
  447. res = dMeituanClient.queryShop(shopQueryVo);
  448. } else if (client.equals("dada")) {
  449. shopQueryVo.setIsDirectDelivery(0);
  450. res = dadaClient.queryShop(shopQueryVo);
  451. } else if (client.equals("dadayz")) {
  452. shopQueryVo.setIsDirectDelivery(1);
  453. res = dadaClient.queryShop(shopQueryVo);
  454. } else if (client.equals("fengniao")) {
  455. // res = fengniaoClient.queryChainStore(shopQueryVo);
  456. res = fengniaoClient.queryShop(shopQueryVo);
  457. } else if (client.equals("shansong")) {
  458. if (shopQueryVo.getIsShansongSH()) {
  459. res = shansongClient.queryShop(shopQueryVo);
  460. } else {
  461. res = shansongSHClient.queryShop(shopQueryVo);
  462. }
  463. } else if (client.equals("shunfeng")) {
  464. res = new ResObject<>();
  465. res.setCode(1);
  466. res.setMsg("顺丰没有相应的接口");
  467. } else {
  468. throw new BusinessException("lbClient参数不正确");
  469. }
  470. return res;
  471. }
  472. /**
  473. * 查询商户余额
  474. *
  475. * @param queryAmount
  476. * @return
  477. */
  478. public ResObject<AmountResultVo> queryAmount(QueryAmount queryAmount) {
  479. String client = queryAmount.getLbClient();
  480. if (StringUtils.isBlank(client)) {
  481. throw new BusinessException("未指定lbClient参数");
  482. }
  483. ResObject<AmountResultVo> res = null;
  484. String msg = "";
  485. if (client.equals("meituan")) {
  486. msg = "美团没有相应的接口";
  487. } else if (client.equals("meituanzb")) {
  488. msg = "美团众包没有相应的接口";
  489. } else if (client.equals("dada")) {
  490. queryAmount.setIsDirectDelivery(0);
  491. res = dadaClient.queryAmount(queryAmount);
  492. } else if (client.equals("dadayz")) {
  493. queryAmount.setIsDirectDelivery(1);
  494. res = dadaClient.queryAmount(queryAmount);
  495. } else if (client.equals("fengniao")) {
  496. // res = fengniaoClient.queryOrder(orderQueryVo);
  497. res = fengniaoClient.queryAmount(queryAmount);
  498. } else if (client.equals("shansong")) {
  499. if (queryAmount.getIsShansongSH()) {
  500. res = shansongClient.queryAmount(queryAmount);
  501. } else {
  502. res = shansongSHClient.queryAmount(null);
  503. }
  504. } else if (client.equals("shunfeng")) {
  505. msg = "顺丰没有相应的接口";
  506. } else if (client.equals("dwd")) {
  507. msg = "dwd没有相应的接口";
  508. } else if (client.equals("uupt")) {
  509. res = uuptClient.queryAmount(queryAmount);
  510. } else if (client.equals("aipt")) {
  511. res = aiptClient.queryAmount(queryAmount);
  512. }else if (client.equals("kuanfu")) {
  513. msg = "快服没有相应的接口";
  514. } else {
  515. throw new BusinessException("lbClient参数不正确");
  516. }
  517. if (null == res) {
  518. res = new ResObject<>();
  519. res.setCode(1);
  520. res.setMsg(msg);
  521. }
  522. return res;
  523. }
  524. }