90 || $lng < -180 || $lng > 180 || ($lat === 0.0 && $lng === 0.0)) { jsonError('Invalid coordinates'); } $order = foodAssertOrderOwnership($orderId, 'courier', $food_courier_id); if (!in_array($order['status'], ['courier_assigned', 'picked_up'], true)) { jsonError('Location sharing is only allowed while the delivery is active', 403); } $payload = [ 'order_id' => $orderId, 'lat' => round($lat, 6), 'lng' => round($lng, 6), 'heading' => filterRequest('heading') !== null ? (float)filterRequest('heading') : null, 'ts' => time(), ]; if ($redis) { // مصدر مسار الاحتياط: تطبيق الراكب يسحبه من order/courier_location.php $redis->setex("food:order:{$orderId}:courier_pos", 90, json_encode($payload)); } // المسار اللحظي — غرفة الزبون على سوكيت الطعام foodPushToSocket('courier_location', array_merge($payload, [ 'passenger_id' => (string)$order['passenger_id'], ])); jsonSuccess(['order_id' => $orderId, 'ts' => $payload['ts']]);