params['ptStyle'] = dict::getDict('ptStyle', 'hd'); // 客户端协议版本:2=旧端金额字段合成;3=净余额(与 ghs 侧 AccountMoneyClass 一致) $headers = Yii::$app->getRequest()->getHeaders(); Yii::$app->params['clientAppVersion'] = (int)$headers->get('appVersion', 2); //token验证 $adminId = jwt::getLoginId(); //将石少华的号模拟成别人的号进行测试,有多处需要同步修改,关键词 simulate_other ssh 20250717 $simulateKey = 'simulate_admin_id'; $simulateId = Yii::$app->redis->executeCommand('GET', [$simulateKey]); if (!empty($simulateId) && $simulateId > 0) { if (getenv('YII_ENV') == 'production') { if ($adminId == 4) { $adminId = $simulateId; } } else { if ($adminId == 919) { $adminId = $simulateId; } } } if (empty($adminId) && !in_array($action->id, $this->guestAccess)) { util::notLogin(); } $admin = AdminClass::getById($adminId, true, 'password', true); if (empty($admin) && !in_array($action->id, $this->guestAccess)) { util::notLogin(); } $adminId = $admin ? intval($admin->id) : 0; $this->admin = $admin; $this->adminId = $adminId; //后台 $currentShopId = $admin ? intval($admin->currentShopId) : 0; if (empty($currentShopId)) { if (in_array($action->id, $this->guestAccess) == false) { util::fail('请注册登录'); } } else { $shop = ShopClass::getById($currentShopId, true); if (empty($shop)) { util::fail('没有找到店铺'); } $this->shopId = $currentShopId; $this->shop = $shop; $mainId = intval($shop->mainId); $main = MainClass::getById($mainId, true); if (empty($main)) { util::fail('没有找到main信息'); } $this->mainId = $mainId; $this->main = $main; $shopAdmin = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId, 'delStatus' => 0], true); //xhStaff 表 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; $this->shopAdminName = $shopAdmin->name ?? ''; $sjId = $shop->sjId; $sj = SjClass::getById($sjId, true); $this->sj = $sj; $this->sjId = $sjId; $sjExtend = MerchantExtendClass::getBySjId($sjId, true); $this->sjExtend = $sjExtend; } return parent::beforeAction($action); } }