params['ptStyle'] = 1; //token验证 $adminId = jwt::getLoginId(); if (empty($adminId)) { util::notLogin(); } $admin = AdminClass::getAdminById($adminId); if (empty($admin)) { util::notLogin(); } $adminId = $admin['id']; $this->admin = $admin; $this->adminId = $adminId; // 只能供货商访问 if ($admin['style'] != ClassesAdminClass::STYLE_HD) { util::fail('您没有权限访问哦!'); } //后台 $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); $this->shop = $shop; if (empty($shop)) { util::fail('没有找到店铺'); } $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId]); 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['merchantId']; $this->sjId = $sjId; $sj = MerchantService::getMerchantById($sjId); $this->sj = $sj; $sjExtend = MerchantExtendClass::getByMerchantId($sjId); $this->sjExtend = $sjExtend; } return parent::beforeAction($action); } }