OrderController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\pc\OrderServices;
  14. class OrderController
  15. {
  16. protected $services;
  17. public function __construct(OrderServices $services)
  18. {
  19. $this->services = $services;
  20. }
  21. /**
  22. * 轮询订单状态
  23. * @param Request $request
  24. * @return mixed
  25. */
  26. public function checkOrderStatus(Request $request)
  27. {
  28. list($order_id, $end_time) = $request->getMore([
  29. ['order_id', ''],
  30. ['end_time', ''],
  31. ], true);
  32. $data['status'] = $this->services->checkOrderStatus((string)$order_id);
  33. $time = $end_time - time();
  34. $data['time'] = $time > 0 ? $time : 0;
  35. return app('json')->successful($data);
  36. }
  37. /**
  38. * 获取订单列表
  39. * @param Request $request
  40. * @return mixed
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\DbException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. */
  45. public function getOrderList(Request $request)
  46. {
  47. $where = $request->getMore([
  48. ['type', '', '', 'status'],
  49. ['search', '', '', 'real_name'],
  50. ]);
  51. $where['uid'] = $request->uid();
  52. $where['is_del'] = 0;
  53. $where['is_system_del'] = 0;
  54. if (!in_array($where['status'], [-1, -2, -3])) $where['pid'] = 0;
  55. return app('json')->successful($this->services->getOrderList($where));
  56. }
  57. }