data = $data; } public function handle() { $service = new RdGenerateDeviceService(); $lockKey = $this->data['lock_key']; try { DB::transaction(function () use($service) { $service->doGenerate($this->data['month']); }); } catch (\Exception $e) { // 只有这里 throw 了,任务才会进入 failed_jobs 表 throw $e; } finally { $service->delLimitingSendRequest($lockKey); } } protected function echoMessage(OutputInterface $output) { //输出消息 $output->writeln(json_encode($this->data)); } }