From 6c7b1ae4c055a97cdc48cf6f5e1171af7ad9674e Mon Sep 17 00:00:00 2001 From: guojia <445241500@qq.com> Date: Tue, 30 Apr 2024 13:33:22 +0800 Subject: [PATCH] 1 --- app/api/controller/Merchant.php | 4 ++-- app/store/controller/Controller.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/api/controller/Merchant.php b/app/api/controller/Merchant.php index c9f1c23c..066b5fbe 100644 --- a/app/api/controller/Merchant.php +++ b/app/api/controller/Merchant.php @@ -77,10 +77,10 @@ class Merchant extends Controller } - public function detail(int $merchantId): Json + public function detail(int $id): Json { // 获取商品详情 - $detail = MerchantModel::detail($merchantId); + $detail = MerchantModel::detail($id); return $this->renderSuccess(compact('detail')); } diff --git a/app/store/controller/Controller.php b/app/store/controller/Controller.php index 577d18fc..a2e75084 100644 --- a/app/store/controller/Controller.php +++ b/app/store/controller/Controller.php @@ -33,7 +33,7 @@ class Controller extends BaseController protected int $storeId; // 当前商户ID - protected int $merchantId; + protected int $merchantId = 0; // 当前控制器名称 protected string $controller = ''; @@ -157,8 +157,9 @@ class Controller extends BaseController protected function getMerchantId() { $user = StoreUserService::getLoginInfo(); - - $this->merchantId = MerchantModel::getMerchantId($user['user']['user_name']); + if (!empty($user)) { + $this->merchantId = MerchantModel::getMerchantId($user['user']['user_name']); + } } /**