diff --git a/app/common/model/Merchant.php b/app/common/model/Merchant.php index 495d57a0..d1e52e8c 100644 --- a/app/common/model/Merchant.php +++ b/app/common/model/Merchant.php @@ -51,16 +51,15 @@ class Merchant extends BaseModel * @param int $storeId * @return static|array|null */ - public static function getMerchantId(int $merchantId) + public static function getMerchantId(String $userName) { try { - $list = self::withoutGlobalScope() - ->with(['logoImage', "licenseImage"]) - ->where('merchant_id', '=', $merchantId) + $info = self::withoutGlobalScope() + ->where('user_name', '=', $userName) ->find(); - return $list ?? null; + return $info['merchant_id'] ?? 0; } catch (\Exception $e) { - return null; + return 0; } } diff --git a/app/store/controller/Controller.php b/app/store/controller/Controller.php index 43946447..577d18fc 100644 --- a/app/store/controller/Controller.php +++ b/app/store/controller/Controller.php @@ -157,9 +157,8 @@ class Controller extends BaseController protected function getMerchantId() { $user = StoreUserService::getLoginInfo(); - print_r($user);die; - $this->merchantId = MerchantModel::getMerchantId(); + $this->merchantId = MerchantModel::getMerchantId($user['user']['user_name']); } /**