Add seed_kazan.php script for pricing table
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
// backend/bot/seed_kazan.php
|
||||
// Populates the `kazan` table with default pricing for Jordan, Syria, and Egypt if missing
|
||||
|
||||
require_once __DIR__ . '/../core/bootstrap.php';
|
||||
require_once __DIR__ . '/../functions.php';
|
||||
|
||||
try {
|
||||
$con = Database::get('main');
|
||||
echo "Connected to database.\n";
|
||||
} catch (Exception $e) {
|
||||
die("Database connection failed: " . $e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
$defaultPricing = [
|
||||
[
|
||||
'country' => 'Jordan',
|
||||
'currency' => 'JOD',
|
||||
'kazanPercent' => '10',
|
||||
'fuelPrice' => '1.0',
|
||||
'startPrice' => '0.35',
|
||||
'speedPrice' => '0.22',
|
||||
'comfortPrice' => '0.29',
|
||||
'ladyPrice' => '0.25',
|
||||
'electricPrice' => '0.26',
|
||||
'vanPrice' => '0.33',
|
||||
'deliveryPrice' => '0.20',
|
||||
'mishwarVipPrice' => '0.31',
|
||||
'fixedPrice' => '0.22',
|
||||
'awfarPrice' => '0.19',
|
||||
'normalMinPrice' => '0.05',
|
||||
'peakMinPrice' => '0.06',
|
||||
'lateMinPrice' => '0.05',
|
||||
'adminId' => 'system'
|
||||
],
|
||||
[
|
||||
'country' => 'JO',
|
||||
'currency' => 'JOD',
|
||||
'kazanPercent' => '10',
|
||||
'fuelPrice' => '1.0',
|
||||
'startPrice' => '0.35',
|
||||
'speedPrice' => '0.22',
|
||||
'comfortPrice' => '0.29',
|
||||
'ladyPrice' => '0.25',
|
||||
'electricPrice' => '0.26',
|
||||
'vanPrice' => '0.33',
|
||||
'deliveryPrice' => '0.20',
|
||||
'mishwarVipPrice' => '0.31',
|
||||
'fixedPrice' => '0.22',
|
||||
'awfarPrice' => '0.19',
|
||||
'normalMinPrice' => '0.05',
|
||||
'peakMinPrice' => '0.06',
|
||||
'lateMinPrice' => '0.05',
|
||||
'adminId' => 'system'
|
||||
],
|
||||
[
|
||||
'country' => 'Syria',
|
||||
'currency' => 'SYP',
|
||||
'kazanPercent' => '10',
|
||||
'fuelPrice' => '12000',
|
||||
'startPrice' => '1000',
|
||||
'speedPrice' => '500',
|
||||
'comfortPrice' => '650',
|
||||
'ladyPrice' => '550',
|
||||
'electricPrice' => '600',
|
||||
'vanPrice' => '750',
|
||||
'deliveryPrice' => '450',
|
||||
'mishwarVipPrice' => '700',
|
||||
'fixedPrice' => '500',
|
||||
'awfarPrice' => '425',
|
||||
'normalMinPrice' => '100',
|
||||
'peakMinPrice' => '115',
|
||||
'lateMinPrice' => '100',
|
||||
'adminId' => 'system'
|
||||
],
|
||||
[
|
||||
'country' => 'Egypt',
|
||||
'currency' => 'EGP',
|
||||
'kazanPercent' => '10',
|
||||
'fuelPrice' => '15',
|
||||
'startPrice' => '10',
|
||||
'speedPrice' => '3.0',
|
||||
'comfortPrice' => '4.0',
|
||||
'ladyPrice' => '3.3',
|
||||
'electricPrice' => '3.6',
|
||||
'vanPrice' => '4.5',
|
||||
'deliveryPrice' => '2.7',
|
||||
'mishwarVipPrice' => '4.2',
|
||||
'fixedPrice' => '3.0',
|
||||
'awfarPrice' => '2.5',
|
||||
'normalMinPrice' => '0.5',
|
||||
'peakMinPrice' => '0.6',
|
||||
'lateMinPrice' => '0.5',
|
||||
'adminId' => 'system'
|
||||
],
|
||||
[
|
||||
'country' => 'EG',
|
||||
'currency' => 'EGP',
|
||||
'kazanPercent' => '10',
|
||||
'fuelPrice' => '15',
|
||||
'startPrice' => '10',
|
||||
'speedPrice' => '3.0',
|
||||
'comfortPrice' => '4.0',
|
||||
'ladyPrice' => '3.3',
|
||||
'electricPrice' => '3.6',
|
||||
'vanPrice' => '4.5',
|
||||
'deliveryPrice' => '2.7',
|
||||
'mishwarVipPrice' => '4.2',
|
||||
'fixedPrice' => '3.0',
|
||||
'awfarPrice' => '2.5',
|
||||
'normalMinPrice' => '0.5',
|
||||
'peakMinPrice' => '0.6',
|
||||
'lateMinPrice' => '0.5',
|
||||
'adminId' => 'system'
|
||||
]
|
||||
];
|
||||
|
||||
$sqlInsert = "INSERT INTO kazan (
|
||||
country, currency, kazanPercent, fuelPrice, startPrice,
|
||||
speedPrice, comfortPrice, ladyPrice, electricPrice, vanPrice,
|
||||
deliveryPrice, mishwarVipPrice, fixedPrice, awfarPrice,
|
||||
normalMinPrice, peakMinPrice, lateMinPrice, adminId
|
||||
) VALUES (
|
||||
:country, :currency, :kazanPercent, :fuelPrice, :startPrice,
|
||||
:speedPrice, :comfortPrice, :ladyPrice, :electricPrice, :vanPrice,
|
||||
:deliveryPrice, :mishwarVipPrice, :fixedPrice, :awfarPrice,
|
||||
:normalMinPrice, :peakMinPrice, :lateMinPrice, :adminId
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
currency = VALUES(currency),
|
||||
startPrice = VALUES(startPrice),
|
||||
speedPrice = VALUES(speedPrice),
|
||||
comfortPrice = VALUES(comfortPrice),
|
||||
ladyPrice = VALUES(ladyPrice),
|
||||
electricPrice = VALUES(electricPrice),
|
||||
vanPrice = VALUES(vanPrice),
|
||||
deliveryPrice = VALUES(deliveryPrice),
|
||||
mishwarVipPrice = VALUES(mishwarVipPrice),
|
||||
fixedPrice = VALUES(fixedPrice),
|
||||
awfarPrice = VALUES(awfarPrice),
|
||||
normalMinPrice = VALUES(normalMinPrice),
|
||||
peakMinPrice = VALUES(peakMinPrice),
|
||||
lateMinPrice = VALUES(lateMinPrice)";
|
||||
|
||||
$stmt = $con->prepare($sqlInsert);
|
||||
|
||||
foreach ($defaultPricing as $row) {
|
||||
try {
|
||||
$stmt->execute($row);
|
||||
echo "Successfully seeded/updated kazan pricing for: {$row['country']}\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Error seeding kazan for {$row['country']}: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "Kazan seeding completed.\n";
|
||||
Reference in New Issue
Block a user