Update: 2026-07-06 02:31:40
This commit is contained in:
@@ -196,14 +196,14 @@ function calculateDynamicPrice($country, $minFare, $distance, $duration, $kazanR
|
|||||||
$isEgypt = ($kazanRow['country'] === 'Egypt' || $kazanRow['country'] === 'EG');
|
$isEgypt = ($kazanRow['country'] === 'Egypt' || $kazanRow['country'] === 'EG');
|
||||||
|
|
||||||
if ($isJordan) {
|
if ($isJordan) {
|
||||||
$longSpeedPerKm = 0.30; // Reasonable long distance speed price for Jordan
|
$longSpeedPerKm = 0.17; // Long trips should be cheaper per km!
|
||||||
$longTripPerMin = 0.06; // Reasonable long distance minute price for Jordan
|
$longTripPerMin = 0.02; // Highway time is usually discounted
|
||||||
} else if ($isEgypt) {
|
} else if ($isEgypt) {
|
||||||
$longSpeedPerKm = 18.0; // Reasonable long distance speed price for Egypt
|
$longSpeedPerKm = 10.0; // Cheaper for long distance
|
||||||
$longTripPerMin = 0.80; // 80 Piasters for long distance minute price for Egypt
|
$longTripPerMin = 0.40;
|
||||||
} else {
|
} else {
|
||||||
$longSpeedPerKm = 26.0; // Syrian Pound
|
$longSpeedPerKm = 18.0;
|
||||||
$longTripPerMin = 6.0; // Syrian Pound
|
$longTripPerMin = 3.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mediumDistThresholdKm = 25.0;
|
$mediumDistThresholdKm = 25.0;
|
||||||
@@ -246,20 +246,14 @@ function calculateDynamicPrice($country, $minFare, $distance, $duration, $kazanR
|
|||||||
$isLongSpeed = $billableDistance > $longSpeedThresholdKm;
|
$isLongSpeed = $billableDistance > $longSpeedThresholdKm;
|
||||||
|
|
||||||
$perKmSpeedBaseFromServer = getPerKmRate($carType, $kazanRow);
|
$perKmSpeedBaseFromServer = getPerKmRate($carType, $kazanRow);
|
||||||
$perKmSpeed = $isLongSpeed ? $longSpeedPerKm : $perKmSpeedBaseFromServer;
|
$perKmSpeed = $perKmSpeedBaseFromServer;
|
||||||
|
|
||||||
$reductionPct40 = 0.0;
|
if ($billableDistance > $longSpeedThresholdKm) { // > 40km
|
||||||
if ($perKmSpeedBaseFromServer > 0) {
|
$perKmSpeed = $longSpeedPerKm;
|
||||||
$r = 1.0 - ($longSpeedPerKm / $perKmSpeedBaseFromServer);
|
} else if ($billableDistance > $mediumDistThresholdKm) { // 25km to 40km
|
||||||
$reductionPct40 = max(0.0, min($maxReductionCap, $r));
|
// Interpolate smoothly between base rate and long distance rate
|
||||||
}
|
$progress = ($billableDistance - $mediumDistThresholdKm) / ($longSpeedThresholdKm - $mediumDistThresholdKm);
|
||||||
$reductionPct100 = max(0.0, min($maxReductionCap, $reductionPct40 + $extraReduction100));
|
$perKmSpeed = $perKmSpeedBaseFromServer - ($progress * ($perKmSpeedBaseFromServer - $longSpeedPerKm));
|
||||||
|
|
||||||
$distanceReduction = 0.0;
|
|
||||||
if ($billableDistance > 100.0) {
|
|
||||||
$distanceReduction = $reductionPct100;
|
|
||||||
} else if ($billableDistance > 40.0) {
|
|
||||||
$distanceReduction = $reductionPct40;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
date_default_timezone_set('Asia/Damascus');
|
date_default_timezone_set('Asia/Damascus');
|
||||||
@@ -379,7 +373,12 @@ function calculateDynamicPrice($country, $minFare, $distance, $duration, $kazanR
|
|||||||
$compDist = (float)$row['distance_km'];
|
$compDist = (float)$row['distance_km'];
|
||||||
$compPrice = (float)$row['total_price'];
|
$compPrice = (float)$row['total_price'];
|
||||||
if ($compDist > 0) {
|
if ($compDist > 0) {
|
||||||
$normalizedPrices[] = ($compPrice / $compDist) * $distance;
|
// Only trust competitor trips that are somewhat close in distance scale (within 35%)
|
||||||
|
// Otherwise, extrapolating a 3km traffic-heavy trip to 40km highway trip creates nonsense pricing
|
||||||
|
$ratio = $distance / $compDist;
|
||||||
|
if ($ratio >= 0.65 && $ratio <= 1.35) {
|
||||||
|
$normalizedPrices[] = ($compPrice / $compDist) * $distance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($normalizedPrices)) {
|
if (!empty($normalizedPrices)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user