seed tarif+apifix
parent
92983774fc
commit
1ae185bbc6
|
|
@ -25,20 +25,22 @@ class MobileApiController extends Controller
|
||||||
}
|
}
|
||||||
foreach ($marks as $mark) {
|
foreach ($marks as $mark) {
|
||||||
$brand = UniModel::model('pipi_auto_brands')->find($mark->brand_id);
|
$brand = UniModel::model('pipi_auto_brands')->find($mark->brand_id);
|
||||||
$tariffs = UniModel::model('pipi_auto_tariffs')->where('model_id', $mark->id)->first();
|
$tariffs = UniModel::model('pipi_auto_tariffs')->where('model_id', $mark->id)->get();
|
||||||
if ($mark->name != 'Ввод остатков') {
|
if ($mark->name != 'Ввод остатков') {
|
||||||
$tariffs = [
|
foreach ($tariffs as $tariff) {
|
||||||
'name' => $tariffs?->name,
|
$tariffs_new[$tariff?->day_range_start . '-' . $tariff->day_range_end] = [
|
||||||
'price' => $tariffs?->base_rate,
|
'name' => $tariff?->name,
|
||||||
'min' => $tariffs?->day_range_start,
|
'price' => $tariff?->base_rate,
|
||||||
'max' => $tariffs?->day_range_end,
|
'min' => $tariff?->day_range_start,
|
||||||
];
|
'max' => $tariff?->day_range_end,
|
||||||
|
];
|
||||||
|
}
|
||||||
$data[$mark->name . '-' . $mark->year] = [
|
$data[$mark->name . '-' . $mark->year] = [
|
||||||
'id' => $mark->id,
|
'id' => $mark->id,
|
||||||
'brand' => $brand->name,
|
'brand' => $brand->name,
|
||||||
'mark' => $mark->name,
|
'mark' => $mark->name,
|
||||||
'year' => $mark->year,
|
'year' => $mark->year,
|
||||||
'tariffs' => $tariffs
|
'tariffs' => $tariffs_new
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,33 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
||||||
|
|
||||||
private function seed()
|
private function seed()
|
||||||
{
|
{
|
||||||
$seed = Storage::disk('pipicar_crm')->get('auto_tariffs/seeds/seed.json');
|
$count = UniModel::model('pipi_auto_tariffs')->count();
|
||||||
|
if ($count === 0) {
|
||||||
|
$seed = Storage::disk('pipicar_crm')->get('auto_tariffs/seeds/seed.json');
|
||||||
|
|
||||||
$data = json_decode($seed, true);
|
$data = json_decode($seed, true);
|
||||||
|
foreach ($data as $item) {
|
||||||
|
$models = explode(' ', $item['model']);
|
||||||
|
if (isset($models[1])) {
|
||||||
|
$model = $models[1];
|
||||||
|
if (isset($models[2])) {
|
||||||
|
$model = $models[1] . ' ' . $models[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($item['rental_periods'] as $rental) {
|
||||||
|
UniModel::model('pipi_auto_tariffs')->create([
|
||||||
|
'name' => $item['model'] . '-' . $item['manufacture_year'] . ' ' . $rental['min_days'] . '-' . $rental['max_days'],
|
||||||
|
'type' => 'dynamic',
|
||||||
|
'day_range_start' => $rental['min_days'],
|
||||||
|
'day_range_end' => $rental['max_days'],
|
||||||
|
'base_rate' => $rental['rate_may_oct'],
|
||||||
|
'deposit' => $rental['deposit'],
|
||||||
|
'model_id' => UniModel::model('pipi_brand_models')
|
||||||
|
->where('name', $model)->where('year', $item['manufacture_year'])->first()?->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,75 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"model": "Huyndai Accent",
|
"model": "Huyndai Accent",
|
||||||
"manufacture_year": "2017 - 2019",
|
"manufacture_year": 2017,
|
||||||
|
"rental_periods": [
|
||||||
|
{
|
||||||
|
"min_days": 1,
|
||||||
|
"max_days": 2,
|
||||||
|
"rate_may_oct": 16000,
|
||||||
|
"rate_nov_apr": 15000,
|
||||||
|
"deposit": 30000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 3,
|
||||||
|
"max_days": 5,
|
||||||
|
"rate_may_oct": 15000,
|
||||||
|
"rate_nov_apr": 13000,
|
||||||
|
"deposit": 30000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 6,
|
||||||
|
"max_days": 15,
|
||||||
|
"rate_may_oct": 14000,
|
||||||
|
"rate_nov_apr": 12000,
|
||||||
|
"deposit": 30000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 15,
|
||||||
|
"max_days": 30,
|
||||||
|
"rate_may_oct": 13000,
|
||||||
|
"rate_nov_apr": 10000,
|
||||||
|
"deposit": 30000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "Huyndai Accent",
|
||||||
|
"manufacture_year": 2018,
|
||||||
|
"rental_periods": [
|
||||||
|
{
|
||||||
|
"min_days": 1,
|
||||||
|
"max_days": 2,
|
||||||
|
"rate_may_oct": 16000,
|
||||||
|
"rate_nov_apr": 15000,
|
||||||
|
"deposit": 30000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 3,
|
||||||
|
"max_days": 5,
|
||||||
|
"rate_may_oct": 15000,
|
||||||
|
"rate_nov_apr": 13000,
|
||||||
|
"deposit": 30000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 6,
|
||||||
|
"max_days": 15,
|
||||||
|
"rate_may_oct": 14000,
|
||||||
|
"rate_nov_apr": 12000,
|
||||||
|
"deposit": 30000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 15,
|
||||||
|
"max_days": 30,
|
||||||
|
"rate_may_oct": 13000,
|
||||||
|
"rate_nov_apr": 10000,
|
||||||
|
"deposit": 30000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "Huyndai Accent",
|
||||||
|
"manufacture_year": 2019,
|
||||||
"rental_periods": [
|
"rental_periods": [
|
||||||
{
|
{
|
||||||
"min_days": 1,
|
"min_days": 1,
|
||||||
|
|
@ -273,7 +341,41 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"model": "Huyndai Elantra",
|
"model": "Huyndai Elantra",
|
||||||
"manufacture_year": "2022 - 2023",
|
"manufacture_year": 2022,
|
||||||
|
"rental_periods": [
|
||||||
|
{
|
||||||
|
"min_days": 1,
|
||||||
|
"max_days": 2,
|
||||||
|
"rate_may_oct": 22000,
|
||||||
|
"rate_nov_apr": 21000,
|
||||||
|
"deposit": 50000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 3,
|
||||||
|
"max_days": 5,
|
||||||
|
"rate_may_oct": 20000,
|
||||||
|
"rate_nov_apr": 20000,
|
||||||
|
"deposit": 50000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 6,
|
||||||
|
"max_days": 15,
|
||||||
|
"rate_may_oct": 18000,
|
||||||
|
"rate_nov_apr": 18000,
|
||||||
|
"deposit": 50000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 15,
|
||||||
|
"max_days": 30,
|
||||||
|
"rate_may_oct": 17000,
|
||||||
|
"rate_nov_apr": 17000,
|
||||||
|
"deposit": 50000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "Huyndai Elantra",
|
||||||
|
"manufacture_year": 2023,
|
||||||
"rental_periods": [
|
"rental_periods": [
|
||||||
{
|
{
|
||||||
"min_days": 1,
|
"min_days": 1,
|
||||||
|
|
@ -341,7 +443,41 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"model": "Huyndai Sonata",
|
"model": "Huyndai Sonata",
|
||||||
"manufacture_year": "2022 - 2023",
|
"manufacture_year": 2022,
|
||||||
|
"rental_periods": [
|
||||||
|
{
|
||||||
|
"min_days": 1,
|
||||||
|
"max_days": 2,
|
||||||
|
"rate_may_oct": 30000,
|
||||||
|
"rate_nov_apr": 30000,
|
||||||
|
"deposit": 50000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 3,
|
||||||
|
"max_days": 5,
|
||||||
|
"rate_may_oct": 28000,
|
||||||
|
"rate_nov_apr": 28000,
|
||||||
|
"deposit": 50000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 6,
|
||||||
|
"max_days": 15,
|
||||||
|
"rate_may_oct": 26000,
|
||||||
|
"rate_nov_apr": 26000,
|
||||||
|
"deposit": 50000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 15,
|
||||||
|
"max_days": 30,
|
||||||
|
"rate_may_oct": 24000,
|
||||||
|
"rate_nov_apr": 24000,
|
||||||
|
"deposit": 50000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "Huyndai Sonata",
|
||||||
|
"manufacture_year": 2023,
|
||||||
"rental_periods": [
|
"rental_periods": [
|
||||||
{
|
{
|
||||||
"min_days": 1,
|
"min_days": 1,
|
||||||
|
|
@ -375,7 +511,41 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"model": "Huyndai Tucson",
|
"model": "Huyndai Tucson",
|
||||||
"manufacture_year": "2023 - 2024",
|
"manufacture_year": 2023,
|
||||||
|
"rental_periods": [
|
||||||
|
{
|
||||||
|
"min_days": 1,
|
||||||
|
"max_days": 2,
|
||||||
|
"rate_may_oct": 32000,
|
||||||
|
"rate_nov_apr": 32000,
|
||||||
|
"deposit": 60000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 3,
|
||||||
|
"max_days": 5,
|
||||||
|
"rate_may_oct": 30000,
|
||||||
|
"rate_nov_apr": 30000,
|
||||||
|
"deposit": 60000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 6,
|
||||||
|
"max_days": 15,
|
||||||
|
"rate_may_oct": 27000,
|
||||||
|
"rate_nov_apr": 27000,
|
||||||
|
"deposit": 60000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"min_days": 15,
|
||||||
|
"max_days": 30,
|
||||||
|
"rate_may_oct": 26000,
|
||||||
|
"rate_nov_apr": 25000,
|
||||||
|
"deposit": 60000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "Huyndai Tucson",
|
||||||
|
"manufacture_year": 2024,
|
||||||
"rental_periods": [
|
"rental_periods": [
|
||||||
{
|
{
|
||||||
"min_days": 1,
|
"min_days": 1,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue