From e41ad193c76614c03de657981447393805d9d3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Tue, 28 Dec 2021 15:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=90=E9=95=BF=E5=80=BC=20>=3D=20650=20?= =?UTF-8?q?=E7=9A=84=E5=B0=B1=E6=98=AF=E4=BC=9A=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Distribution/PreIncomeCommand.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 app/Console/Commands/Distribution/PreIncomeCommand.php diff --git a/app/Console/Commands/Distribution/PreIncomeCommand.php b/app/Console/Commands/Distribution/PreIncomeCommand.php new file mode 100644 index 00000000..0911b4a0 --- /dev/null +++ b/app/Console/Commands/Distribution/PreIncomeCommand.php @@ -0,0 +1,59 @@ +pending()->chunkById(200, function ($jobs) use ($jobService) { + foreach ($jobs as $job) { + try { + DB::beginTransaction(); + + $jobService->run($job); + + DB::commit(); + } catch (Throwable $e) { + DB::rollBack(); + + report($e); + + if ($e instanceof BizException) { + $job->update([ + 'status' => DistributionPreIncomeJob::STATUS_FAILED, + 'failed_reason' => $e->getMessage(), + ]); + } + } + } + }); + } +}