diff --git a/app/common/model/GoodsCategoryRel.php b/app/common/model/GoodsCategoryRel.php index d9dc33a9..a5b25ba9 100644 --- a/app/common/model/GoodsCategoryRel.php +++ b/app/common/model/GoodsCategoryRel.php @@ -41,7 +41,7 @@ class GoodsCategoryRel extends BaseModel $dataset = []; foreach ($categoryIds as $categoryId) { $dataset[] = [ - 'category_id' => $categoryId, + 'category_id' => $categoryId ?? 0, 'goods_id' => $goodsId, 'store_id' => $storeId ?: self::$storeId ]; diff --git a/app/common/model/Merchant.php b/app/common/model/Merchant.php index 69b03669..495d57a0 100644 --- a/app/common/model/Merchant.php +++ b/app/common/model/Merchant.php @@ -46,6 +46,24 @@ class Merchant extends BaseModel return $this->HasMany('UploadFile', 'file_id', 'license_img_id'); } + /** + * 详情信息 + * @param int $storeId + * @return static|array|null + */ + public static function getMerchantId(int $merchantId) + { + try { + $list = self::withoutGlobalScope() + ->with(['logoImage', "licenseImage"]) + ->where('merchant_id', '=', $merchantId) + ->find(); + return $list ?? null; + } catch (\Exception $e) { + return null; + } + } + /** * 详情信息 diff --git a/app/store/controller/Controller.php b/app/store/controller/Controller.php index 6ae4e2df..43946447 100644 --- a/app/store/controller/Controller.php +++ b/app/store/controller/Controller.php @@ -17,6 +17,7 @@ use cores\BaseController; use app\store\service\Auth as AuthService; use app\common\service\store\User as StoreUserService; use cores\exception\BaseException; +use app\common\model\Merchant as MerchantModel; /** * 商户后台控制器基类 @@ -81,6 +82,8 @@ class Controller extends BaseController $this->checkPrivilege(); // 强制验证当前访问的控制器方法method $this->checkMethodRules(); + + $this->getMerchantId(); } /** @@ -148,6 +151,17 @@ class Controller extends BaseController $this->storeId = $this->request->storeId(); } + /** + * 获取当前登录的商城ID + */ + protected function getMerchantId() + { + $user = StoreUserService::getLoginInfo(); + print_r($user);die; + + $this->merchantId = MerchantModel::getMerchantId(); + } + /** * 强制验证当前访问的控制器方法method * @return void