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']); + } } /**