From a4ba24963d27dd5fa7923ecc27a979ef165f9e08 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Thu, 7 May 2026 17:29:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=81=9C=E8=BD=A6=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/ParkingInformation.php | 2 +- app/Services/ParkingInformationService.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Models/ParkingInformation.php b/app/Models/ParkingInformation.php index 061bb32..b878c6d 100644 --- a/app/Models/ParkingInformation.php +++ b/app/Models/ParkingInformation.php @@ -29,6 +29,6 @@ class ParkingInformation extends Model public function getEntryTimeAttribute($value): string { - return get_datetime('datetime', strtotime($value)); + return $value ? get_datetime('datetime', strtotime($value)) : ''; } } diff --git a/app/Services/ParkingInformationService.php b/app/Services/ParkingInformationService.php index c8f014f..dd54138 100644 --- a/app/Services/ParkingInformationService.php +++ b/app/Services/ParkingInformationService.php @@ -49,6 +49,7 @@ class ParkingInformationService extends BaseService $space_id = 0; $floor_region_id = 0; // 通过车位类型查询楼层 区域 车位 + $entry_time = get_datetime(); if ($space_type_id) { $parkingSpaceWhere = [ 'space_type_id' => $space_type_id, @@ -57,7 +58,7 @@ class ParkingInformationService extends BaseService ]; $res = ParkingSpace::query() ->where($parkingSpaceWhere) - ->first(['id', 'floor_id']); + ->first(['id', 'floor_id', 'berthing_time']); if ($res) { $space_id = $res['id']; if ($res['floor_id']) { @@ -66,6 +67,9 @@ class ParkingInformationService extends BaseService $res['floor_id'] )->value('id'); } + if ($res['berthing_time']) { + $entry_time = $res['berthing_time']; + } } } @@ -73,7 +77,7 @@ class ParkingInformationService extends BaseService if ($space_id) { $space = ParkingSpace::query()->where('status', 0) ->where('license_plate_id', 0)->first( - ['id', 'floor_id', 'space_type_id'] + ['id', 'floor_id', 'space_type_id', 'berthing_time'] ); if ($space) { $space_id = $space['id']; @@ -86,6 +90,9 @@ class ParkingInformationService extends BaseService $space['floor_id'] )->value('id'); } + if ($space['berthing_time']) { + $entry_time = $space['berthing_time']; + } } } @@ -118,7 +125,7 @@ class ParkingInformationService extends BaseService 'floor_region_id' => $floor_region_id, 'space_id' => $space_id, 'license_plate_id' => $license_plate_id, - 'entry_time' => get_datetime(), + 'entry_time' => $entry_time, 'space_type_id' => $space_type_id, 'created_at' => get_datetime() ]);