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.

89 lines
3.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Constants\v3\ErrorCode;
  4. use App\Constants\v3\LogLabel;
  5. use App\Controller\BaseController;
  6. use App\Exception\ErrorCodeException;
  7. use App\Model\v3\OrderMain;
  8. use App\Service\v3\Interfaces\HorsemanServiceInterface;
  9. use App\Service\v3\Interfaces\SeparateAccountsServiceInterface;
  10. use Hyperf\DbConnection\Db;
  11. use Hyperf\Di\Annotation\Inject;
  12. use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
  13. use App\Request\v3\EmployeesRequest;
  14. use App\Request\v3\HorsemanOrderRequest;
  15. class HorsemanController extends BaseController
  16. {
  17. /**
  18. * @Inject
  19. * @var HorsemanServiceInterface
  20. */
  21. protected $horsemanService;
  22. /**
  23. * @Inject
  24. * @var OrderOnlineServiceInterface
  25. */
  26. protected $orderOnlineService;
  27. /**
  28. * @Inject
  29. * @var SeparateAccountsServiceInterface
  30. */
  31. protected $separateAccountsService;
  32. public function getOrderList(EmployeesRequest $request)
  33. {
  34. $employeesId = $this->request->input('employees_id', -1);
  35. $page = $this->request->input('page',0);
  36. $pagesize = $this->request->input('pagesize',0);
  37. $orderMainList = $this->horsemanService->getOrderList($employeesId,$page, $pagesize);
  38. return $this->success($orderMainList);
  39. }
  40. public function getOrderInfo(HorsemanOrderRequest $request)
  41. {
  42. $globalOrderId = $this->request->input('global_order_id', -1);
  43. $orderMain = $this->orderOnlineService->getOrderInfo($globalOrderId);
  44. return $this->success(['order' => $orderMain]);
  45. }
  46. public function setHorsemanCoordinate(EmployeesRequest $request)
  47. {
  48. $employeesId = $this->request->input('employees_id', -1);
  49. $coordinate = $this->request->input('coordinate', -1);
  50. return $this->success($this->horsemanService->setHorsemanCoordinate($employeesId,$coordinate));
  51. }
  52. public function getHorsemanCoordinate(EmployeesRequest $request)
  53. {
  54. $employeesId = $this->request->input('employees_id', -1);
  55. $coordinate = $this->horsemanService->getHorsemanCoordinate($employeesId);
  56. return $this->success(['coordinate' => $coordinate]);
  57. }
  58. public function getOrderCoordinate()
  59. {
  60. $globalOrderId = $this->request->input('global_order_id', -1);
  61. return $this->success($this->horsemanService->getOrderCoordinate($globalOrderId));
  62. }
  63. public function orderComplete(HorsemanOrderRequest $request)
  64. {
  65. $globalOrderId = $this->request->input('global_order_id', -1);
  66. $userId = OrderMain::query()->where('global_order_id',$globalOrderId)->value('user_id');
  67. Db::beginTransaction();
  68. try {
  69. $this->orderOnlineService->doComplete($globalOrderId, $userId);
  70. $this->separateAccountsService->orderOnlineCompleted($globalOrderId, $userId);
  71. Db::commit();
  72. return $this->success(true);
  73. } catch (\Exception $e) {
  74. Db::rollBack();
  75. $this->log->event(LogLabel::ORDER_COMPLETE_LOG, ['exception' => $e->getMessage()]);
  76. throw new ErrorCodeException(ErrorCode::ORDER_COMPLETE_FAIL);
  77. }
  78. }
  79. }