From 88ee75143e04fbd26b856e63ebacc965097a8174 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Tue, 11 Feb 2025 11:14:35 +0800 Subject: [PATCH] feat: sku --- app/Controller/Api/OrderController.php | 23 +++++++++++++++++--- app/Service/Api/Good/OptionalListService.php | 13 ++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/Controller/Api/OrderController.php b/app/Controller/Api/OrderController.php index 07cce0e..9c379eb 100644 --- a/app/Controller/Api/OrderController.php +++ b/app/Controller/Api/OrderController.php @@ -13,13 +13,20 @@ use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\Middlewares; use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\Validation\Annotation\Scene; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; #[Controller(prefix: 'api/order')] -//#[Middlewares([ -// JwtAuthMiddleware::class, -//])] +#[Middlewares([ + JwtAuthMiddleware::class, +])] class OrderController extends AbstractController { + /** + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ #[RequestMapping(path: 'check_cart',methods: 'post')] #[Scene(scene: 'check_cart')] public function checkCart() @@ -27,6 +34,11 @@ class OrderController extends AbstractController return (new CheckCartService)->handle(); } + /** + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ #[RequestMapping(path: 'confirmation_order',methods: 'post')] #[Scene(scene: 'confirmation_order')] public function confirmationOrder() @@ -34,6 +46,11 @@ class OrderController extends AbstractController return (new ConfirmationOrderService)->handle(); } + /** + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ #[RequestMapping(path: 'place_order',methods: 'post')] #[Scene(scene: 'place_order')] public function placeOrder() diff --git a/app/Service/Api/Good/OptionalListService.php b/app/Service/Api/Good/OptionalListService.php index 72bafec..59e0e51 100644 --- a/app/Service/Api/Good/OptionalListService.php +++ b/app/Service/Api/Good/OptionalListService.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace App\Service\Api\Good; use App\Cache\Redis\Api\GoodCache; +use App\Cache\Redis\Api\SiteCache; use App\Service\Api\BaseService; use App\Service\ServiceTrait\Common\CycleTrait; use Hyperf\Di\Annotation\Inject; @@ -27,6 +28,12 @@ class OptionalListService extends BaseService #[Inject] protected GoodCache $goodCache; + /** + * @var SiteCache + */ + #[Inject] + protected SiteCache $siteCache; + /** * @return array * @throws ContainerExceptionInterface @@ -39,7 +46,11 @@ class OptionalListService extends BaseService if (empty($cycleId)) return ['list' => []]; $this->goodCache->cycleId = (int)$cycleId; - $this->goodCache->kitchenId = (int)$this->request->input('kitchen_id'); + $siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id')); + + if (empty($siteInfo) || empty($siteInfo['kitchen_id'])) return ['list' => []]; + + $this->goodCache->kitchenId = $siteInfo['kitchen_id']; $data = $this->goodCache->getOptionalGoodList(); return $this->return->success('success', ['list' => $data]);