merchants.user_id 关联获取 */ public function getMerchantId(): int { if ($this->_merchantId === null) { $userId = Auth::id(); $merchant = MerchantStoreModel::where('user_id', $userId)->first(['id']); if (!$merchant) { $this->throwError('商户信息不存在,请联系管理员'); } $this->_merchantId = $merchant->id; } return $this->_merchantId; } /** * 获取当前登录商户的完整模型 */ public function getMerchant(): MerchantStoreModel { $userId = Auth::id(); $merchant = MerchantStoreModel::where('user_id', $userId)->first(); if (!$merchant) { $this->throwError('商户信息不存在,请联系管理员'); } return $merchant; } }