OrderController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\workerapi\controller\shops;
  3. use app\workerapi\controller\BaseApiController;
  4. use app\workerapi\lists\shops\ShopOrderLists;
  5. use app\workerapi\logic\shops\ShopOrderLogic;
  6. use app\workerapi\validate\shops\ShopOrderValidate;
  7. /**
  8. * 商城订单
  9. */
  10. class OrderController extends BaseApiController
  11. {
  12. public function lists()
  13. {
  14. return $this->dataLists(new ShopOrderLists());
  15. }
  16. public function detail()
  17. {
  18. $params = (new ShopOrderValidate())->goCheck('detail',[
  19. 'worker_id' => $this->userId,
  20. ]);
  21. $result = ShopOrderLogic::detail($params);
  22. if (false === $result) {
  23. return $this->fail(ShopOrderLogic::getError());
  24. }
  25. return $this->data($result);
  26. }
  27. /**
  28. * 取消订单
  29. */
  30. public function cancelOrder()
  31. {
  32. $params = (new ShopOrderValidate())->goCheck('detail',[
  33. 'worker_id' => $this->userId,
  34. ]);
  35. $result = ShopOrderLogic::cancelOrder($params);
  36. if (false === $result) {
  37. return $this->fail(ShopOrderLogic::getError());
  38. }
  39. return $this->success('取消成功', [], 1, 1);
  40. }
  41. }