From bea8bba97aba4e91fd6af2c1b0225b943cf8cd02 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Wed, 8 Jul 2026 16:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=B4=BB=E5=8A=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E8=BD=A6=E4=BD=8D=E5=88=A0=E9=99=A4=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=88=A0=E9=99=A4=E6=A8=A1=E5=BC=8F=E5=85=B3=E8=81=94?= =?UTF-8?q?=E8=BD=A6=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/EventCalendarController.php | 6 +++--- app/Services/EventCalendarService.php | 3 ++- app/Services/ParkingPatternSpaceService.php | 16 ++++++++++++++++ app/Services/ParkingSpaceService.php | 10 +++++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Admin/EventCalendarController.php b/app/Http/Controllers/Admin/EventCalendarController.php index 59ed926..7761d72 100644 --- a/app/Http/Controllers/Admin/EventCalendarController.php +++ b/app/Http/Controllers/Admin/EventCalendarController.php @@ -313,6 +313,7 @@ class EventCalendarController extends BaseController * @param string $id * @return JsonResponse * @throws ValidationException + * @throws CustomException */ public function end(string $id): JsonResponse { @@ -323,12 +324,11 @@ class EventCalendarController extends BaseController null, __('exception.event_calendar.end_succeeded') ); - } catch (ValidationException $e) { + } catch (ValidationException|CustomException $e) { throw $e; } catch (Exception $e) { return $this->responseService->systemError( - __('exception.event_calendar.end_failed') . ':' - . $e->getMessage() + __('exception.event_calendar.end_failed') ); } } diff --git a/app/Services/EventCalendarService.php b/app/Services/EventCalendarService.php index bbba294..0d9b55a 100644 --- a/app/Services/EventCalendarService.php +++ b/app/Services/EventCalendarService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Exceptions\CustomException; use App\Models\EventCalendar; use App\Models\ParkingPattern; use App\Models\ParkingPatternSpace; @@ -191,7 +192,7 @@ class EventCalendarService extends BaseService $model = EventCalendar::query()->findOrFail($id); $oldValues = $model->toArray(); if ($model['status'] != 1) { - throw new Exception(__('service.event_calendar.error_end')); + throw new CustomException(__('service.event_calendar.error_end')); } $update = [ 'status' => 2, diff --git a/app/Services/ParkingPatternSpaceService.php b/app/Services/ParkingPatternSpaceService.php index 5f8cf56..f6db0a8 100644 --- a/app/Services/ParkingPatternSpaceService.php +++ b/app/Services/ParkingPatternSpaceService.php @@ -164,4 +164,20 @@ class ParkingPatternSpaceService extends BaseService } return []; } + + // 车位删除同步删除已添加的绘制地图 + public static function syncDeleteMapSpace($space_id) + { + $id = ParkingPatternSpace::query()->where([ + 'space_id' => $space_id + ])->value('id'); + if ($id) { + $model = ParkingPatternSpace::query()->findOrFail($id); + $model->delete(); + (new OperationLogService())->logDeleted( + $model, + 'parking_pattern_space.delete' + ); + } + } } diff --git a/app/Services/ParkingSpaceService.php b/app/Services/ParkingSpaceService.php index 2a1f82e..b8b7e9b 100644 --- a/app/Services/ParkingSpaceService.php +++ b/app/Services/ParkingSpaceService.php @@ -425,7 +425,10 @@ class ParkingSpaceService extends BaseService return; } } - $model = ParkingSpace::query()->findOrFail($id); + $model = ParkingSpace::query()->find($id); + if (!$model) { + return; + } $oldValues = $model->toArray(); // 相同不更新 if ($oldValues['space_type_id'] == $type_id) { @@ -553,6 +556,9 @@ class ParkingSpaceService extends BaseService $oldValue['floor_id'] ); + // 同步删除模式关联车位 + ParkingPatternSpaceService::syncDeleteMapSpace($id); + DB::commit(); return true; } catch (Exception $e) { @@ -584,6 +590,8 @@ class ParkingSpaceService extends BaseService $id, $oldValue['floor_id'] ); + // 同步删除模式关联车位 + ParkingPatternSpaceService::syncDeleteMapSpace($id); } DB::commit();