userService = resolve("microUserService"); } /** * Execute the console command. * * @return mixed */ public function handle() { $broker = new BrokerService(); $broker->subscribe('password.reset', function ($message) { // 解析消息数据 $message = $message->getBody(); $passwordReset = json_decode(base64_decode($message['Body'])); $email = $passwordReset->email; $token = $passwordReset->token; // 发送重置邮件 $user = $this->userService->getByEmail($email); if ($user) { $model = new UserItem(); $model->fillAttributes($user); $model->sendPasswordResetNotification($token); $this->info('密码重置邮件已发送[email:' . $email . ']'); } else { $this->error('指定用户不存在[email:' . $email . ']'); } }); $broker->wait(); } }