Food delivery driver module + masked calls + TURN

This commit is contained in:
Hamza-Ayed
2026-08-04 01:50:50 +03:00
parent 04c214bdf6
commit f01e408ba6
35 changed files with 3029 additions and 212 deletions
+15 -5
View File
@@ -5,15 +5,25 @@
require_once __DIR__ . '/../connect_courier.php';
$st = $food_con->prepare(
"SELECT a.order_id, a.offered_at, o.merchant_id, m.name_ar AS merchant_name_ar,
m.latitude AS merchant_lat, m.longitude AS merchant_lng, o.delivery_fee,
o.delivery_lat, o.delivery_lng
"SELECT a.order_id, a.offered_at
FROM food_courier_assignments a
JOIN food_orders o ON o.id = a.order_id
JOIN food_merchants m ON m.id = o.merchant_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]);
jsonSuccess(['offers' => $st->fetchAll()]);
// نفس حمولة مسار السوكيت حرفياً (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]);