params['ptStyle'] = dict::getDict('ptStyle', 'mall'); $this->isWx = util::isWx(); $userId = jwt::getLoginId(); if (empty($userId)) { if (!in_array($action->id, $this->guestAccess)) { util::fail('请先登录哈'); } } $userId = intval($userId); $this->userId = $userId; $user = UserClass::getById($userId, true); if (empty($user)) { if (!in_array($action->id, $this->guestAccess)) { util::fail('请先登录呢'); } } $this->user = $user; $shopId = Yii::$app->request->get('account'); // 从 $_GET 中取 $shopId = empty($shopId) ? Yii::$app->request->post('account') : $shopId; // 从 $_POST 中取 $shopId = intval($shopId); if (!empty($shopId)) { $this->shopId = $shopId; $shop = ShopClass::getById($shopId, true); if (!empty($shop)) { $this->shop = $shop; $mainId = $shop->mainId ?? 0; $main = MainClass::getById($mainId, true); $this->main = $main; $this->mainId = $mainId; $hdId = Yii::$app->request->get('hdId', 0); if (empty($hdId)) { //兼容早期代码,勿删,扫码付款页也用到,只写POST方式 $hdId = Yii::$app->request->post('hdId', 0); } if (!empty($hdId)) { $hd = HdClass::getById($hdId, true); if (!empty($hd)) { if (!empty($this->userId) && $hd->userId == $this->userId && $shopId == $hd->shopId) { $this->hd = $hd; $this->hdId = $hdId; $customId = $hd->customId ?? 0; $custom = CustomClass::getById($customId, true); $this->custom = $custom; $this->customId = $customId; } } } } } return parent::beforeAction($action); } }