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