get(SSDBTask::class); $user = $ssdb->exec('hgetall', SsdbKeys::USER_INFO.$userId); // 微信登录 $config = config('applet'); $app = Factory::miniProgram($config); $app['guzzle_handler'] = CoroutineHandler::class; $decryptedData = $app->encryptor->decryptData($user['session_key'], $iv, $encryptedData); $data = [ 'nick_name' => $decryptedData['nickName'], 'avatar' => $decryptedData['avatarUrl'], 'openid' => $decryptedData['openId'], 'unionid' => $decryptedData['unionId'], 'country' => $decryptedData['country'], 'province' => $decryptedData['province'], 'city' => $decryptedData['city'], 'gender' => $decryptedData['gender'], 'language' => $decryptedData['nickName'], ]; $user = User::query()->find($userId); $res = $user->fill($data)->save(); if (!$res) { throw new ErrorCodeException(ErrorCode::USER_INFO_UPDATE_ERROR); } return $res; } public function check($userId) { return User::query()->where(['status' => 1, 'id' => $userId])->exists(); } public function undo($userId) { // TODO: Implement undo() method. } public function detail($userId) { return User::query() ->select(['id', 'nick_name', 'avatar', 'openid', 'total_score', 'real_name']) ->where(['status' => 1, 'id' => $userId]) ->first()->toArray(); } }