0) { $ids = OfflineOrder::where('status', OfflineOrderStatus::Pending) ->where('created_at', '<=', now()->subSeconds($expirs)) ->oldest('id') ->limit(500) ->pluck('id'); foreach ($ids as $id) { try { DB::beginTransaction(); $order = OfflineOrder::lockForUpdate()->findOrFail($id); $offlineOrderService->revoke($order); DB::commit(); } catch (Throwable $e) { DB::rollBack(); report($e); } } if ($ids->isEmpty()) { sleep(60); } else { sleep(10); } } else { sleep(60); } } } }