admin = $admin; $this->adminId = $adminId; $header = httpUtil::getHeader(); $shopId = $header['shop-id'] ?? 0; if (!empty($shopId)) { $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); if (in_array($action->id, $this->guestAccessAction) == false) { util::fail('此商家的页面,您没有权限访问'); } } else { $currentShopId = $admin['currentShopId'] ?? 0; if (!empty($currentShopId)) { $shop = ShopService::getById($currentShopId); $sjId = $shop['merchantId']; $sj = MerchantService::getMerchantById($sjId); $this->sj = $sj; $this->shopId = $currentShopId; $this->sjId = $sjId; $this->sjExtend = MerchantExtendClass::getByMerchantId($sjId); } else { if (in_array($action->id, $this->guestAccessAction) == false) { util::fail('此管理后台页面,您没有权限访问'); } } } return parent::beforeAction($action); } }