OrderController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\pc;
  12. use app\Request;
  13. use app\services\order\StoreOrderRefundServices;
  14. use app\services\pc\OrderServices;
  15. class OrderController
  16. {
  17. protected $services;
  18. public function __construct(OrderServices $services)
  19. {
  20. $this->services = $services;
  21. }
  22. /**
  23. * 轮询订单状态
  24. * @param Request $request
  25. * @return mixed
  26. */
  27. public function checkOrderStatus(Request $request)
  28. {
  29. list($order_id, $end_time) = $request->getMore([
  30. ['order_id', ''],
  31. ['end_time', ''],
  32. ], true);
  33. $data['status'] = $this->services->checkOrderStatus((string)$order_id);
  34. $time = $end_time - time();
  35. $data['time'] = $time > 0 ? $time : 0;
  36. return app('json')->success($data);
  37. }
  38. /**
  39. * 获取订单列表
  40. * @param Request $request
  41. * @return mixed
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. */
  46. public function getOrderList(Request $request)
  47. {
  48. $where = $request->getMore([
  49. ['type', '', '', 'status'],
  50. ['search', '', '', 'real_name'],
  51. ]);
  52. $where['uid'] = $request->uid();
  53. $where['is_del'] = 0;
  54. $where['is_system_del'] = 0;
  55. if (!in_array($where['status'], [-1, -2, -3])) $where['pid'] = 0;
  56. return app('json')->success($this->services->getOrderList($where));
  57. }
  58. /**
  59. * 退款单列表
  60. * @param Request $request
  61. * @param StoreOrderRefundServices $refundServices
  62. * @return mixed
  63. */
  64. public function getRefundOrderList(Request $request,StoreOrderRefundServices $refundServices)
  65. {
  66. $where['uid'] = $request->uid();
  67. $where['is_cancel'] = 0;
  68. $where['is_del'] = 0;
  69. $where['is_system_del'] = 0;
  70. $data = $refundServices->refundList($where);
  71. return app('json')->success($data);
  72. }
  73. }