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