user->login($user, static::EXPIRE_TIME); $user->expire_at = time() + static::EXPIRE_TIME; $user->access_token = Yii::$app->security->generateRandomString(); if (!$user->save()) { throw new ServerErrorHttpException('更新登录信息失败'); } return $user->access_token; } /** * @return array|User|null * @throws BadRequestHttpException * @throws NotFoundHttpException */ protected static function getWxUser() { $openid = Yii::$app->request->getBodyParam('openid'); if (!$openid) { throw new BadRequestHttpException('缺少参数openid'); } $user = User::find() ->where(['status' => User::STATUS_ACTIVE]) ->andWhere(['wx_openid' => $openid]) ->one(); if (!$user) { throw new NotFoundHttpException('用户未找到'); } return $user; } public function miniProgramLogin() { } protected function getMiniUser() { } }