where('status', PaymentOrderService::STATUS_PROCESS) ->where('created_at', '<', $timeoutAt) ->limit(500)->pluck('id')->all(); if (!$ids) break; // 带状态条件更新,避免覆盖同一时刻回调已改成成功/失败的订单 PaymentOrder::whereIn('id', $ids)->where('status', PaymentOrderService::STATUS_PROCESS) ->update(['status' => PaymentOrderService::STATUS_TIMEOUT]); AdminRealtime::record('payment_orders', $ids); } while (count($ids) === 500); return 0; } }