$order['status'], 'courier_position' => null]); } $position = null; if ($redis) { $raw = $redis->get("food:order:{$orderId}:courier_pos"); if ($raw) $position = json_decode($raw, true); } // إحداثيات وجهتَي الخريطة — المطعم وعنوان التسليم (كلاهما معروف للزبون أصلاً) $st = $food_con->prepare( "SELECT o.delivery_lat, o.delivery_lng, o.delivery_address, m.name_ar AS merchant_name_ar, m.latitude AS merchant_lat, m.longitude AS merchant_lng FROM food_orders o JOIN food_merchants m ON m.id = o.merchant_id WHERE o.id = ? LIMIT 1" ); $st->execute([$orderId]); $meta = $st->fetch() ?: []; jsonSuccess([ 'status' => $order['status'], 'courier_position' => $position, 'merchant' => $meta ? [ 'name_ar' => $meta['merchant_name_ar'], 'lat' => (float)$meta['merchant_lat'], 'lng' => (float)$meta['merchant_lng'], ] : null, 'destination' => $meta ? [ 'address' => $meta['delivery_address'], 'lat' => (float)$meta['delivery_lat'], 'lng' => (float)$meta['delivery_lng'], ] : null, ]);