Browse Source

活动行事历优化3

master
wanghongjun 3 weeks ago
parent
commit
75dd72bc33
  1. 12
      app/Services/EventCalendarService.php

12
app/Services/EventCalendarService.php

@ -105,6 +105,10 @@ class EventCalendarService extends BaseService
{ {
try { try {
DB::beginTransaction(); DB::beginTransaction();
if (isset($data['status']) && $data['status'] == 0
&& isset($data['start_time'])
) {
$start_time = $data['start_time'];
$existsWhere = [ $existsWhere = [
['pattern_id', '=', $data['pattern_id']], ['pattern_id', '=', $data['pattern_id']],
['id', '<>', $id] ['id', '<>', $id]
@ -112,12 +116,18 @@ class EventCalendarService extends BaseService
if (EventCalendar::query()->where($existsWhere)->whereIn( if (EventCalendar::query()->where($existsWhere)->whereIn(
'status', 'status',
[0, 1] [0, 1]
)->exists() )
->where(function ($query) use ($start_time) {
$query->whereRaw(
"'{$start_time}' BETWEEN start_time AND end_time"
);
})->exists()
) { ) {
throw new Exception( throw new Exception(
__('service.event_calendar.pattern_exists') __('service.event_calendar.pattern_exists')
); );
} }
}
$model = EventCalendar::query()->findOrFail($id); $model = EventCalendar::query()->findOrFail($id);
$oldValues = $model->toArray(); $oldValues = $model->toArray();

Loading…
Cancel
Save