layout && in_array(Yii::$app->id, [AppEnum::BACKEND, AppEnum::MERCHANT])) { $this->layout = '@addons/Happiness/' . $this->module->id . '/views/layouts/agent'; } $redirect_url = '/happiness/agent/auth/login'; $this->admin = Yii::$app->happiness_agent_user->identity; $agentList = HappinessAgent::find()->where(['user_id' => $this->admin->user_id, 'status' => StatusEnum::ENABLED])->asArray()->all(); if (empty($agentList)) return $this->redirect([$redirect_url]); if (empty($this->admin)) return $this->redirect([$redirect_url]); $mall = Mall::findOne(['id' => $agentList[0]['mall_id']]); $this->mall = $mall; $this->mall_id = $mall['id']; $this->agent_ids = array_column($agentList, 'id'); foreach ($agentList as $agent) { if($agent['role']==HappinessEnum::AGENT_CITY) { $this->city_ids[] = $agent['city_id']; } if($agent['role']==HappinessEnum::AGENT_DISTRICT) { $this->district_ids[] = $agent['district_id']; } if($agent['role']==HappinessEnum::AGENT_PROVINCE) { $this->province_ids[] = $agent['province_id']; } } } /** * @return array */ public function behaviors() { return [ 'actionLog' => [ 'class' => ActionLogBehavior::class ] ]; } /** * @param $action * @return bool * @throws UnauthorizedHttpException * @throws \yii\web\BadRequestHttpException */ public function beforeAction($action) { if (!parent::beforeAction($action)) { return false; } // 每页数量 $this->pageSize = Yii::$app->request->get('per-page', 10); $this->pageSize > 50 && $this->pageSize = 50; return true; } }