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.

32 lines
909 B

6 years ago
6 years ago
  1. <?php
  2. namespace App\Controller;
  3. use App\Request\OrderOnlineRequest;
  4. use Hyperf\Di\Annotation\Inject;
  5. use App\Service\OrderServiceInterface;
  6. use Hyperf\HttpMessage\Stream\SwooleStream;
  7. class OrderController extends BaseController
  8. {
  9. /**
  10. * @Inject
  11. * @var OrderServiceInterface
  12. */
  13. protected $orderService;
  14. public function addOnlineOrder(OrderOnlineRequest $request)
  15. {
  16. $orderMainId = $this->orderService->addOnlineOrder($request->validated());
  17. if (!is_int($orderMainId)) {
  18. return $this->response
  19. ->withHeader('Content-Type', 'application/text')
  20. ->withStatus(500)
  21. ->withBody(new SwooleStream($orderMainId));
  22. }
  23. return $this->response
  24. ->withHeader('Content-Type', 'application/text')
  25. ->withStatus(200)
  26. ->withBody(new SwooleStream($orderMainId));
  27. }
  28. }