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.
33 lines
909 B
33 lines
909 B
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Request\OrderOnlineRequest;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use App\Service\OrderServiceInterface;
|
|
use Hyperf\HttpMessage\Stream\SwooleStream;
|
|
|
|
class OrderController extends BaseController
|
|
{
|
|
|
|
/**
|
|
* @Inject
|
|
* @var OrderServiceInterface
|
|
*/
|
|
protected $orderService;
|
|
|
|
public function addOnlineOrder(OrderOnlineRequest $request)
|
|
{
|
|
$orderMainId = $this->orderService->addOnlineOrder($request->validated());
|
|
if (!is_int($orderMainId)) {
|
|
return $this->response
|
|
->withHeader('Content-Type', 'application/text')
|
|
->withStatus(500)
|
|
->withBody(new SwooleStream($orderMainId));
|
|
}
|
|
return $this->response
|
|
->withHeader('Content-Type', 'application/text')
|
|
->withStatus(200)
|
|
->withBody(new SwooleStream($orderMainId));
|
|
}
|
|
}
|