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(), + ]); + } + } + } + }); + } +}