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']));
// 活动开始时间不能在已有活动时间内
$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')
);

Loading…
Cancel
Save