|
|
@ -105,11 +105,14 @@ class ReservationController |
|
|
public function confirm(Request $request): JsonResponse |
|
|
public function confirm(Request $request): JsonResponse |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
$id = $request->post('id'); |
|
|
$reserve_id = $request->post('id', ''); |
|
|
$exists = ParkingReservation::query()->where( |
|
|
if (empty($reserve_id)) { |
|
|
['id' => $id, 'status' => 0] |
|
|
throw new Exception('数据缺失'); |
|
|
)->exists(); |
|
|
} |
|
|
if (!$exists) { |
|
|
$id = ParkingReservation::query()->where( |
|
|
|
|
|
['reserve_id' => $reserve_id, 'status' => 0] |
|
|
|
|
|
)->value('id'); |
|
|
|
|
|
if (!$id) { |
|
|
throw new Exception('确认失败'); |
|
|
throw new Exception('确认失败'); |
|
|
} |
|
|
} |
|
|
$this->service->confirm($id); |
|
|
$this->service->confirm($id); |
|
|
@ -122,12 +125,15 @@ class ReservationController |
|
|
public function cancel(Request $request): JsonResponse |
|
|
public function cancel(Request $request): JsonResponse |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
$id = $request->post('id'); |
|
|
$reserve_id = $request->post('id', ''); |
|
|
$exists = ParkingReservation::query()->where('id', $id)->whereIn( |
|
|
if (empty($reserve_id)) { |
|
|
|
|
|
throw new Exception('数据缺失'); |
|
|
|
|
|
} |
|
|
|
|
|
$id = ParkingReservation::query()->where('reserve_id', $reserve_id)->whereIn( |
|
|
'status', |
|
|
'status', |
|
|
[0, 1] |
|
|
[0, 1] |
|
|
)->exists(); |
|
|
)->value('id'); |
|
|
if (!$exists) { |
|
|
if (!$id) { |
|
|
throw new Exception('取消失败'); |
|
|
throw new Exception('取消失败'); |
|
|
} |
|
|
} |
|
|
$this->service->cancel($id); |
|
|
$this->service->cancel($id); |
|
|
|