|
|
|
@ -5,6 +5,7 @@ namespace App\Imports; |
|
|
|
use App\Models\Parking; |
|
|
|
use App\Models\ParkingChannel; |
|
|
|
use App\Models\ParkingSpaceType; |
|
|
|
use App\Services\AdminTranslationService; |
|
|
|
use App\Services\OperationLogService; |
|
|
|
use App\Services\ParkingWhitelistService; |
|
|
|
use Maatwebsite\Excel\Concerns\ToModel; |
|
|
|
@ -35,7 +36,10 @@ class ParkingWhitelistImport implements ToModel, WithChunkReading |
|
|
|
} |
|
|
|
$parking_id = Parking::getValueId($parking_name); |
|
|
|
if (empty($parking_id)) { |
|
|
|
return; |
|
|
|
$parking_id = AdminTranslationService::getTypeId(3, $parking_name); |
|
|
|
if (!$parking_id) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
$channel_name = $row[3]; |
|
|
|
if (empty($channel_name)) { |
|
|
|
@ -44,7 +48,16 @@ class ParkingWhitelistImport implements ToModel, WithChunkReading |
|
|
|
$channel_arr = explode(',', $channel_name); |
|
|
|
$channelIds = ParkingChannel::query()->whereIn('name', $channel_arr)->pluck('id')->toArray(); |
|
|
|
if (empty($channelIds)) { |
|
|
|
return; |
|
|
|
$channelIds = []; |
|
|
|
foreach ($channel_arr as $channel) { |
|
|
|
$channel_id = AdminTranslationService::getTypeId(5, $channel); |
|
|
|
if ($channel_id) { |
|
|
|
$channelIds[] = $channel_id; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!$channelIds) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
$reason = $row[4]; |
|
|
|
if (empty($reason)) { |
|
|
|
@ -53,7 +66,10 @@ class ParkingWhitelistImport implements ToModel, WithChunkReading |
|
|
|
$type_str = $row[5]; |
|
|
|
$space_type_id = 0; |
|
|
|
if (!empty($type_str)) { |
|
|
|
$space_type_id = ParkingSpaceType::getValueId($type_str); |
|
|
|
$space_type_id = ParkingSpaceType::getValueId($type_str) ?? 0; |
|
|
|
if (!$space_type_id) { |
|
|
|
$space_type_id = AdminTranslationService::getTypeId(1, $type_str) ?? 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$data = [ |
|
|
|
|