OrderController.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LikeShop有特色的全开源社交分销电商系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
  7. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  8. // | 微信公众号:好象科技
  9. // | 访问官网:http://www.likemarket.net
  10. // | 访问社区:http://bbs.likemarket.net
  11. // | 访问手册:http://doc.likemarket.net
  12. // | 好象科技开发团队 版权所有 拥有最终解释权
  13. // +----------------------------------------------------------------------
  14. // | Author: LikeShopTeam-段誉
  15. // +----------------------------------------------------------------------
  16. namespace app\shopapi\controller;
  17. use app\common\model\Order;
  18. use app\common\service\WechatMiniExpressSendSyncService;
  19. use app\shopapi\lists\OrderLists;
  20. use app\shopapi\logic\Order\OrderLogic;
  21. use app\shopapi\validate\PlaceOrderValidate;
  22. use app\shopapi\validate\OrderValidate;
  23. /**
  24. * 订单
  25. * Class OrderController
  26. * @package app\shopapi\controller
  27. */
  28. class OrderController extends BaseShopController
  29. {
  30. /**
  31. * @notes 提交订单/结算详情
  32. * @return \think\response\Json
  33. * @author 段誉
  34. * @date 2021/7/23 15:52
  35. */
  36. public function placeOrder()
  37. {
  38. $data = [
  39. 'terminal' => $this->userInfo['terminal'],
  40. 'user_id'=> $this->userId
  41. ];
  42. $params = (new PlaceOrderValidate())->post()->goCheck('', $data);
  43. //订单结算信息
  44. $settlement = OrderLogic::settlement($params);
  45. if (false === $settlement) {
  46. return $this->fail(OrderLogic::getError());
  47. }
  48. //结算信息
  49. if ($params['action'] == 'settle') {
  50. return $this->data($settlement);
  51. }
  52. //提交订单
  53. $result = OrderLogic::submitOrder($settlement);
  54. if (false === $result) {
  55. return $this->fail(OrderLogic::getError(), []);
  56. }
  57. return $this->data($result);
  58. }
  59. /**
  60. * @notes 订单列表
  61. * @return \think\response\Json
  62. * @author 段誉
  63. * @date 2021/7/23 18:58
  64. */
  65. public function lists()
  66. {
  67. return $this->dataLists((new OrderLists()));
  68. }
  69. /**
  70. * @notes 订单详情
  71. * @return \think\response\Json
  72. * @author 段誉
  73. * @date 2021/8/2 21:00
  74. */
  75. public function detail()
  76. {
  77. $params = (new OrderValidate())->goCheck('detail', ['user_id' => $this->userId]);
  78. return $this->data(OrderLogic::getDetail($params));
  79. }
  80. /**
  81. * @notes 取消订单
  82. * @return \think\response\Json
  83. * @author 段誉
  84. * @date 2021/8/2 16:37
  85. */
  86. public function cancel()
  87. {
  88. $params = (new OrderValidate())->post()->goCheck('cancel', ['user_id' => $this->userId]);
  89. $result = OrderLogic::cancelOrder($params);
  90. if (false === $result) {
  91. return $this->fail(OrderLogic::getError());
  92. }
  93. return $this->success('取消订单成功');
  94. }
  95. /**
  96. * @notes 确认收货
  97. * @return \think\response\Json
  98. * @author 段誉
  99. * @date 2021/8/2 15:21
  100. */
  101. public function confirm()
  102. {
  103. $params = (new OrderValidate())->post()->goCheck('confirm', ['user_id' => $this->userId]);
  104. OrderLogic::confirmOrder($params);
  105. return $this->success('确认收货成功');
  106. }
  107. /**
  108. * @notes 查看物流
  109. * @return \think\response\Json
  110. * @author ljj
  111. * @date 2021/8/13 6:08 下午
  112. */
  113. public function orderTraces()
  114. {
  115. $params = (new OrderValidate())->goCheck('OrderTraces', ['user_id' => $this->userId]);
  116. $result = OrderLogic::orderTraces($params);
  117. return $this->data($result);
  118. }
  119. /**
  120. * @notes 获取配送方式
  121. * @return \think\response\Json
  122. * @author ljj
  123. * @date 2021/8/27 2:33 下午
  124. */
  125. public function getDeliveryType()
  126. {
  127. $result = (new OrderLogic())->getDeliveryType();
  128. return $this->success('',$result);
  129. }
  130. /**
  131. * @notes 删除订单
  132. * @return \think\response\Json
  133. * @author ljj
  134. * @date 2021/8/31 2:38 下午
  135. */
  136. public function del()
  137. {
  138. $params = (new OrderValidate())->post()->goCheck('del', ['user_id' => $this->userId]);
  139. (new OrderLogic())->del($params);
  140. return $this->success('删除成功',[],1,1);
  141. }
  142. /**
  143. * @notes 微信同步发货 查询
  144. * @return \think\response\Json
  145. * @author lbzy
  146. * @datetime 2023-09-07 15:27:17
  147. */
  148. function wechatSyncCheck()
  149. {
  150. $id = $this->request->get('id');
  151. $order = Order::where('id', $id)->where('user_id', $this->userId)->findOrEmpty();
  152. $result = WechatMiniExpressSendSyncService::wechatSyncCheck($order);
  153. if (! $result) {
  154. return $this->fail('获取失败', [], 0, 0);
  155. }
  156. return $this->success('成功', $result);
  157. }
  158. /**
  159. * @notes 微信确认收货 获取详情
  160. * @return \think\response\Json
  161. * @author lbzy
  162. * @datetime 2023-09-05 09:51:41
  163. */
  164. function wxReceiveDetail()
  165. {
  166. return $this->success('获取成功', OrderLogic::wxReceiveDetail(input('order_id/d'), $this->userId));
  167. }
  168. }