Browse Source

优化停车时间

master
wanghongjun 1 month ago
parent
commit
a4ba24963d
  1. 2
      app/Models/ParkingInformation.php
  2. 13
      app/Services/ParkingInformationService.php

2
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)) : '';
}
}

13
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()
]);

Loading…
Cancel
Save