Browse Source

活动行事历优化

master
wanghongjun 3 weeks ago
parent
commit
df7a9644c3
  1. 19
      app/Services/EventCalendarService.php

19
app/Services/EventCalendarService.php

@ -61,14 +61,17 @@ class EventCalendarService extends BaseService
$end_time = get_datetime('datetime', strtotime($data['end_time'])); $end_time = get_datetime('datetime', strtotime($data['end_time']));
// 活动开始时间不能在已有活动时间内 // 活动开始时间不能在已有活动时间内
$where = [ $exists = EventCalendar::query()->whereIn('status', [0, 1])->where(
['pattern_id', '=', $data['pattern_id']], 'pattern_id',
['start_time', '>=', $start_time], $data['pattern_id']
['end_time', '<=', $start_time] )
]; ->where(function ($query) use ($start_time) {
if (EventCalendar::query()->whereIn('status', [0, 1])->where($where) $query->whereRaw(
->exists() "'{$start_time}' BETWEEN start_time AND end_time"
) { );
})
->exists();
if ($exists) {
throw new Exception( throw new Exception(
__('service.event_calendar.pattern_exists') __('service.event_calendar.pattern_exists')
); );

Loading…
Cancel
Save