From df7a9644c3cb963055d6e85e93adc9c57edef5bf Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Wed, 27 May 2026 15:35:08 +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=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/EventCalendarService.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/Services/EventCalendarService.php b/app/Services/EventCalendarService.php index 06461db..9c79c90 100644 --- a/app/Services/EventCalendarService.php +++ b/app/Services/EventCalendarService.php @@ -61,14 +61,17 @@ class EventCalendarService extends BaseService $end_time = get_datetime('datetime', strtotime($data['end_time'])); // 活动开始时间不能在已有活动时间内 - $where = [ - ['pattern_id', '=', $data['pattern_id']], - ['start_time', '>=', $start_time], - ['end_time', '<=', $start_time] - ]; - if (EventCalendar::query()->whereIn('status', [0, 1])->where($where) - ->exists() - ) { + $exists = EventCalendar::query()->whereIn('status', [0, 1])->where( + 'pattern_id', + $data['pattern_id'] + ) + ->where(function ($query) use ($start_time) { + $query->whereRaw( + "'{$start_time}' BETWEEN start_time AND end_time" + ); + }) + ->exists(); + if ($exists) { throw new Exception( __('service.event_calendar.pattern_exists') );