From 75dd72bc33b613b1be4bfd2c5145cbd9b66725d2 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Wed, 27 May 2026 16:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E8=A1=8C=E4=BA=8B=E5=8E=86?= =?UTF-8?q?=E4=BC=98=E5=8C=963?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/EventCalendarService.php | 32 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/app/Services/EventCalendarService.php b/app/Services/EventCalendarService.php index 9c79c90..5f83b96 100644 --- a/app/Services/EventCalendarService.php +++ b/app/Services/EventCalendarService.php @@ -105,18 +105,28 @@ class EventCalendarService extends BaseService { try { DB::beginTransaction(); - $existsWhere = [ - ['pattern_id', '=', $data['pattern_id']], - ['id', '<>', $id] - ]; - if (EventCalendar::query()->where($existsWhere)->whereIn( - 'status', - [0, 1] - )->exists() + if (isset($data['status']) && $data['status'] == 0 + && isset($data['start_time']) ) { - throw new Exception( - __('service.event_calendar.pattern_exists') - ); + $start_time = $data['start_time']; + $existsWhere = [ + ['pattern_id', '=', $data['pattern_id']], + ['id', '<>', $id] + ]; + if (EventCalendar::query()->where($existsWhere)->whereIn( + 'status', + [0, 1] + ) + ->where(function ($query) use ($start_time) { + $query->whereRaw( + "'{$start_time}' BETWEEN start_time AND end_time" + ); + })->exists() + ) { + throw new Exception( + __('service.event_calendar.pattern_exists') + ); + } } $model = EventCalendar::query()->findOrFail($id); $oldValues = $model->toArray();