prepare( "SELECT a.order_id, a.offered_at FROM food_courier_assignments a JOIN food_orders o ON o.id = a.order_id WHERE a.courier_id = ? AND a.status = 'offered' AND a.offered_at > (NOW() - INTERVAL 20 SECOND) AND o.status = 'ready' AND o.courier_id IS NULL ORDER BY a.offered_at ASC" ); $st->execute([$food_courier_id]); // نفس حمولة مسار السوكيت حرفياً (foodBuildCourierOfferPayload) — شاشة العرض // عند السائق واحدة، فلا يجوز أن تختلف الحقول حسب المسار الذي وصل منه العرض. $offers = []; foreach ($st->fetchAll() as $row) { $payload = foodBuildCourierOfferPayload((int)$row['order_id']); if (!$payload) continue; $offers[] = array_merge( ['order_id' => (int)$row['order_id'], 'offered_at' => $row['offered_at'], 'offer_ttl_seconds' => 20], $payload ); } jsonSuccess(['offers' => $offers]);