admin = $admin; $this->adminId = $adminId; $header = httpUtil::getHeader(); $shopId = $header['shop-id'] ?? 0; if (!empty($shopId)) { //商城 if (in_array($action->id, $this->guestAccessAction) == false) { util::fail('您没有权限访问哦'); } $shop = ShopClass::getById($shopId); if (empty($shop)) { util::fail('没有找到店铺'); } $sjId = $shop['merchantId'] ?? 0; $custom = CustomClass::getCustom(['sjId' => $sjId, 'adminId' => $adminId]); $customId = $custom['id'] ?? 0; if (empty($customId)) { util::fail('没有找到客户信息'); } $this->custom = $custom; $this->customId = $customId; $this->sjId = $sjId; $sj = MerchantService::getMerchantById($sjId); $this->sj = $sj; $this->sjExtend = MerchantExtendClass::getByMerchantId($sjId); } else { //后台 $currentShopId = $admin['currentShopId'] ?? 0; if (empty($currentShopId) && in_array($action->id, $this->guestAccessAction) == false) { util::fail('您没有权限访问哦~'); } $this->shopId = $currentShopId; $shop = ShopService::getById($currentShopId); if (empty($shop)) { util::fail('没有找到店铺'); } $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId, 'delStatus' => 0]); if (empty($shopAdmin)) { util::fail('没有找到员工信息'); } $this->shopAdmin = $shopAdmin; $this->shopAdminId = $shopAdmin['id'] ?? 0; $sjId = $shop['merchantId']; $this->sjId = $sjId; $sj = MerchantService::getMerchantById($sjId); $this->sj = $sj; $sjExtend = MerchantExtendClass::getByMerchantId($sjId); $this->sjExtend = $sjExtend; } return parent::beforeAction($action); } }