diff --git a/.DS_Store b/.DS_Store index 4ada6b5c..26d9b97d 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/backend/ride/rides/add_ride.php b/backend/ride/rides/add_ride.php index b949035c..736e0028 100644 --- a/backend/ride/rides/add_ride.php +++ b/backend/ride/rides/add_ride.php @@ -226,6 +226,17 @@ try { error_log("[add_ride] ride DB insert success. RideID=$insertedId"); + // 🆕 Seed initial ride state in Redis — fired as early as possible so + // getRideStatus polling has a cache entry from the first poll onward. + // Uses $status/$driver_id/$passenger_id, the exact values just written + // to MySQL above, not hardcoded literals. + sendToLocationServer('update_ride_state', [ + 'ride_id' => $insertedId, + 'status' => $status, + 'driver_id' => $driver_id, + 'passenger_id' => $passenger_id, + ]); + // ═══════════════════════════════════════════════════════════ // STEP B — primary DB ثانياً (نسخة أرشيفية بنفس الـ ID) // ═══════════════════════════════════════════════════════════ diff --git a/backend/ride/rides/cancel_ride_by_driver.php b/backend/ride/rides/cancel_ride_by_driver.php index f06623cc..53c7dd6b 100644 --- a/backend/ride/rides/cancel_ride_by_driver.php +++ b/backend/ride/rides/cancel_ride_by_driver.php @@ -212,10 +212,12 @@ try { $con->commit(); - // 🆕 Cache ride state in Redis + // 🆕 Cache ride state in Redis — use $statusText (the exact value just + // written to MySQL above), not a hardcoded label, so a cache hit can + // never disagree with the row it was seeded from. sendToLocationServer('update_ride_state', [ 'ride_id' => $rideId, - 'status' => 'cancelled_by_driver', + 'status' => $statusText, 'driver_id' => $driverId, 'passenger_id' => $passenger_id ?? '', ]); diff --git a/backend/ride/rides/finish_ride_updates.php b/backend/ride/rides/finish_ride_updates.php index f55f7423..4044e088 100644 --- a/backend/ride/rides/finish_ride_updates.php +++ b/backend/ride/rides/finish_ride_updates.php @@ -313,6 +313,17 @@ try { // ✅ Payment succeeded — COMMIT $con->commit(); + // 🆕 Cache ride state in Redis — placed immediately after commit(), before + // the best-effort remote-DB sync / streak / notification code below, so a + // later exception in any of those non-critical steps can never suppress + // this write for a ride that's genuinely finished in MySQL. + sendToLocationServer('update_ride_state', [ + 'ride_id' => $rideId, + 'status' => $newStatus, + 'driver_id' => $driver_id, + 'passenger_id' => $passengerId, + ]); + // 🔥 [Fix Split-Brain] تحديث القاعدة البعيدة الآن فقط، بعد أن أصبح الدفع // والتحديث المحلي مؤكدَين نجاحهما — يبقي الحالتين متطابقتين دائماً. // فشل هذا التحديث best-effort فقط (لا يُرجع الرحلة المحلية المُنجَزة فعلاً). diff --git a/backend/ride/rides/retry_search_drivers.php b/backend/ride/rides/retry_search_drivers.php index d0e263e0..1fbe1a6a 100644 --- a/backend/ride/rides/retry_search_drivers.php +++ b/backend/ride/rides/retry_search_drivers.php @@ -134,6 +134,17 @@ try { ':id' => $rideId, ]); + // 🆕 Refresh Redis cache — this UPDATE just reset status back to 'waiting' + // and driver_id to 0. Without this, a passenger polling during a retry + // round would keep seeing a stale prior state (e.g. 'arrived') cached + // from before the reset. + sendToLocationServer('update_ride_state', [ + 'ride_id' => $rideId, + 'status' => 'waiting', + 'driver_id' => '0', + 'passenger_id' => $passengerId, + ]); + // 3. حساب العمولة (Kazan) المُحدَّثة بعد الـ bonus $kazan = (float)$price - (float)$priceForDriver; if ($kazan < 0) $kazan = 0; // Floor protection diff --git a/backend/ride/rides/start_ride.php b/backend/ride/rides/start_ride.php index ae165bf5..f5bd6b61 100644 --- a/backend/ride/rides/start_ride.php +++ b/backend/ride/rides/start_ride.php @@ -142,10 +142,12 @@ try { $con->commit(); - // 🆕 Cache ride state in Redis + // 🆕 Cache ride state in Redis — use $status (the exact value just + // written to MySQL above), not a hardcoded label, so a cache hit can + // never disagree with the row it was seeded from. sendToLocationServer('update_ride_state', [ 'ride_id' => $ride_id, - 'status' => 'started', + 'status' => $status, 'driver_id' => $driver_id, 'passenger_id' => $passenger_id ?? '', ]); diff --git a/docs/server_architecture_feedback.md b/docs/server_architecture_feedback.md new file mode 100644 index 00000000..6f8bee1b --- /dev/null +++ b/docs/server_architecture_feedback.md @@ -0,0 +1,290 @@ +# تقرير التدقيق وتصميم بنية سيرفرات منصة Siro (نسخة محدثة ونهائية) + +بناءً على التوضيح الدقيق للهيكلية الفعلية المعتمدة للمنظومة، يهدف هذا التقرير إلى تقديم تفصيل كامل للمكونات، ورسم طوبولوجيا الشبكة المطابقة للواقع، وحل مشكلة اتصال وتزامن خوادم الـ WebSockets مع خوادم الباك إند والعملاء. + +--- + +## أولاً: الهيكلية المعتمدة للنظام (Actual Architecture Topology) + +تتكون المنظومة من المكونات الأساسية التالية وتوزيعها كالتالي: + +1. **موزع الأحمال (Load Balancer):** يقع في المقدمة لتلقي طلبات الـ API (HTTP/HTTPS) فقط وتوزيعها على خادمين. +2. **خوادم الـ API (Web Server A & B):** خوادم Stateless تستقبل الطلبات وتقوم بالمعالجة وحفظ الملفات، وتتصل بكل من قاعدة البيانات وذاكرة Redis المؤقتة. +3. **قاعدة البيانات الرئيسية (MySQL Master):** تحتوي على البيانات الأساسية ولها خادمان تابعان: + * **نسخة مطابقة (Replica):** للمزامنة الحية وتخفيف ضغط القراءة. + * **نسخة نسخ احتياطي (Dump Server):** لأخذ النسخ الاحتياطية الدورية دون التأثير على الأداء. +4. **خوادم الـ Redis:** تعمل كطبقة كاش ذكية أولى/ثانية أمام قاعدة البيانات لحفظ الجلسات، التحقق، ومعدل الطلبات، ولها خادم احتياطي (Replica). +5. **خوادم الـ WebSockets المنفصلة:** + * **سيرفر الموقع الجغرافي (Location Server):** خادم مستقل يستقبل إحداثيات GPS حية من تطبيق السائق. + * **سيرفر الرحلات (Ride/Passenger Server):** خادم مستقل يدير قنوات الاتصال الحي بين الراكب والسائق أثناء الرحلة. + * **ملاحظة:** تطبيق الفلاتر (الراكب والسائق) يتصل **مباشرة** بهذين السيرفرين عبر بروتوكول WS/WSS. + +--- + +## ثانياً: حل معضلة اتصال الـ WebSockets (The WebSocket Integration Solution) + +> [!IMPORTANT] +> ### السؤال الأساسي: كيف تتواصل خوادم الباك إند (Web Server A & B) مع خوادم الـ Sockets المنفصلة وتزامن حالة الرحلة؟ +> بما أن خوادم الباك إند معزولة خلف موزع الأحمال، وتطبيقات الموبايل متصلة مباشرة بخوادم الـ Sockets، فإن أفضل طريقة تشغيلية ومعمارية للربط هي استخدام **Redis Pub/Sub (نظام النشر والاشتراك)** كجسر تواصل سريع جداً (Event Bus): + +```mermaid +sequenceDiagram + autonumber + actor Driver as تطبيق السائق + participant WebAPI as خادم الباك إند (A أو B) + participant Redis as Redis Pub/Sub + participant RideSocket as سيرفر الـ Sockets (Ride) + actor Rider as تطبيق الراكب + + Driver->>WebAPI: 1. قبول الرحلة (طلب API) + WebAPI->>WebAPI: 2. معالجة الطلب وحفظ الحالة بقاعدة البيانات + WebAPI->>Redis: 3. نشر حدث (Publish) -> "قبول_رحلة" لقناة Redis + Note over Redis: الحدث يحتوي على معرف الرحلة والراكب + Redis-->>RideSocket: 4. استلام الحدث فوراً (Subscription) + RideSocket->>Rider: 5. دفع تنبيه حقيقي (WebSocket Push) -> "السائق قبل رحلتك" +``` + +### مزايا هذا الحل: +* **Stateless API:** تبقى خوادم الباك إند خفيفة ولا تحتاج لمعرفة من متصل بأي سيرفر سوكت. +* **تزامن فوري:** تتم عملية النشر والاستلام عبر الـ Redis في أجزاء من الميلي ثانية. +* **فصل كامل للمسؤولية:** خوادم السوكت تركز فقط على الحفاظ على الاتصالات المفتوحة وإرسال البيانات، بينما خوادم الباك إند تركز على منطق العمل وحساب الأسعار. + +--- + +## ثالثاً: مخطط طوبولوجيا الشبكة المقترح (Network Topology Diagram) + +يوضح المخطط التالي العلاقة التفاعلية ومسارات اتصال تطبيقات الموبايل بالمنظومة: + +```mermaid +graph TD + %% Clients + Rider([تطبيق الراكب]) + Driver([تطبيق السائق]) + + %% API Routing + Rider -.->|1. API Requests HTTPS| LB[Load Balancer] + Driver -.->|1. API Requests HTTPS| LB + + LB --> WebA[Web Server A] + LB --> WebB[Web Server B] + + %% Direct Web Sockets Connection + Rider ==>|2. WebSocket WSS| RideSocket[Ride/Passenger Server] + Driver ==>|2. Live Location WSS| LocationSocket[Location Server] + + %% Shared Storage for Uploads + WebA -->|Uploads| SharedStorage[(Shared Storage / NFS)] + WebB -->|Uploads| SharedStorage + + %% Caching & PubSub Bridge + WebA --> RedisMaster[Redis Master] + WebB --> RedisMaster + RideSocket --> RedisMaster + LocationSocket --> RedisMaster + RedisMaster -->|Replication| RedisReplica[Redis Replica] + + %% Databases + WebA --> DBMaster[(MySQL Master DB)] + WebB --> DBMaster + LocationSocket -.->|Save Trackings| DBMaster + RideSocket -.->|Save Ride States| DBMaster + + %% DB Backup & Replication + DBMaster -->|Streaming| DBReplica[(MySQL Replica DB)] + DBMaster -->|Dumps| DBBackup[(MySQL Dump Server)] +``` + +--- + +## رابعاً: معالجة البيانات والتخزين المؤقت (Redis Caching Strategy) + +* **البيانات المخزنة في Redis:** الجلسات النشطة (Sessions)، التوكنات المؤقتة للتحقق (OTP & JWT)، معدل الطلبات (Rate Limiting)، والبيانات الجغرافية المؤقتة للسائقين القريبين. +* **البيانات في MySQL:** بيانات المستخدمين، تفاصيل الرحلات، الحسابات المالية، سجلات الحظر والوثائق. +* عند طلب بيانات معينة (مثل الملف الشخصي)، يفحص السيرفر الـ Redis أولاً؛ إن لم يجدها (Cache Miss) يقرأها من MySQL Master/Replica ويخزنها في Redis لمرة ثانية لتسريع الطلبات القادمة. + +--- + +## خامساً: خطة الشراء واختيار السيرفرات (Hosting & Sizing Recommendations) + +بناءً على عروض الاستضافة المتاحة من شركتي **Netcup** و **Contabo**، تم تصميم خطة الشراء التالية لتوفر أفضل أداء مقابل السعر مع تحقيق توازن كامل للمنظومة: + +### ١. مبررات اختيار الشركات لكل خدمة: +* **سيرفرات قواعد البيانات والـ Sockets والـ Redis (اختيار Netcup):** قواعد البيانات والاتصالات الحية تحتاج إلى **استقرار كامل للـ CPU** ونوعية رام مدعومة بكشف الأخطاء وتصحيحها (**ECC DDR5 RAM**)، بالإضافة إلى سرعة قراءة وكتابة فائقة للأقراص (NVMe SSD)، وهو ما تتفوق فيه Netcup بشكل قطعي. +* **سيرفرات الـ API المستقلة وسيرفر الخرائط (اختيار Contabo):** خوادم الـ API هي Stateless وتتطلب سعة ذاكرة رام عالية وأنوية معالجة بتكلفة اقتصادية لتوزيع الأحمال. كما أن سيرفر الخرائط يحتاج لمساحة ديسك ضخمة ورام كبيرة جداً لتحميل ملفات الـ PBF والـ Tiles، وتوفر Contabo أحجام رام ضخمة بأسعار منافسة جداً. + +--- + +### ٢. جدول توزيع المشتريات ومواصفات السيرفرات (١٢ سيرفر): + +| # | السيرفر ووظيفته | المواصفات المطلوبة | الشركة والخطة المقترحة | التكلفة (€/شهر) | التكلفة ($/شهر) | نوع القرص والتخزين | +| :---: | :--- | :---: | :--- | :---: | :---: | :---: | +| 1 | **موزع الأحمال (Load Balancer)** | 2GB RAM / 2 Cores | **Netcup:** VPS nano G11s | €2.58 | $2.92 | 60 GB SSD | +| 2 | **خادم الـ API الأول (Web Server A)** | 8GB RAM / 4 Cores | **Contabo:** Cloud VPS 10 | €4.40 | $4.97 | 75 GB NVMe | +| 3 | **خادم الـ API الثاني (Web Server B)** | 8GB RAM / 4 Cores | **Contabo:** Cloud VPS 10 | €4.40 | $4.97 | 75 GB NVMe | +| 4 | **قاعدة البيانات الرئيسية (MySQL Master)** | 32GB RAM / 12 Cores | **Netcup:** VPS 4000 G12 | €27.00 | $30.51 | 1 TB NVMe | +| 5 | **قاعدة البيانات الاحتياطية (MySQL Replica)** | 16GB RAM / 8 Cores | **Netcup:** VPS 2000 G12 | €16.17 | $18.27 | 512 GB NVMe | +| 6 | **سيرفر النسخ الاحتياطي (Dump DB)** | 4GB RAM / 2 Cores | **Netcup:** VPS 500 G12 | €4.96 | $5.61 | 128 GB NVMe | +| 7 | **ذاكرة Redis الرئيسية (Redis Master)** | 2GB RAM / 2 Cores | **Netcup:** VPS nano G11s | €2.58 | $2.92 | 60 GB SSD | +| 8 | **ذاكرة Redis الاحتياطية (Redis Replica)** | 2GB RAM / 2 Cores | **Netcup:** VPS nano G11s | €2.58 | $2.92 | 60 GB SSD | +| 9 | **سيرفر تتبع المواقع الحية (Location Server)** | 4GB RAM / 2 Cores | **Netcup:** VPS 500 G12 | €4.96 | $5.61 | 128 GB NVMe | +| 10 | **سيرفر حالة الرحلات (Passenger Socket)** | 2GB RAM / 2 Cores | **Netcup:** VPS nano G11s | €2.58 | $2.92 | 60 GB SSD | +| 11 | **سيرفر المدفوعات المستقل (Payments)** | 2GB RAM / 2 Cores | **Netcup:** VPS nano G11s | €2.58 | $2.92 | 60 GB SSD | +| 12 | **سيرفر الخرائط المخصص (SiroMaps)** | 64GB RAM / 16 Cores | **Contabo:** Cloud VPS 50 | €29.60 | $33.45 | 300 GB NVMe | + +--- + +### ٣. ملخص التكلفة الشهرية الإجمالية: + +| البند | التكلفة باليورو (€) | التكلفة بالدولار ($) | +| :--- | :---: | :---: | +| **إجمالي سيرفرات Netcup (9 سيرفرات)** | €65.99 | $74.58 | +| **إجمالي سيرفرات Contabo (3 سيرفرات)** | €38.40 | $43.39 | +| **الإجمالي الكلي للمنظومة (12 سيرفر)** | **€104.39** | **$117.97** | + +> [!NOTE] +> سعر الصرف المستخدم: 1 يورو = 1.13 دولار أمريكي (تقريبي). الأسعار المذكورة هي أسعار الاشتراك الشهري فقط ولا تشمل رسوم الإعداد (Setup Fee) إن وجدت. + +--- + +## سادساً: تقييم الأداء — كم تستوعب هذه المنظومة؟ (Capacity Estimation) + +> [!IMPORTANT] +> ### الجواب المختصر: هذه البنية كافية ومتينة جداً لمنصة نقل ركاب بحجم سوق سوريا ومصر في مراحل التشغيل والنمو الأولى والمتوسطة. + +### تقدير السعة حسب كل مكوّن: + +| المكوّن | السعة التقديرية القصوى | الشرح والمبرر | +| :--- | :---: | :--- | +| **خوادم الـ API (Web A + B)** | ~2,000 - 3,000 طلب HTTP متزامن | كل سيرفر PHP-FPM بـ 8GB يخدم حوالي 1,000-1,500 طلب متزامن. مع سيرفرين خلف اللود بلانسر، تتضاعف السعة. | +| **سيرفر الموقع الجغرافي (Location WebSocket)** | ~10,000 - 15,000 سائق متصل في نفس اللحظة | Workerman على 4GB DDR5 يدير اتصالات خفيفة جداً (إحداثيات GPS كل 3 ثوانٍ). القيد هنا هو عدد الـ File Descriptors وليس الرام. | +| **سيرفر الرحلات (Passenger Socket)** | ~5,000 - 8,000 راكب متصل في نفس اللحظة | خفيف جداً كونه relay. كل اتصال يستهلك ~50KB رام فقط. | +| **قاعدة البيانات الرئيسية (MySQL Master)** | ~5,000 - 8,000 استعلام في الثانية | 32GB مع `innodb_buffer_pool_size=22GB` يخدم ملايين الصفوف بسرعة فائقة. مع الـ Replica يتضاعف أداء القراءة. | +| **Redis Master** | ~100,000+ عملية في الثانية | Redis على 2GB يخدم مئات آلاف العمليات/ثانية. حجم البيانات المخزنة (جلسات + كاش + GEO) لن يتجاوز 500MB في الذروة. | +| **سيرفر الخرائط (SiroMaps)** | ~500 - 1,000 طلب توجيه/ثانية | OSRM على 64GB رام يحمّل خريطة سوريا ومصر بالكامل في الذاكرة لسرعة فائقة. | + +### تقدير السعة الإجمالية للمنصة: + +| المقياس | السعة التقديرية | +| :--- | :---: | +| **عدد المستخدمين المسجلين (ركاب + سائقين)** | حتى **500,000+** مستخدم مسجل | +| **عدد السائقين المتصلين في نفس اللحظة (أوقات الذروة)** | حتى **10,000 - 15,000** سائق | +| **عدد الركاب النشطين في نفس اللحظة** | حتى **5,000 - 8,000** راكب | +| **عدد الرحلات اليومية** | حتى **20,000 - 40,000** رحلة/يوم | +| **عدد الرحلات المتزامنة في نفس اللحظة** | حتى **1,500 - 3,000** رحلة نشطة | + +> [!TIP] +> ### للمقارنة: تطبيقات نقل ركاب كبرى في المنطقة مثل "كريم" و"بولت" في مراحلها الأولى كانت تعمل بمنظومات أصغر من هذه. هذه البنية تكفي لتغطية سوريا ومصر بالكامل حتى الوصول لعشرات الآلاف من الرحلات اليومية. + +### عوامل تحدد متى تحتاج للترقية: + +| المؤشر | القيمة الحدّية التي توجب الترقية | +| :--- | :---: | +| استخدام CPU لخوادم الـ API يتجاوز | 75% بشكل مستمر لأكثر من ساعة | +| استخدام الرام لقاعدة البيانات يتجاوز | 85% من الـ Buffer Pool | +| عدد اتصالات السوكت يتجاوز | 80% من حد الـ File Descriptors | +| زمن استجابة الـ API يتجاوز | 500 ميلي ثانية كمتوسط | +| حجم قاعدة بيانات التتبع (Tracking) يتجاوز | 50GB بدون سياسة تنظيف (TTL) | + +--- + +## سابعاً: الشبكة الداخلية (Private Network / VLAN) — هل هي ضرورية؟ + +> [!CAUTION] +> ### الجواب القاطع: نعم، الشبكة الداخلية (VLAN) **إلزامية وليست اختيارية** في هذا التصميم. بدونها أنت تعرّض قاعدة البيانات وخادم Redis للإنترنت العام مباشرة، وهذه كارثة أمنية. + +### لماذا الشبكة الداخلية ضرورية؟ + +| السبب | التفصيل | +| :--- | :--- | +| **١. الأمان (Security)** | قاعدة البيانات MySQL وخادم Redis يجب أن يكونا **معزولين تماماً** عن الإنترنت العام. لا يجب أن يملك أي شخص خارج المنظومة القدرة على الوصول إليهما. الشبكة الداخلية تجعل هذين الخادمين مرئيين فقط لخوادم الـ API والسوكت. | +| **٢. الأداء (Performance)** | الاتصال عبر الشبكة الداخلية أسرع بكثير (latency أقل بـ 5-10 أضعاف) من الاتصال عبر الإنترنت العام. استعلامات قاعدة البيانات ستستجيب بـ 0.1ms بدلاً من 1-5ms. | +| **٣. التكلفة (Cost)** | الترافيك عبر الشبكة الداخلية **مجاني بالكامل** ولا يُحسب من حصة الباندويث. بينما الترافيك العام يُحسب ويُكلّف. | +| **٤. عزل الخدمات (Isolation)** | لو تم اختراق أحد خوادم الـ API (لا سمح الله)، لن يتمكن المهاجم من الوصول لقاعدة البيانات عبر الإنترنت العام لأنها ببساطة غير مرئية من الخارج. | + +### كيف يتم التطبيق عملياً؟ + +```mermaid +graph TD + subgraph PublicZone["المنطقة العامة (Public Zone)"] + LB[Load Balancer] + LocationSocket[Location Server] + RideSocket[Ride Server] + end + + subgraph PrivateVLAN["الشبكة الداخلية الخاصة (Private VLAN)"] + WebA[Web Server A] + WebB[Web Server B] + RedisMaster[Redis Master] + RedisReplica[Redis Replica] + DBMaster[(MySQL Master)] + DBReplica[(MySQL Replica)] + DBBackup[(Dump Server)] + Payments[Payments Server] + end + + subgraph MapsZone["منطقة الخرائط (Maps Zone)"] + Maps[SiroMaps Server] + end + + Internet([الإنترنت]) -->|HTTPS| LB + Internet -->|WSS| LocationSocket + Internet -->|WSS| RideSocket + + LB -->|Private IP| WebA + LB -->|Private IP| WebB + + WebA -->|Private IP| RedisMaster + WebA -->|Private IP| DBMaster + WebB -->|Private IP| RedisMaster + WebB -->|Private IP| DBMaster + + LocationSocket -->|Private IP| RedisMaster + RideSocket -->|Private IP| RedisMaster + + WebA -->|Private IP| Maps +``` + +### التطبيق العملي لكل شركة: + +| الشركة | طريقة إنشاء الشبكة الداخلية | الملاحظة | +| :--- | :--- | :--- | +| **Netcup** | من لوحة التحكم SCP → "vLAN" → إنشاء شبكة افتراضية وربط السيرفرات بها | Netcup يوفر VLAN مجاني بين سيرفراتك في نفس مركز البيانات (Datacenter). اختر جميع سيرفرات Netcup في **نفس الموقع الجغرافي** (مثلاً Nürnberg). | +| **Contabo** | من لوحة التحكم → "Private Networking" → إضافة السيرفرات لنفس الشبكة | Contabo يوفر شبكة خاصة مجانية. اختر جميع سيرفرات Contabo في **نفس الموقع** (مثلاً EU-Germany). | + +### الربط بين الشركتين (Netcup ↔ Contabo): + +> [!WARNING] +> سيرفرات Netcup وسيرفرات Contabo في مراكز بيانات مختلفة فيزيائياً، لذلك **لا يمكن وضعها في نفس الـ VLAN**. الحل: + +| الطريقة | التفصيل | +| :--- | :--- | +| **WireGuard VPN Tunnel** | إنشاء نفق VPN مشفّر بين سيرفر من Netcup وسيرفر من Contabo. هذا يجعلها تتصرف كأنها في نفس الشبكة الداخلية مع تشفير كامل. زمن الاتصال بين مراكز بيانات ألمانيا ≈ 1-3ms فقط. | +| **التطبيق:** | تثبيت WireGuard على موزع الأحمال (Netcup) وعلى خوادم الـ API (Contabo)، وإنشاء نفق بينهما. كل السيرفرات الأخرى تتصل عبر الشبكة الداخلية لشركتها. | + +### قواعد الجدار الناري (Firewall Rules): + +| السيرفر | المنافذ المفتوحة للإنترنت العام | المنافذ المفتوحة فقط للشبكة الداخلية | +| :--- | :---: | :---: | +| **موزع الأحمال** | 80, 443 (HTTP/HTTPS) | — | +| **سيرفر الموقع (Location)** | منفذ WSS المحدد | — | +| **سيرفر الرحلات (Ride)** | منفذ WSS المحدد | — | +| **Web Server A & B** | ❌ لا شيء | 80, 443 (يستقبل فقط من LB) | +| **MySQL Master & Replica** | ❌ لا شيء | 3306 (فقط من Web + Sockets) | +| **Redis Master & Replica** | ❌ لا شيء | 6379 (فقط من Web + Sockets) | +| **سيرفر المدفوعات** | ❌ لا شيء | المنفذ المحدد (فقط من Web) | +| **سيرفر الخرائط** | ❌ لا شيء | 5000, 8080 (فقط من Web) | + +--- + +## ثامناً: التقييم النهائي + +> [!TIP] +> ### الحكم العام: تصميم سليم ومتزن وجاهز للتنفيذ. + +| السؤال | الإجابة | +| :--- | :--- | +| **هل التنظيم سليم؟** | نعم. فصل المسؤوليات واضح: API منفصل، DB منفصل، Sockets منفصل، Redis منفصل، Maps منفصل. كل مكوّن يمكن ترقيته أو استبداله بشكل مستقل دون التأثير على البقية. | +| **هل الموارد كافية؟** | نعم وزيادة. هذه البنية تخدم حتى 15,000 سائق و8,000 راكب متصلين في نفس اللحظة، و40,000 رحلة يومياً. أكبر من حاجة السوق السوري والمصري في المرحلة الحالية. | +| **كم عدد السيرفرات؟** | **12 سيرفر** موزعة بين 9 سيرفرات Netcup و3 سيرفرات Contabo. | +| **كم التكلفة الشهرية؟** | **€104.39 يورو = $117.97 دولار أمريكي شهرياً** | +| **هل نحتاج شبكة داخلية؟** | **إلزامية بشكل قاطع.** بدونها قاعدة البيانات و Redis مكشوفان على الإنترنت. الشبكة الداخلية مجانية من كلا الشركتين، ويتم ربطهما ببعض عبر WireGuard VPN. | diff --git a/loction_server/driver_socket.php b/loction_server/driver_socket.php index 2f223e4b..b41afa33 100755 --- a/loction_server/driver_socket.php +++ b/loction_server/driver_socket.php @@ -511,6 +511,24 @@ $io->on('workerStart', function () use ($io, $INTERNAL_KEY) { $connection->send('OK'); + // ── 7b. Get Ride State (Redis Cache Read-Only) ───────── + // Used by ride_server/intaleq/ride/rides/getRideStatus.php to + // answer passenger polling without hitting MySQL on every call. + } elseif ($action === 'get_ride_state') { + $rideId = (int)($post['ride_id'] ?? 0); + + if ($rideId <= 0 || !$redis) { + $connection->send(json_encode(['status' => false, 'data' => null])); + return; + } + + $stateData = $redis->hgetall("ride:{$rideId}:state"); + + $connection->send(json_encode([ + 'status' => !empty($stateData), + 'data' => $stateData ?: null, + ])); + // ── 5. Force Disconnect ─────────────────────────────── } elseif ($action === 'force_disconnect') { $driverId = $post['driver_id'] ?? null; diff --git a/ride_server/composer.json b/ride_server/composer.json new file mode 100644 index 00000000..4e645d86 --- /dev/null +++ b/ride_server/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "firebase/php-jwt": "^7.0", + "workerman/phpsocket.io": "^2.2" + } +} diff --git a/ride_server/index.php b/ride_server/index.php new file mode 100755 index 00000000..66807395 --- /dev/null +++ b/ride_server/index.php @@ -0,0 +1,3 @@ +sub ?? $decodedToken->user_id ?? null; + +// --- DB connection: same physical database backend's Database::get('main') +// resolves to (confirmed distinct from Database::get('ride') — the getRideStatus +// endpoint this replaces has always read from 'main', so the fallback query +// below stays on 'main' too, for zero behavior change vs. today). Env var +// names match backend/core/Database/Database.php's 'main' entry exactly; +// falling back to loction_server's simpler names only if ops sets this box +// up differently. Actual values must be confirmed/provisioned by ops. --- +$dbname = getenv('DB_PRIMARY_NAME_V2') ?: getenv('dbname'); +$dbhost = getenv('DB_PRIMARY_HOST_V2') ?: 'localhost'; +$dbuser = getenv('DB_PRIMARY_USER_V2') ?: getenv('USER'); +$dbpass = getenv('DB_PRIMARY_PASS_V2') ?: getenv('PASS'); + +try { + $dsn = "mysql:host=$dbhost;dbname=$dbname;charset=utf8mb4"; + $con = new PDO($dsn, $dbuser, $dbpass, [ + PDO::ATTR_EMULATE_PREPARES => false, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8", + PDO::ATTR_TIMEOUT => 5, + ]); +} catch (PDOException $e) { + error_log("[ride_server/connect] DB connection failed: " . $e->getMessage()); + http_response_code(500); + echo json_encode(['status' => 'failure', 'message' => 'A database error occurred.']); + exit; +} diff --git a/ride_server/intaleq/functions.php b/ride_server/intaleq/functions.php new file mode 100644 index 00000000..15b5d0c0 --- /dev/null +++ b/ride_server/intaleq/functions.php @@ -0,0 +1,95 @@ + 'failure', 'message' => 'Internal server configuration error.']); + exit; + } + + $authHeader = $_SERVER['HTTP_AUTHORIZATION'] ?? ''; + $token = null; + if (preg_match('/Bearer\s(\S+)/', $authHeader, $matches)) { + $token = $matches[1]; + } + if (!$token) { + http_response_code(401); + echo json_encode(['status' => 'failure', 'message' => 'Authorization token required']); + exit; + } + + try { + return JWT::decode($token, new Key($secretKey, 'HS256')); + } catch (ExpiredException $e) { + http_response_code(401); + echo json_encode(['status' => 'failure', 'message' => 'Token expired']); + exit; + } catch (SignatureInvalidException $e) { + http_response_code(401); + echo json_encode(['status' => 'failure', 'message' => 'Invalid token signature']); + exit; + } catch (BeforeValidException $e) { + http_response_code(401); + echo json_encode(['status' => 'failure', 'message' => 'Token not yet valid']); + exit; + } catch (Exception $e) { + http_response_code(401); + echo json_encode(['status' => 'failure', 'message' => 'Invalid token']); + exit; + } + // NOTE: signature/expiry only — does not replicate backend's + // core/Auth/JwtService::authenticate() JTI-blacklist (revoked-token) + // check or X-Device-FP verification. Flagged as a follow-up in the + // plan; not blocking for this read-only endpoint. +} + +// Flutter's CRUD().get() always issues an HTTP POST under the hood +// (see siro_rider/lib/controller/functions/crud.dart _makeRequest/doPost) — +// so every field this endpoint reads comes through $_POST, never $_GET. +function filterRequest($requestname, $type = 'string') { + if (isset($_POST[$requestname]) && $_POST[$requestname] !== '') { + $value = trim($_POST[$requestname]); + $value = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', '', $value); + if ($type === 'numeric') { + return filter_var($value, FILTER_VALIDATE_FLOAT) !== false ? $value : null; + } + return $value; + } + return null; +} + +function printFailure($message = "none") { + echo json_encode(["status" => "failure", "message" => $message]); +} diff --git a/ride_server/intaleq/load_env.php b/ride_server/intaleq/load_env.php new file mode 100644 index 00000000..cd4c0403 --- /dev/null +++ b/ride_server/intaleq/load_env.php @@ -0,0 +1,23 @@ +"} +// +// Reads Redis truth via loction_server's internal HTTP API first (same +// "ask location server, fall back to DB" shape as backend/ride/location/get.php); +// on any miss/timeout/error, falls back to a direct MySQL SELECT so behavior +// never regresses to "no answer." + +require_once __DIR__ . '/../../connect.php'; + +$id = filterRequest("id"); +$rideId = (int) $id; + +if (empty($id) || $rideId <= 0) { + printFailure("Missing ride ID."); + exit; +} + +// ── 1. Try Redis via the location server's internal HTTP API ────────────── +$status = null; + +$locationServerUrl = getenv('LOCATION_SERVER_URL') ?: 'http://location.intaleq.xyz:2021'; +$internalKey = getInternalSocketKey(); + +if ($internalKey) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $locationServerUrl); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ + 'action' => 'get_ride_state', + 'ride_id' => $rideId, + ])); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + // Foreground/synchronous read — the answer IS the response, so this is + // deliberately longer than the 200-500ms fire-and-forget write timeouts + // used elsewhere in this codebase. + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 500); + curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1500); + curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-internal-key: $internalKey"]); + + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $curlErr = curl_error($ch); + curl_close($ch); + + if (!$curlErr && $httpCode === 200 && $response) { + $json = json_decode($response, true); + if (is_array($json) && ($json['status'] ?? false) === true + && !empty($json['data']['status'])) { + $status = $json['data']['status']; + } + } else { + error_log("[getRideStatus] location-server read miss/error for ride=$rideId: " + . ($curlErr ?: "HTTP $httpCode")); + } +} else { + error_log("[getRideStatus] internal key not configured — skipping Redis read, using DB fallback."); +} + +// ── 2. Fallback: direct MySQL read (identical query to the legacy file) ─── +if ($status === null) { + try { + $stmt = $con->prepare("SELECT `status` FROM `ride` WHERE `id` = :id"); + $stmt->bindParam(':id', $rideId, PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if ($row && isset($row['status'])) { + $status = $row['status']; + } + } catch (PDOException $e) { + error_log("[getRideStatus] DB fallback error for ride=$rideId: " . $e->getMessage()); + http_response_code(500); + echo json_encode(["status" => "failure", "message" => "An internal error occurred."]); + exit; + } +} + +if ($status !== null) { + echo json_encode([ + "status" => "success", + "data" => $status + ]); +} else { + printFailure("Ride not found."); +} diff --git a/ride_server/passenger_socket.php b/ride_server/passenger_socket.php new file mode 100755 index 00000000..ed74e64b --- /dev/null +++ b/ride_server/passenger_socket.php @@ -0,0 +1,191 @@ +on('workerStart', function () use ($io, $INTERNAL_KEY, $INTERNAL_PORT) { + + $innerHttp = new Worker("http://0.0.0.0:$INTERNAL_PORT"); + + $innerHttp->onMessage = function ($connection, $request) use ($io, $INTERNAL_KEY) { + + $headers = $request->header(); + $clientIp = $connection->getRemoteIp(); + + if (($headers['x-internal-key'] ?? '') !== $INTERNAL_KEY) { + socket_log("[HTTP_ERROR] Unauthorized internal request from IP: $clientIp"); + $connection->send('Unauthorized'); + return; + } + + $post = $request->post(); + $action = trim($post['action'] ?? ''); + + if ($action === 'update_ride_status') { + + $passengerId = $post['passenger_id'] ?? null; + $rawPayload = $post['payload'] ?? null; + + if (!$passengerId || !$rawPayload) { + socket_log("[HTTP_ERROR] Missing passenger_id or payload for action: update_ride_status", $post); + $connection->send('Error: Missing passenger_id or payload'); + return; + } + + $payload = is_string($rawPayload) + ? (json_decode($rawPayload, true) ?? $rawPayload) + : $rawPayload; + + socket_log("[HTTP_SUCCESS] Emitting 'ride_status_change' to Passenger #$passengerId", $payload); + $io->to('passenger_' . $passengerId)->emit('ride_status_change', $payload); + + $connection->send('OK'); + + } elseif ($action === 'update_driver_location') { + + $passengerId = $post['passenger_id'] ?? null; + $rawPayload = $post['payload'] ?? null; + + if (!$passengerId || !$rawPayload) { + socket_log("[HTTP_ERROR] Missing passenger_id or payload for action: update_driver_location", $post); + $connection->send('Error: Missing passenger_id or payload'); + return; + } + + $payload = is_string($rawPayload) + ? (json_decode($rawPayload, true) ?? $rawPayload) + : $rawPayload; + + socket_log("[HTTP_SUCCESS] Emitting 'driver_location_update' to Passenger #$passengerId", $payload); + $io->to('passenger_' . $passengerId)->emit('driver_location_update', $payload); + + $connection->send('OK'); + + } else { + socket_log("[HTTP_WARNING] Unknown action received: $action", $post); + $connection->send('Unknown action: ' . $action); + } + }; + + $innerHttp->listen(); + socket_log("[INFO] Internal HTTP started on port $INTERNAL_PORT"); +}); + +$io->on('connection', function ($socket) { + + $query = $socket->handshake['query'] ?? []; + $passengerId = $query['id'] ?? null; + $jwtToken = $query['jwt'] ?? ''; // JWT Token for authentication + $clientIp = $socket->conn->remoteAddress ?? 'Unknown'; + + if (!$passengerId || empty($jwtToken)) { + socket_log("[SOCKET_REJECTED] Connection rejected (No passenger ID or JWT missing) from IP: $clientIp"); + $socket->disconnect(); + return; + } + + try { + $secretKey = getJwtSecret(); + if (empty($secretKey)) { + socket_log("[WARNING] JWT Secret is not configured on the server!"); + } else { + $decoded = JWT::decode($jwtToken, new Key($secretKey, 'HS256')); + if ((string)$decoded->sub !== (string)$passengerId || $decoded->role !== 'passenger') { + socket_log("[SOCKET_REJECTED] Connection rejected: Invalid JWT for passenger_id=$passengerId from IP: $clientIp"); + $socket->disconnect(); + return; + } + } + } catch (\Exception $e) { + socket_log("[SOCKET_REJECTED] Connection rejected: JWT Verification failed -> " . $e->getMessage() . " from IP: $clientIp"); + $socket->disconnect(); + return; + } + + $socket->join('passenger_' . $passengerId); + socket_log("[SOCKET_CONNECTED] Passenger Connected: #$passengerId (IP: $clientIp)"); + + $socket->on('heartbeat', function ($data) { + // يمكن تفعيل السطر التالي للتأكد من النبضات إذا أردت دقة شديدة، لكنه قد يملأ ملف الـ log + // socket_log("[SOCKET_HEARTBEAT] Received from Passenger #$passengerId"); + }); + + $socket->on('disconnect', function () use ($passengerId, $clientIp) { + socket_log("[SOCKET_DISCONNECTED] Passenger Disconnected: #$passengerId (IP: $clientIp)"); + }); +}); + +Worker::runAll(); \ No newline at end of file diff --git a/ride_server/schema_ride.sql b/ride_server/schema_ride.sql new file mode 100644 index 00000000..df08bd33 --- /dev/null +++ b/ride_server/schema_ride.sql @@ -0,0 +1,1720 @@ +-- MySQL dump 10.13 Distrib 8.0.36-28, for Linux (x86_64) +-- +-- Host: localhost Database: intaleq-ridesDB +-- ------------------------------------------------------ +-- Server version 8.0.36-28 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!50717 SELECT COUNT(*) INTO @rocksdb_has_p_s_session_variables FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'session_variables' */; +/*!50717 SET @rocksdb_get_is_supported = IF (@rocksdb_has_p_s_session_variables, 'SELECT COUNT(*) INTO @rocksdb_is_supported FROM performance_schema.session_variables WHERE VARIABLE_NAME=\'rocksdb_bulk_load\'', 'SELECT 0') */; +/*!50717 PREPARE s FROM @rocksdb_get_is_supported */; +/*!50717 EXECUTE s */; +/*!50717 DEALLOCATE PREPARE s */; +/*!50717 SET @rocksdb_enable_bulk_load = IF (@rocksdb_is_supported, 'SET SESSION rocksdb_bulk_load = 1', 'SET @rocksdb_dummy_bulk_load = 0') */; +/*!50717 PREPARE s FROM @rocksdb_enable_bulk_load */; +/*!50717 EXECUTE s */; +/*!50717 DEALLOCATE PREPARE s */; + +-- +-- Table structure for table `CarRegistration` +-- + +DROP TABLE IF EXISTS `CarRegistration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `CarRegistration` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `vin` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `car_plate` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `make` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `model` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `year` varchar(10) CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL, + `expiration_date` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `color` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `owner` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `color_hex` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `fuel` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `isDefault` tinyint(1) NOT NULL DEFAULT '0', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'yet', + PRIMARY KEY (`id`), + UNIQUE KEY `car_plate` (`car_plate`), + KEY `idx_driverID` (`driverID`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `adminUser` +-- + +DROP TABLE IF EXISTS `adminUser`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `adminUser` ( + `id` int NOT NULL AUTO_INCREMENT, + `device_number` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `name` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `api_keys` +-- + +DROP TABLE IF EXISTS `api_keys`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `api_keys` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `hashed_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `blacklist_driver` +-- + +DROP TABLE IF EXISTS `blacklist_driver`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `blacklist_driver` ( + `id` int NOT NULL AUTO_INCREMENT, + `driver_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `phone` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'Violation', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `canecl` +-- + +DROP TABLE IF EXISTS `canecl`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `canecl` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(111) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `passengerID` varchar(111) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `rideID` varchar(111) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `note` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'nothing', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `captains_car` +-- + +DROP TABLE IF EXISTS `captains_car`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `captains_car` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `vin` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `car_plate` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `make` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `year` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `expiration_date` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `color` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `owner` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `color_hex` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `displacement` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `fuel` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `registration_date` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `isDefault` tinyint(1) NOT NULL DEFAULT '0', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `car_plate` (`car_plate`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `carPlateEdit` +-- + +DROP TABLE IF EXISTS `carPlateEdit`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `carPlateEdit` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(50) NOT NULL, + `carPlate` varchar(155) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `color` varchar(20) NOT NULL, + `make` varchar(50) NOT NULL, + `model` varchar(20) NOT NULL, + `expiration_date` varchar(50) NOT NULL, + `owner` varchar(155) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `year` int NOT NULL, + `isEdit` tinyint(1) NOT NULL DEFAULT '0', + `employee` varchar(30) NOT NULL DEFAULT 'any', + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `driverId` (`driverId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `car_locations` +-- + +DROP TABLE IF EXISTS `car_locations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `car_locations` ( + `driver_id` varchar(100) NOT NULL, + `latitude` decimal(10,7) NOT NULL, + `longitude` decimal(10,7) NOT NULL, + `heading` decimal(10,2) NOT NULL, + `speed` double(10,3) NOT NULL, + `distance` decimal(10,2) NOT NULL, + `status` varchar(6) NOT NULL DEFAULT 'off', + `carType` varchar(100) NOT NULL DEFAULT 'Awfar', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `location_point` point NOT NULL /*!80003 SRID 4326 */, + PRIMARY KEY (`driver_id`), + KEY `idx_loc_status_time` (`status`,`updated_at`,`latitude`,`longitude`), + SPATIAL KEY `idx_location_point` (`location_point`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`intaleq-rides`@`%`*/ /*!50003 TRIGGER `trg_before_insert_car_locations` BEFORE INSERT ON `car_locations` FOR EACH ROW BEGIN +SET NEW.location_point = ST_PointFromText(CONCAT('POINT(', NEW.longitude, ' ', NEW.latitude, ')'), 4326); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`intaleq-rides`@`%`*/ /*!50003 TRIGGER `trg_before_update_car_locations` BEFORE UPDATE ON `car_locations` FOR EACH ROW BEGIN +IF NEW.latitude <> OLD.latitude OR NEW.longitude <> OLD.longitude THEN +SET NEW.location_point = ST_PointFromText(CONCAT('POINT(', NEW.longitude, ' ', NEW.latitude, ')'), 4326); +END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Table structure for table `car_tracks` +-- + +DROP TABLE IF EXISTS `car_tracks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `car_tracks` ( + `id` int NOT NULL AUTO_INCREMENT, + `driver_id` varchar(100) NOT NULL, + `latitude` decimal(10,7) NOT NULL, + `longitude` decimal(10,7) NOT NULL, + `heading` float DEFAULT NULL, + `speed` float DEFAULT NULL, + `distance` float DEFAULT NULL, + `status` enum('on','off') DEFAULT 'off', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `card_images` +-- + +DROP TABLE IF EXISTS `card_images`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `card_images` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `image_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `upload_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `link` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `carsToWork` +-- + +DROP TABLE IF EXISTS `carsToWork`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `carsToWork` ( + `id` int NOT NULL AUTO_INCREMENT, + `owner_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `phone` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `car_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `manufacture_year` year NOT NULL, + `car_model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `car_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `site` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `registration_date` date NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `complaint` +-- + +DROP TABLE IF EXISTS `complaint`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `complaint` ( + `id` int NOT NULL AUTO_INCREMENT, + `ride_id` varchar(255) NOT NULL, + `passenger_id` varchar(255) DEFAULT NULL, + `driver_id` varchar(255) DEFAULT NULL, + `complaint_type` enum('Driver','Passenger','Both') NOT NULL, + `description` text, + `date_filed` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `statusComplaint` enum('Open','In Progress','Resolved') NOT NULL DEFAULT 'Open', + `resolution` text, + `passenger_report` text, + `driver_report` text, + `cs_solutions` text, + `fault_determination` varchar(255) DEFAULT NULL, + `complaint_nature` varchar(255) DEFAULT NULL, + `date_resolved` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `contactEgypt` +-- + +DROP TABLE IF EXISTS `contactEgypt`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `contactEgypt` ( + `id` int NOT NULL AUTO_INCREMENT, + `phones` varchar(20) NOT NULL, + `name` varchar(100) NOT NULL, + `phones2` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `contactSyria` +-- + +DROP TABLE IF EXISTS `contactSyria`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `contactSyria` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(255) NOT NULL COMMENT 'معرّف السائق الذي قام بمزامنة جهة الاتصال', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'اسم جهة الاتصال', + `phone` varchar(50) NOT NULL COMMENT 'رقم هاتف جهة الاتصال', + `sync_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'وقت المزامنة', + PRIMARY KEY (`id`), + UNIQUE KEY `driver_contact_unique` (`driverId`,`phone`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `criminalDocuments` +-- + +DROP TABLE IF EXISTS `criminalDocuments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `criminalDocuments` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(50) NOT NULL, + `IssueDate` varchar(20) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `InspectionResult` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `driverId` (`driverId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driver` +-- + +DROP TABLE IF EXISTS `driver`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driver` ( + `idn` int NOT NULL AUTO_INCREMENT, + `id` varchar(100) NOT NULL, + `phone` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `email` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `gender` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'Male', + `license_type` varchar(255) DEFAULT NULL, + `national_number` varchar(255) DEFAULT NULL, + `name_arabic` varchar(255) DEFAULT NULL, + `issue_date` date DEFAULT NULL, + `expiry_date` date DEFAULT NULL, + `license_categories` varchar(255) DEFAULT NULL, + `address` text, + `licenseIssueDate` varchar(50) DEFAULT NULL, + `status` varchar(20) NOT NULL DEFAULT 'notDeleted', + `birthdate` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `site` varchar(255) NOT NULL, + `first_name` varchar(255) NOT NULL, + `last_name` varchar(255) NOT NULL, + `accountBank` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'yet', + `bankCode` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'CIB', + `employmentType` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `maritalStatus` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `fullNameMaritial` varchar(255) DEFAULT NULL, + `expirationDate` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`idn`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driverToken` +-- + +DROP TABLE IF EXISTS `driverToken`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driverToken` ( + `id` int NOT NULL AUTO_INCREMENT, + `token` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `captain_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `fingerPrint` varchar(155) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `idx_captain_id` (`captain_id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + + +-- +-- Table structure for table `driver_behavior` +-- + +DROP TABLE IF EXISTS `driver_behavior`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driver_behavior` ( + `id` int NOT NULL, + `driver_id` varchar(255) NOT NULL, + `trip_id` varchar(255) NOT NULL, + `max_speed` double DEFAULT '0', + `avg_speed` double DEFAULT '0', + `hard_brakes` int DEFAULT '0', + `total_distance` double DEFAULT '0', + `behavior_score` double DEFAULT '0', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driver_documents` +-- + +DROP TABLE IF EXISTS `driver_documents`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driver_documents` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(64) NOT NULL, + `doc_type` varchar(64) NOT NULL, + `image_name` varchar(255) NOT NULL, + `link` varchar(512) NOT NULL, + `upload_date` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `driverID` (`driverID`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driver_gifts` +-- + +DROP TABLE IF EXISTS `driver_gifts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driver_gifts` ( + `id` int NOT NULL AUTO_INCREMENT, + `driver_id` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `gift_description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `gift_date` datetime DEFAULT CURRENT_TIMESTAMP, + `is_claimed` tinyint(1) DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `driver_id` (`driver_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driver_health_assurance` +-- + +DROP TABLE IF EXISTS `driver_health_assurance`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driver_health_assurance` ( + `id` int NOT NULL AUTO_INCREMENT, + `driver_id` varchar(155) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `assured` tinyint(1) DEFAULT '0', + `date_created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `health_insurance_provider` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `driver_id` (`driver_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driver_orders` +-- + +DROP TABLE IF EXISTS `driver_orders`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driver_orders` ( + `id` int NOT NULL AUTO_INCREMENT, + `driver_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `order_id` varchar(99) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `notes` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'nothing', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `status` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'applied', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driver_ride_scam` +-- + +DROP TABLE IF EXISTS `driver_ride_scam`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driver_ride_scam` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `passendgerID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `rideID` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `isDriverCallPassenger` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `dateCreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `driversWantWork` +-- + +DROP TABLE IF EXISTS `driversWantWork`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `driversWantWork` ( + `id` int NOT NULL AUTO_INCREMENT, + `driver_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `phone` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `national_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `birth_date` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `license_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `site` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `national_id` (`national_id`), + UNIQUE KEY `phone` (`phone`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `email_verifications` +-- + +DROP TABLE IF EXISTS `email_verifications`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `email_verifications` ( + `id` int NOT NULL AUTO_INCREMENT, + `email` varchar(255) NOT NULL, + `token` varchar(255) NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `verified` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `employee` +-- + +DROP TABLE IF EXISTS `employee`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `employee` ( + `id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `education` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `site` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `status` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `phone` (`phone`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `error` +-- + +DROP TABLE IF EXISTS `error`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `error` ( + `id` int NOT NULL AUTO_INCREMENT, + `error` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `userId` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `userType` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `device` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, + `status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'new', + PRIMARY KEY (`id`), + KEY `idx_error_created_at` (`created_at`), + KEY `idx_error_phone` (`phone`) +) ENGINE=InnoDB AUTO_INCREMENT=14316 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `feedBack` +-- + +DROP TABLE IF EXISTS `feedBack`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `feedBack` ( + `id` int NOT NULL AUTO_INCREMENT, + `passengerId` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `feedBack` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `datecreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `helpCenter` +-- + +DROP TABLE IF EXISTS `helpCenter`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `helpCenter` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(89) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `helpQuestion` varchar(300) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `replay` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'not yet', + `datecreated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `hotels` +-- + +DROP TABLE IF EXISTS `hotels`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `hotels` ( + `id` int NOT NULL, + `nameEnglish` varchar(255) DEFAULT NULL, + `nameArabic` varchar(255) DEFAULT NULL, + `phone` varchar(20) DEFAULT NULL, + `countReview` int DEFAULT NULL, + `rate` float DEFAULT NULL, + `stars` varchar(50) DEFAULT NULL, + `address` text, + `website` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `PlusCode` varchar(50) DEFAULT NULL, + `closeTime` varchar(50) DEFAULT NULL, + `latitude` decimal(10,6) DEFAULT NULL, + `longitude` decimal(10,6) DEFAULT NULL, + `instagram` varchar(255) DEFAULT NULL, + `facebook` varchar(255) DEFAULT NULL, + `linkedin` varchar(255) DEFAULT NULL, + `twitter` varchar(255) DEFAULT NULL, + `photo` varchar(255) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `imageProfileCaptain` +-- + +DROP TABLE IF EXISTS `imageProfileCaptain`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `imageProfileCaptain` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `image_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `upload_date` datetime DEFAULT CURRENT_TIMESTAMP, + `link` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `invites` +-- + +DROP TABLE IF EXISTS `invites`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `invites` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(50) NOT NULL, + `inviterDriverPhone` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `inviteCode` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `isInstall` tinyint(1) NOT NULL DEFAULT '0', + `isGiftToken` tinyint(1) NOT NULL DEFAULT '0', + `expirationTime` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `inviterDriverId` (`inviterDriverPhone`), + UNIQUE KEY `inviteCode` (`inviteCode`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `invitesToPassengers` +-- + +DROP TABLE IF EXISTS `invitesToPassengers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `invitesToPassengers` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `passengerID` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'yet', + `inviterPassengerPhone` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `inviteCode` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `expirationTime` datetime NOT NULL, + `createdAt` datetime DEFAULT CURRENT_TIMESTAMP, + `isInstall` tinyint(1) DEFAULT '0', + `isGiftToken` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `inviteCode` (`inviteCode`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `invoice_records` +-- + +DROP TABLE IF EXISTS `invoice_records`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `invoice_records` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` int NOT NULL, + `invoice_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `amount` decimal(10,2) DEFAULT NULL, + `date` date DEFAULT NULL, + `image_link` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, + `created_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `invoicesAdmin` +-- + +DROP TABLE IF EXISTS `invoicesAdmin`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `invoicesAdmin` ( + `id` int NOT NULL AUTO_INCREMENT, + `item_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `amount` decimal(10,2) NOT NULL, + `image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `kazan` +-- + +DROP TABLE IF EXISTS `kazan`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `kazan` ( + `id` int NOT NULL AUTO_INCREMENT, + `country` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `kazan` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `comfortPrice` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `speedPrice` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `familyPrice` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `deliveryPrice` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `freePrice` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `latePrice` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `heavyPrice` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `adminId` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `naturePrice` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `fuelPrice` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `lisenceDetails` +-- + +DROP TABLE IF EXISTS `lisenceDetails`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `lisenceDetails` ( + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `driverID` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `licenseClass` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `documentNo` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `height` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `postalCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `sex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `stateCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expireDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `dateOfBirth` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `dateCreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `documentNo` (`documentNo`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `login_attempts` +-- + +DROP TABLE IF EXISTS `login_attempts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `login_attempts` ( + `id` int NOT NULL AUTO_INCREMENT, + `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `attempt_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `login_attempts_drivers` +-- + +DROP TABLE IF EXISTS `login_attempts_drivers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `login_attempts_drivers` ( + `id` int NOT NULL AUTO_INCREMENT, + `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `attempt_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `mishwaritrips` +-- + +DROP TABLE IF EXISTS `mishwaritrips`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `mishwaritrips` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `phone` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `gender` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `name_english` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `religion` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `age` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `startNameAddress` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'none', + `locationCoordinate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'none', + `education` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `license_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `national_number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `car_plate` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `make` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `color` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `color_hex` char(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `rating` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `countRide` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `passengerId` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `timeSelected` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `createdAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'pending', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `notesForDriverService` +-- + +DROP TABLE IF EXISTS `notesForDriverService`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `notesForDriverService` ( + `id` int NOT NULL AUTO_INCREMENT, + `phone` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `note` varchar(250) NOT NULL, + `editor` varchar(50) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `phone` (`phone`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `notesForPassengerService` +-- + +DROP TABLE IF EXISTS `notesForPassengerService`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `notesForPassengerService` ( + `id` int NOT NULL AUTO_INCREMENT, + `phone` int NOT NULL, + `note` varchar(250) NOT NULL, + `editor` varchar(50) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `notificationCaptain` +-- + +DROP TABLE IF EXISTS `notificationCaptain`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `notificationCaptain` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `title` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `body` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `isShown` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'false', + `isPin` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'unPin', + `dateCreated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `notifications` +-- + +DROP TABLE IF EXISTS `notifications`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `notifications` ( + `id` int NOT NULL AUTO_INCREMENT, + `title` varchar(111) NOT NULL, + `body` varchar(265) NOT NULL, + `passenger_id` varchar(111) NOT NULL, + `isShown` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'false', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `otp_verification_fingerPrint` +-- + +DROP TABLE IF EXISTS `otp_verification_fingerPrint`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `otp_verification_fingerPrint` ( + `id` int NOT NULL, + `phone` varchar(20) NOT NULL, + `otp` varchar(6) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `packageInfo` +-- + +DROP TABLE IF EXISTS `packageInfo`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `packageInfo` ( + `id` int NOT NULL AUTO_INCREMENT, + `platform` varchar(50) NOT NULL, + `appName` varchar(20) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `version` varchar(10) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `palces11` +-- + +DROP TABLE IF EXISTS `palces11`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `palces11` ( + `id` int NOT NULL AUTO_INCREMENT, + `latitude` varchar(50) NOT NULL, + `longitude` varchar(50) NOT NULL, + `name` varchar(180) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `name_ar` varchar(200) NOT NULL, + `name_en` varchar(200) NOT NULL, + `address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `category` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `location` point NOT NULL, + PRIMARY KEY (`id`), + SPATIAL KEY `idx_spatial_location` (`location`), + FULLTEXT KEY `idx_fulltext_search` (`name`,`name_ar`,`name_en`,`address`,`category`) +) ENGINE=InnoDB AUTO_INCREMENT=28951 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + + +-- +-- Table structure for table `passenger_blacklist` +-- + +DROP TABLE IF EXISTS `passenger_blacklist`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `passenger_blacklist` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `phone` varchar(150) NOT NULL, + `phone_normalized` varchar(64) NOT NULL, + `reason` varchar(255) DEFAULT NULL, + `expires_at` datetime DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_phone_norm` (`phone_normalized`), + KEY `idx_expires` (`expires_at`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `passengerlocation` +-- + +DROP TABLE IF EXISTS `passengerlocation`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `passengerlocation` ( + `id` int NOT NULL AUTO_INCREMENT, + `passengerId` varchar(60) NOT NULL, + `lat` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `lng` varchar(20) NOT NULL, + `rideId` varchar(10) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `passengers` +-- + +DROP TABLE IF EXISTS `passengers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `passengers` ( + `id` varchar(100) NOT NULL, + `phone` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `email` varchar(255) NOT NULL, + `password` varchar(100) NOT NULL, + `gender` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `status` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'notDeleted', + `birthdate` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `site` varchar(255) NOT NULL, + `first_name` varchar(255) NOT NULL, + `last_name` varchar(255) NOT NULL, + `sosPhone` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'sos', + `education` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'none', + `employmentType` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'none', + `maritalStatus` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'none', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `phone` (`phone`,`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `payment_tokens` +-- + +DROP TABLE IF EXISTS `payment_tokens`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `payment_tokens` ( + `id` int NOT NULL AUTO_INCREMENT, + `token` varchar(255) NOT NULL, + `driverID` varchar(255) NOT NULL, + `dateCreated` datetime NOT NULL, + `amount` decimal(10,2) NOT NULL, + `isUsed` tinyint(1) DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `payment_tokens_passenger` +-- + +DROP TABLE IF EXISTS `payment_tokens_passenger`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `payment_tokens_passenger` ( + `id` int NOT NULL AUTO_INCREMENT, + `token` varchar(255) NOT NULL, + `passengerId` varchar(255) NOT NULL, + `dateCreated` datetime NOT NULL, + `amount` decimal(10,2) NOT NULL, + `isUsed` tinyint(1) DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + + + + + +-- +-- Table structure for table `phone_verification` +-- + +DROP TABLE IF EXISTS `phone_verification`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `phone_verification` ( + `id` int NOT NULL AUTO_INCREMENT, + `phone_number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `driverId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'yet', + `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'yet', + `token_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `expiration_time` datetime NOT NULL, + `is_verified` tinyint(1) DEFAULT '0', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=111 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `phone_verification_passenger` +-- + +DROP TABLE IF EXISTS `phone_verification_passenger`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `phone_verification_passenger` ( + `id` int NOT NULL AUTO_INCREMENT, + `phone_number` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `token` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `expiration_time` datetime NOT NULL, + `verified` tinyint(1) DEFAULT '0', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `status` varchar(22) NOT NULL DEFAULT 'yet', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=109 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `places` +-- + +DROP TABLE IF EXISTS `places`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `places` ( + `id` int NOT NULL AUTO_INCREMENT, + `latitude` double NOT NULL, + `longitude` double NOT NULL, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `name_ar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `name_en` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `category` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=58830 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `placesEgypt` +-- + +DROP TABLE IF EXISTS `placesEgypt`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `placesEgypt` ( + `id` int NOT NULL, + `nameEnglish` varchar(255) DEFAULT NULL, + `nameArabic` varchar(255) DEFAULT NULL, + `phone` varchar(20) DEFAULT NULL, + `countReview` int DEFAULT NULL, + `rate` float DEFAULT NULL, + `stars` varchar(50) DEFAULT NULL, + `address` text, + `website` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `PlusCode` varchar(50) DEFAULT NULL, + `closeTime` varchar(50) DEFAULT NULL, + `latitude` decimal(10,6) DEFAULT NULL, + `longitude` decimal(10,6) DEFAULT NULL, + `instagram` varchar(255) DEFAULT NULL, + `facebook` varchar(255) DEFAULT NULL, + `linkedin` varchar(255) DEFAULT NULL, + `twitter` varchar(255) DEFAULT NULL, + `photo` varchar(255) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `promos` +-- + +DROP TABLE IF EXISTS `promos`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `promos` ( + `id` int NOT NULL AUTO_INCREMENT, + `promo_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `amount` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0', + `description` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `passengerID` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'none', + `validity_start_date` date DEFAULT NULL, + `validity_end_date` date DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `passengerID` (`passengerID`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `promptDriverIDEgypt` +-- + +DROP TABLE IF EXISTS `promptDriverIDEgypt`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `promptDriverIDEgypt` ( + `id` int NOT NULL AUTO_INCREMENT, + `type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `prompt` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `createdAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updatedAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ratingApp` +-- + +DROP TABLE IF EXISTS `ratingApp`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `ratingApp` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `email` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `phone` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `userId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `userType` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `rating` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `comment` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ratingDriver` +-- + +DROP TABLE IF EXISTS `ratingDriver`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `ratingDriver` ( + `id` int NOT NULL AUTO_INCREMENT, + `passenger_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, + `driver_id` varchar(33) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `ride_id` int DEFAULT NULL, + `rating` float DEFAULT NULL, + `comment` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `ride_id` (`ride_id`), + KEY `idx_driver_id` (`driver_id`) +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ratingPassenger` +-- + +DROP TABLE IF EXISTS `ratingPassenger`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `ratingPassenger` ( + `id` int NOT NULL AUTO_INCREMENT, + `passenger_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `driverID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `rideId` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `rating` float NOT NULL, + `comment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `rideId` (`rideId`) +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ride` +-- + +DROP TABLE IF EXISTS `ride`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `ride` ( + `id` int NOT NULL AUTO_INCREMENT, + `start_location` varchar(255) NOT NULL, + `end_location` varchar(255) NOT NULL, + `date` date NOT NULL, + `time` time NOT NULL, + `endtime` time NOT NULL, + `price` decimal(10,2) NOT NULL DEFAULT '0.00', + `ai_negotiated_bonus` double DEFAULT '0', + `passenger_id` varchar(111) NOT NULL, + `driver_id` varchar(111) NOT NULL, + `status` varchar(200) NOT NULL DEFAULT 'nothing', + `paymentMethod` varchar(20) NOT NULL DEFAULT 'Cash', + `carType` varchar(20) NOT NULL DEFAULT 'Speed', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `is_destination_match` tinyint(1) NOT NULL DEFAULT 0, + `DriverIsGoingToPassenger` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `rideTimeStart` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `rideTimeFinish` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `price_for_driver` decimal(10,2) NOT NULL DEFAULT '0.00', + `price_for_passenger` decimal(10,2) NOT NULL DEFAULT '0.00', + `distance` float DEFAULT '0', + PRIMARY KEY (`id`), + KEY `passengerfk` (`passenger_id`), + KEY `driverfk` (`driver_id`) +) ENGINE=InnoDB AUTO_INCREMENT=831 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `seferWallet` +-- + +DROP TABLE IF EXISTS `seferWallet`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `seferWallet` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(100) NOT NULL, + `passengerId` varchar(100) NOT NULL, + `amount` varchar(10) NOT NULL, + `paymentMethod` varchar(50) NOT NULL, + `token` varchar(100) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `server_locations` +-- + +DROP TABLE IF EXISTS `server_locations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `server_locations` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `min_latitude` decimal(10,6) NOT NULL, + `max_latitude` decimal(10,6) NOT NULL, + `min_longitude` decimal(10,6) NOT NULL, + `max_longitude` decimal(10,6) NOT NULL, + `server_link` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `smsSender` +-- + +DROP TABLE IF EXISTS `smsSender`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `smsSender` ( + `id` int NOT NULL AUTO_INCREMENT, + `senderId` varchar(20) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `test` +-- + +DROP TABLE IF EXISTS `test`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `test` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(22) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `testApp` +-- + +DROP TABLE IF EXISTS `testApp`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `testApp` ( + `id` int NOT NULL AUTO_INCREMENT, + `isTest` tinyint(1) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `appPlatform` varchar(20) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `tips` +-- + +DROP TABLE IF EXISTS `tips`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `tips` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `passengerID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `rideID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `tipAmount` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `token_verification` +-- + +DROP TABLE IF EXISTS `token_verification`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `token_verification` ( + `id` int NOT NULL AUTO_INCREMENT, + `phone_number` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `expiration_time` datetime NOT NULL, + `verified` tinyint(1) DEFAULT '0', + `created_at` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `token_verification_admin` +-- + +DROP TABLE IF EXISTS `token_verification_admin`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `token_verification_admin` ( + `id` int NOT NULL AUTO_INCREMENT, + `phone_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `token` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `expiration_time` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `phone_number` (`phone_number`) +) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `token_verification_driver` +-- + +DROP TABLE IF EXISTS `token_verification_driver`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `token_verification_driver` ( + `id` int NOT NULL AUTO_INCREMENT, + `phone_number` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `expiration_time` datetime NOT NULL, + `verified` tinyint(1) NOT NULL DEFAULT '0', + `created_at` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `tokens` +-- + +DROP TABLE IF EXISTS `tokens`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `tokens` ( + `id` int NOT NULL AUTO_INCREMENT, + `token` varchar(333) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `passengerID` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `fingerPrint` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `status` varchar(22) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'yet', + PRIMARY KEY (`id`), + UNIQUE KEY `passengerID` (`passengerID`) +) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `users` ( + `id` varchar(111) NOT NULL, + `phone` varchar(15) NOT NULL, + `email` varchar(255) NOT NULL, + `gender` varchar(10) NOT NULL, + `password` varchar(100) NOT NULL, + `birthdate` date NOT NULL, + `site` varchar(255) NOT NULL, + `first_name` varchar(255) NOT NULL, + `last_name` varchar(255) NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `user_type` varchar(44) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`), + UNIQUE KEY `phone` (`phone`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `vehicles` +-- + +DROP TABLE IF EXISTS `vehicles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `vehicles` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverID` varchar(100) NOT NULL, + `make` varchar(255) NOT NULL, + `model` varchar(255) NOT NULL, + `license_plate` varchar(255) NOT NULL, + `seats` int NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `license_plate` (`license_plate`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `videos` +-- + +DROP TABLE IF EXISTS `videos`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `videos` ( + `id` int NOT NULL AUTO_INCREMENT, + `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `description` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `url` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `waitingRides` +-- + +DROP TABLE IF EXISTS `waitingRides`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `waitingRides` ( + `id` varchar(100) NOT NULL, + `start_location` varchar(255) NOT NULL, + `end_location` varchar(255) NOT NULL, + `date` date NOT NULL, + `time` time NOT NULL, + `price` decimal(10,2) NOT NULL DEFAULT '0.00', + `passenger_id` varchar(111) NOT NULL, + `status` varchar(200) NOT NULL DEFAULT 'nothing', + `carType` varchar(19) NOT NULL, + `passengerRate` decimal(10,2) NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `price_for_passenger` decimal(10,2) NOT NULL DEFAULT '0.00', + `distance` varchar(255) NOT NULL, + `duration` varchar(10) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `welcomeDriverCall` +-- + +DROP TABLE IF EXISTS `welcomeDriverCall`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `welcomeDriverCall` ( + `id` int NOT NULL AUTO_INCREMENT, + `driverId` varchar(50) NOT NULL, + `isCall` tinyint(1) NOT NULL DEFAULT '0', + `notes` varchar(255) NOT NULL, + `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `write_argument_after_applied_from_background` +-- + +DROP TABLE IF EXISTS `write_argument_after_applied_from_background`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `write_argument_after_applied_from_background` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `ride_id` varchar(50) NOT NULL, + `driver_id` varchar(50) NOT NULL, + `passenger_id` varchar(50) NOT NULL, + `passenger_location` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `passenger_destination` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `duration` varchar(255) NOT NULL, + `duration_to_passenger` varchar(255) NOT NULL, + `duration_of_ride` varchar(255) NOT NULL, + `distance` varchar(255) NOT NULL, + `total_cost` varchar(255) NOT NULL, + `payment_amount` varchar(255) NOT NULL, + `payment_method` enum('visa','cash') NOT NULL, + `wallet_checked` varchar(255) NOT NULL, + `has_steps` varchar(255) NOT NULL, + `step0` varchar(255) DEFAULT NULL, + `step1` varchar(255) DEFAULT NULL, + `step2` varchar(255) DEFAULT NULL, + `step3` varchar(255) DEFAULT NULL, + `step4` varchar(255) DEFAULT NULL, + `passenger_wallet_burc` varchar(33) NOT NULL, + `token_passenger` varchar(255) NOT NULL, + `name` varchar(100) NOT NULL, + `phone` varchar(20) NOT NULL, + `email` varchar(150) NOT NULL, + `start_name_location` varchar(255) NOT NULL, + `end_name_location` varchar(255) NOT NULL, + `car_type` varchar(50) NOT NULL, + `kazan` varchar(255) NOT NULL, + `direction_url` text NOT NULL, + `time_of_order` datetime NOT NULL, + `total_passenger` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping events for database 'intaleq-ridesDB' +-- + +-- +-- Dumping routines for database 'intaleq-ridesDB' +-- +/*!50112 SET @disable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load = @old_rocksdb_bulk_load', 'SET @dummy_rocksdb_bulk_load = 0') */; +/*!50112 PREPARE s FROM @disable_bulk_load */; +/*!50112 EXECUTE s */; +/*!50112 DEALLOCATE PREPARE s */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2026-04-22 20:58:51 diff --git a/siro_driver/lib/constant/links.dart b/siro_driver/lib/constant/links.dart index de3c85e7..4fe2d364 100755 --- a/siro_driver/lib/constant/links.dart +++ b/siro_driver/lib/constant/links.dart @@ -555,8 +555,7 @@ class AppLink { static String get claimInviteReward => "$server/ride/invitor/claim.php"; static String get updateInvitationCodeFromRegister => "$ride/invitor/updateInvitationCodeFromRegister.php"; - static String get register_driver_and_car => - "$auth/driver/register.php"; + static String get register_driver_and_car => "$auth/driver/register.php"; static String get updateDriverInvitationDirectly => "$ride/invitor/updateDriverInvitationDirectly.php"; static String get updatePassengersInvitation => diff --git a/siro_driver/lib/controller/home/navigation/navigation_controller.dart b/siro_driver/lib/controller/home/navigation/navigation_controller.dart index 58280c85..55323fd0 100644 --- a/siro_driver/lib/controller/home/navigation/navigation_controller.dart +++ b/siro_driver/lib/controller/home/navigation/navigation_controller.dart @@ -381,8 +381,11 @@ class NavigationController extends GetxController Future onStyleLoaded() async { Log.print("DEBUG: NavigationController.onStyleLoaded called"); - isStyleLoaded = true; + // Register the custom icons (car/start/dest) BEFORE marking the style as + // ready. Otherwise a location tick can fire _updateCarMarker() in the gap + // and reference 'car_icon' before it exists in the style → blank marker. await _loadCustomIcons(); + isStyleLoaded = true; WidgetsBinding.instance.addPostFrameCallback((_) async { await Future.delayed(const Duration(milliseconds: 300)); @@ -490,8 +493,7 @@ class NavigationController extends GetxController _isProcessing = true; try { - currentSpeed = - locSpeed; // Convert m/s to km/h already done by location controller if needed, wait location_controller sends raw speed or km/h? It sends raw speed. So we should * 3.6 + // LocationController forwards raw speed in m/s; convert to km/h. currentSpeed = locSpeed * 3.6; // Skip if movement is too small @@ -674,7 +676,21 @@ class NavigationController extends GetxController } Future _updateCarMarker() async { - // Car marker is now handled natively by myLocationEnabled: true. + if (myLocation == null || !isStyleLoaded || mapController == null) return; + // Draw the driver's car as a single imperatively-managed puck. It moves on + // every location tick, so it must NOT live in the declarative `markers` set + // (in-place mutation of that Set is invisible to the map widget's diff and + // makes the car freeze or never render). setUserMarker updates one native + // symbol in place instead. + await mapController!.setUserMarker(Marker( + markerId: const MarkerId('car'), + position: myLocation!, + icon: InlqBitmap.fromStyleImage('car_icon'), + anchor: const Offset(0.5, 0.5), + flat: true, + rotation: _smoothedHeading, + zIndex: 100, + )); } void animateCameraToPosition(LatLng position, @@ -1053,8 +1069,9 @@ class NavigationController extends GetxController _finalDestination = destination; await clearRoute(isNewRoute: true); - // Preserve car marker if it exists - markers = markers.where((m) => m.markerId.value == 'car').toSet(); + // The car puck is managed imperatively (setUserMarker), not via this set, + // so start from a clean declarative set holding only origin/destination. + markers = {}; markers.add(Marker( markerId: const MarkerId('destination'), diff --git a/siro_driver/lib/controller/home/navigation/navigation_view.dart b/siro_driver/lib/controller/home/navigation/navigation_view.dart index 7d4dab89..33272402 100644 --- a/siro_driver/lib/controller/home/navigation/navigation_view.dart +++ b/siro_driver/lib/controller/home/navigation/navigation_view.dart @@ -46,6 +46,7 @@ class NavigationView extends StatelessWidget { child: IntaleqMap( apiKey: Env.mapSaasKey, onMapCreated: c.onMapCreated, + onStyleLoaded: c.onStyleLoaded, onLongPress: (pos) => c.onMapLongPressed(Point(0, 0), pos), onTap: (pos) => c.onMapTapped(Point(0, 0), pos), markers: c.markers, diff --git a/siro_rider/lib/constant/links.dart b/siro_rider/lib/constant/links.dart index 5a4f5d7a..3114f0b1 100644 --- a/siro_rider/lib/constant/links.dart +++ b/siro_rider/lib/constant/links.dart @@ -201,7 +201,8 @@ class AppLink { //=======================Siro Prime=================== static String get initiatePrime => "$server/api/payments/initiate_prime.php"; - static String get getPrimeStatus => "$server/api/payments/get_prime_status.php"; + static String get getPrimeStatus => + "$server/api/payments/get_prime_status.php"; static String get getWalletByDriver => "$walletDriver/getWalletByDriver.php"; static String get getDriversWallet => "$walletDriver/get.php"; @@ -396,7 +397,8 @@ class AppLink { // Endpoint لجلب التسعيرة من السيرفر (Server-Side Pricing) static String get getPrices => "$server/ride/pricing/get.php"; - static String get getCompetitorContext => "$server/api/ride/get_competitor_context.php"; + static String get getCompetitorContext => + "$server/api/ride/get_competitor_context.php"; static String get addRateToDriver => "$server/ride/rate/addRateToDriver.php"; static String get getDriverRate => "$server/ride/rate/getDriverRate.php"; diff --git a/siro_rider/lib/controller/home/map/ride_lifecycle_controller.dart b/siro_rider/lib/controller/home/map/ride_lifecycle_controller.dart index f44fc64a..95f9bff6 100644 --- a/siro_rider/lib/controller/home/map/ride_lifecycle_controller.dart +++ b/siro_rider/lib/controller/home/map/ride_lifecycle_controller.dart @@ -1889,7 +1889,7 @@ class RideLifecycleController extends GetxController { var digest = md5.convert(bytes); String token = digest.toString(); - return "https://intaleqapp.com/track/index.php?id=$cleanRideId&token=$token"; + return "https://siromove.com/track/index.php?id=$cleanRideId&token=$token"; } calcualateDistsanceInMetet(LatLng prev, current) async { @@ -2205,52 +2205,77 @@ class RideLifecycleController extends GetxController { Future calculateDriverToPassengerRoute( LatLng driverPos, LatLng passengerPos, {bool isBeginPhase = false}) async { - if (mapController == null) { - Log.print('⚠️ mapController is null, cannot calculate route via intaleq_maps'); + Log.print( + '⚠️ mapController is null, cannot calculate route via intaleq_maps'); return; } Log.print('📍 Calculating Driver Route via IntaleqMapController...'); try { - final responseData = await mapController!.getDirections(driverPos, passengerPos); + final responseData = + await mapController!.getDirections(driverPos, passengerPos); var routeData = responseData['routes'] != null ? responseData['routes'][0] : responseData; - double durationSecondsRaw = (routeData['trafficAwareDuration'] ?? routeData['duration'] as num).toDouble(); - int finalDurationSeconds = - (durationSecondsRaw * kDurationScalar).toInt(); - double distanceMeters = (routeData['distance'] as num).toDouble(); + double durationSecondsRaw = + (routeData['trafficAwareDuration'] ?? routeData['duration'] as num) + .toDouble(); + int finalDurationSeconds = (durationSecondsRaw * kDurationScalar).toInt(); + double distanceMeters = (routeData['distance'] as num).toDouble(); - updateDriverRouteMetrics( - etaSeconds: finalDurationSeconds, - distanceMeters: distanceMeters, - ); - _currentDriverRouteDistanceMeters = distanceMeters; - _currentDriverRouteDurationSeconds = finalDurationSeconds; + updateDriverRouteMetrics( + etaSeconds: finalDurationSeconds, + distanceMeters: distanceMeters, + ); + _currentDriverRouteDistanceMeters = distanceMeters; + _currentDriverRouteDurationSeconds = finalDurationSeconds; - int minutes = (finalDurationSeconds / 60).floor(); - int seconds = finalDurationSeconds % 60; - stringRemainingTimeToPassenger = - '$minutes:${seconds.toString().padLeft(2, '0')}'; + int minutes = (finalDurationSeconds / 60).floor(); + int seconds = finalDurationSeconds % 60; + stringRemainingTimeToPassenger = + '$minutes:${seconds.toString().padLeft(2, '0')}'; - Log.print( - '✅ Driver Route Info: $minutes min, ${distanceMeters.toInt()} m'); + Log.print( + '✅ Driver Route Info: $minutes min, ${distanceMeters.toInt()} m'); - String pointsString = - routeData['points'] ?? routeData['geometry'] ?? ""; - if (pointsString.isNotEmpty) { - List decodedPoints = - await compute(decodePolylineIsolate, pointsString); - _currentDriverRoutePoints = decodedPoints; - final double decodedDistance = _pathDistanceMeters(decodedPoints); - if (decodedDistance > 0) { - _currentDriverRouteDistanceMeters = decodedDistance; - } - // مسح كل السلمات السابقة (الخط المستمر والمتقطع على حد سواء) + String pointsString = routeData['points'] ?? routeData['geometry'] ?? ""; + if (pointsString.isNotEmpty) { + List decodedPoints = + await compute(decodePolylineIsolate, pointsString); + _currentDriverRoutePoints = decodedPoints; + final double decodedDistance = _pathDistanceMeters(decodedPoints); + if (decodedDistance > 0) { + _currentDriverRouteDistanceMeters = decodedDistance; + } + // مسح كل السلمات السابقة (الخط المستمر والمتقطع على حد سواء) + polyLines = polyLines + .where((p) => + !p.polylineId.value.startsWith('driver_route') && + p.polylineId.value != 'main_route' && + !p.polylineId.value.startsWith('route_primary') && + p.polylineId.value != 'route_direct') + .toSet(); + + if (isBeginPhase) { + // حالة Begin: لا نرسم مسار السائق القديم إطلاقاً لأنه وصل والآن الرحلة ستبدأ + polyLines = polyLines + .where((p) => !p.polylineId.value.startsWith('driver_route')) + .toSet(); + polyLines = { + ...polyLines, + Polyline( + polylineId: const PolylineId('main_route'), + points: decodedPoints, + color: const Color(0xFF2196F3), + width: 6, + ) + }; + } else { + // مسح السلمات القديمة أولاً polyLines = polyLines .where((p) => !p.polylineId.value.startsWith('driver_route') && @@ -2258,46 +2283,22 @@ class RideLifecycleController extends GetxController { !p.polylineId.value.startsWith('route_primary') && p.polylineId.value != 'route_direct') .toSet(); - - if (isBeginPhase) { - // حالة Begin: لا نرسم مسار السائق القديم إطلاقاً لأنه وصل والآن الرحلة ستبدأ - polyLines = polyLines - .where((p) => !p.polylineId.value.startsWith('driver_route')) - .toSet(); - polyLines = { - ...polyLines, - Polyline( - polylineId: const PolylineId('main_route'), - points: decodedPoints, - color: const Color(0xFF2196F3), - width: 6, - ) - }; - } else { - // مسح السلمات القديمة أولاً - polyLines = polyLines - .where((p) => - !p.polylineId.value.startsWith('driver_route') && - p.polylineId.value != 'main_route' && - !p.polylineId.value.startsWith('route_primary') && - p.polylineId.value != 'route_direct') - .toSet(); - // حالة Apply/Arrived: خط متصل صلب بدل المتقطع - polyLines = { - ...polyLines, - Polyline( - polylineId: const PolylineId('driver_route_solid'), - points: decodedPoints, - color: Colors.amber, // مسار القدوم باللون الأصفر - width: 5, - ) - }; - } + // حالة Apply/Arrived: خط متصل صلب بدل المتقطع + polyLines = { + ...polyLines, + Polyline( + polylineId: const PolylineId('driver_route_solid'), + points: decodedPoints, + color: Colors.amber, // مسار القدوم باللون الأصفر + width: 5, + ) + }; } + } - mapEngine.fitCameraToPoints(driverPos, passengerPos); - _updatePassengerWalkLine(); - update(); + mapEngine.fitCameraToPoints(driverPos, passengerPos); + _updatePassengerWalkLine(); + update(); } catch (e) { Log.print('❌ Error calculating driver route: $e'); } @@ -3521,8 +3522,9 @@ class RideLifecycleController extends GetxController { // 🔥 [Fix Race] كل طلب جديد (attemptCount == 0) يفتح "جيلاً" جديداً؛ // إعادة المحاولات (retries) تتبع نفس الجيل. أي استجابة تصل بعد أن بدأ // جيل أحدث (تبديل وجهة سريع) تُهمَل ولا تكتب فوق الحالة الحالية. - final int myGeneration = - attemptCount == 0 ? (++_routeRequestGeneration) : (gen ?? _routeRequestGeneration); + final int myGeneration = attemptCount == 0 + ? (++_routeRequestGeneration) + : (gen ?? _routeRequestGeneration); if (attemptCount == 0) { isDrawingRoute = true; @@ -3616,8 +3618,8 @@ class RideLifecycleController extends GetxController { if (attemptCount < 2) { Log.print("🔄 Retrying request (Attempt ${attemptCount + 2})..."); await Future.delayed(const Duration(seconds: 1)); - await getDirectionMap(origin, destination, waypoints, - attemptCount + 1, myGeneration); + await getDirectionMap( + origin, destination, waypoints, attemptCount + 1, myGeneration); return; } else { Log.print("❌ All retries failed. Calculating Route is impossible."); @@ -3798,8 +3800,9 @@ class RideLifecycleController extends GetxController { } } - Future _retryProcess(String origin, String dest, List waypoints, - int currentAttempt, [int? gen]) async { + Future _retryProcess( + String origin, String dest, List waypoints, int currentAttempt, + [int? gen]) async { Log.print( "🔄 Exception or Error caught. Retrying in 1s... (Attempt ${currentAttempt + 1})"); await Future.delayed(const Duration(seconds: 1)); @@ -4481,7 +4484,7 @@ class RideLifecycleController extends GetxController { required double dashLengthMeters, required double gapLengthMeters, required Color color, - required int width, + required double width, required String idPrefix, }) { final Set result = {}; diff --git a/siro_rider/lib/views/home/navigation/navigation_controller.dart b/siro_rider/lib/views/home/navigation/navigation_controller.dart index 51e24928..75a297f7 100644 --- a/siro_rider/lib/views/home/navigation/navigation_controller.dart +++ b/siro_rider/lib/views/home/navigation/navigation_controller.dart @@ -407,8 +407,11 @@ class NavigationController extends GetxController Future onStyleLoaded() async { Log.print("DEBUG: NavigationController.onStyleLoaded called"); - isStyleLoaded = true; + // Register the custom icons (car/start/dest) BEFORE marking the style as + // ready. Otherwise a location tick can fire _updateCarMarker() in the gap + // and reference 'car_icon' before it exists in the style → blank marker. await _loadCustomIcons(); + isStyleLoaded = true; WidgetsBinding.instance.addPostFrameCallback((_) async { await Future.delayed(const Duration(milliseconds: 300)); @@ -715,9 +718,12 @@ class NavigationController extends GetxController } Future _updateCarMarker() async { - if (myLocation == null || !isStyleLoaded) return; - markers.removeWhere((m) => m.markerId.value == 'car'); - markers.add(Marker( + if (myLocation == null || !isStyleLoaded || mapController == null) return; + // The car puck moves on every GPS/animation tick. Driving it through the + // declarative `markers` set means mutating the same Set in place, which the + // map widget's diff can't see (old == new reference) — so the puck would + // freeze or never appear. Update it imperatively as a single native symbol. + await mapController!.setUserMarker(Marker( markerId: const MarkerId('car'), position: myLocation!, icon: InlqBitmap.fromStyleImage('car_icon'), @@ -1113,8 +1119,9 @@ class NavigationController extends GetxController _finalDestination = destination; await clearRoute(isNewRoute: true); - // Preserve car marker if it exists - markers = markers.where((m) => m.markerId.value == 'car').toSet(); + // The car puck is managed imperatively (setUserMarker), not via this set, + // so start from a clean declarative set holding only origin/destination. + markers = {}; markers.add(Marker( markerId: const MarkerId('destination'),