6
0
Fork 0
release
李静 2022-01-07 21:56:45 +08:00
parent 0918976250
commit e8ad2bd135
1 changed files with 24 additions and 20 deletions

View File

@ -35,24 +35,25 @@ class PreIncomeJobCommand extends Command
*/ */
public function handle(DistributionPreIncomeJobService $jobService) public function handle(DistributionPreIncomeJobService $jobService)
{ {
DistributionPreIncomeJob::with('jobable')->pending()->chunkById(200, function ($jobs) use ($jobService) { while (true) {
foreach ($jobs as $job) { DistributionPreIncomeJob::with('jobable')->pending()->chunkById(200, function ($jobs) use ($jobService) {
try { foreach ($jobs as $job) {
DB::beginTransaction(); try {
DB::beginTransaction();
$jobService->run($job); $jobService->run($job);
DB::commit(); DB::commit();
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
report($e); report($e);
} }
//发送商家端预收益进帐消息 //发送商家端预收益进帐消息
try { try {
DB::beginTransaction(); DB::beginTransaction();
switch (get_class($job->jobable)) { switch (get_class($job->jobable)) {
case Order::class://如果是订单类型,则发送预收益消息 case Order::class://如果是订单类型,则发送预收益消息
$order = $job->jobable; $order = $job->jobable;
$incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get(); $incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get();
@ -66,13 +67,16 @@ class PreIncomeJobCommand extends Command
default: default:
break; break;
} }
DB::commit(); DB::commit();
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
report($e); report($e);
}
} }
} });
});
sleep(5);
}
} }
} }