params['ptStyle'] = dict::getDict('ptStyle', 'hd'); //token验证 $adminId = jwt::getLoginId(); if (getenv('YII_ENV', 'local') != 'production') { //$adminId = 253; } if (empty($adminId) && in_array($action->id, $this->guestAccess) == false) { util::notLogin(); } $admin = AdminClass::getById($adminId, true); if (empty($admin) && in_array($action->id, $this->guestAccess) == false) { util::notLogin(); } $adminId = $admin->id ?? 0; $this->admin = $admin; $this->adminId = $adminId; //后台 $currentShopId = $admin->currentShopId ?? 0; if (empty($currentShopId)) { if (in_array($action->id, $this->guestAccess) == false) { util::fail('请注册登录'); } } else { $this->shopId = $currentShopId; $shop = ShopService::getById($currentShopId, true); if (empty($shop)) { util::fail('没有找到店铺'); } $this->shop = $shop; $mainId = $shop->mainId ?? 0; $this->mainId = $mainId; $main = MainClass::getById($mainId, true); if (empty($main)) { util::fail('没有找到main信息'); } $this->main = $main; $shopAdmin = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId, 'delStatus' => 0], true); if (empty($shopAdmin)) { util::logout('没有找到员工信息'); } if (isset($shopAdmin->delStatus) == false || $shopAdmin->delStatus == 1) { util::fail('您不是本店员工哦'); } if (isset($shopAdmin->status) == false || $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 = MerchantExtendClass::getBySjId($sjId, true); $this->sjExtend = $sjExtend; } return parent::beforeAction($action); } }