onQueue('traffic_fetch'); $this->u = $u; $this->d = $d; $this->userId = $userId; $this->server = $server; $this->protocol = $protocol; } /** * Execute the job. * * @return void */ public function handle() { $user = User::lockForUpdate()->find($this->userId); if (!$user) return; $user->t = time(); $user->u = $user->u + $this->u; $user->d = $user->d + $this->d; if (!$user->save()) throw new \Exception('流量更新失败'); $mailService = new MailService(); $mailService->remindTraffic($user); } }