params['ptStyle'] = dict::getDict('ptStyle', 'ghs'); //token验证 $adminId = jwt::getLoginId(); if (getenv('YII_ENV', 'local') != 'production') { //$adminId = 18; } if (empty($adminId)) { util::notLogin(); } $this->adminId = $adminId; $admin = AdminService::getById($adminId, true); if (empty($admin)) { util::logout('帐号无效'); } $this->admin = $admin; // 只能供应商访问 if ($admin->style != AdminClass::STYLE_GHS) { util::fail('您没有权限访问哦'); } //后台 $currentShopId = $admin->currentShopId ?? 0; if (empty($currentShopId)) { if (in_array($action->id, $this->guestAccess) == false) { util::fail('您没有权限访问哦!'); } } else { $this->shopId = $currentShopId; $shop = ShopClass::getById($currentShopId, true); $this->shop = $shop; if (empty($shop)) { util::fail('没有找到您管理的门店'); } $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId, 'delStatus' => 0], true); if (empty($shopAdmin)) { util::logout('没有找到员工信息'); } if (isset($shopAdmin->delStatus) && $shopAdmin->delStatus == 1) { util::fail('您还不是员工哦'); } if (isset($shopAdmin->status) && $shopAdmin->status == 0) { util::fail('您的帐号已被禁用'); } $this->shopAdmin = $shopAdmin; $this->shopAdminId = $shopAdmin->id ?? 0; $sjId = $shop->sjId; $this->sjId = $sjId; $sj = SjClass::getById($sjId, true); $this->sj = $sj; $sjExtend = MerchantExtendService::getBySjId($sjId, true); $this->sjExtend = $sjExtend; } return parent::beforeAction($action); } }