You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OrderController.php 2.6KB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace app\controller\api\pc;
  3. use app\Request;
  4. use app\services\order\StoreOrderRefundServices;
  5. use app\services\order\StoreOrderServices;
  6. use app\services\pc\OrderServices;
  7. class OrderController
  8. {
  9. protected $services;
  10. public function __construct(OrderServices $services)
  11. {
  12. $this->services = $services;
  13. }
  14. /**
  15. * 轮询订单状态
  16. * @param Request $request
  17. * @return mixed
  18. */
  19. public function checkOrderStatus(Request $request)
  20. {
  21. list($order_id, $end_time) = $request->getMore([
  22. ['order_id', ''],
  23. ['end_time', ''],
  24. ], true);
  25. $data['status'] = $this->services->checkOrderStatus((string)$order_id);
  26. $time = $end_time - time();
  27. $data['time'] = $time > 0 ? $time : 0;
  28. return app('json')->successful($data);
  29. }
  30. /**
  31. * 获取订单列表
  32. * @param Request $request
  33. * @return mixed
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. */
  38. public function getOrderList(Request $request)
  39. {
  40. $where = $request->getMore([
  41. ['type', '', '', 'status'],
  42. ['search', '', '', 'real_name'],
  43. ]);
  44. $where['uid'] = $request->uid();
  45. $where['is_del'] = 0;
  46. $where['is_system_del'] = 0;
  47. if (!in_array($where['status'], [-1, -2, -3])) $where['pid'] = 0;
  48. return app('json')->successful($this->services->getOrderList($where));
  49. }
  50. /**
  51. * 获取退货商品列表
  52. * @param StoreOrderCartInfoServices $services
  53. * @param $id
  54. * @return mixed
  55. */
  56. public function refundCartInfoList(Request $request, StoreOrderServices $services)
  57. {
  58. [$cart_ids, $id] = $request->postMore([
  59. ['cart_ids', ''],
  60. ['id', 0],
  61. ], true);
  62. if (!$id) {
  63. return app('json')->fail('缺少发货ID');
  64. }
  65. $cart_id = [];
  66. if ($cart_ids) $cart_id[] = ['cart_id' => $cart_ids];
  67. return app('json')->success($services->refundCartInfoList((array)$cart_id, (int)$id));
  68. }
  69. /**
  70. * 订单列表
  71. * @param Request $request
  72. * @return mixed
  73. */
  74. public function refundList(Request $request, StoreOrderRefundServices $services)
  75. {
  76. $where = $request->getMore([
  77. ['refund_type', '', '', 'refundTypes']
  78. ]);
  79. $where['uid'] = $request->uid();
  80. $where['is_cancel'] = 0;
  81. $data['list'] = $services->getRefundOrderList($where);
  82. $data['count'] = $services->count($where);
  83. return app('json')->successful($data);
  84. }
  85. }