Update: 2026-06-30 21:12:26

This commit is contained in:
Hamza-Ayed
2026-06-30 21:12:26 +03:00
parent c2eab19045
commit 1ae8acad7a
14 changed files with 90 additions and 55 deletions

View File

@@ -133,11 +133,13 @@ if ($method === 'GET') {
// 1. Save to MySQL
$stmt = $con->prepare("
INSERT INTO competitor_prices
(competitor_name, from_latitude, from_longitude, to_latitude, to_longitude, distance_km, total_price, price_per_km, country_code)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO scraped_competitor_prices
(task_id, app_name, competitor_name, start_location, end_location, start_lat, start_lng, end_lat, end_lng, price_amount, price_per_km, currency, country_code)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
");
$stmt->execute([$app_name, (string)$start_lat, (string)$start_lng, (string)$end_lat, (string)$end_lng, $distance_km, $price, $pricePerKm, $country_code]);
$start_loc = "Lat: $start_lat, Lng: $start_lng";
$end_loc = "Lat: $end_lat, Lng: $end_lng";
$stmt->execute([$task_id, $app_name, $app_name, $start_loc, $end_loc, (string)$start_lat, (string)$start_lng, (string)$end_lat, (string)$end_lng, $price, $pricePerKm, 'JOD', $country_code]);
// 2. Save to Redis (Calculate Price Per KM)
if ($distance_km > 0 && $price > 0) {