diff --git a/app/Console/Commands/AutomaticallyStartActivity.php b/app/Console/Commands/AutomaticallyStartActivity.php index badc80d..423164b 100644 --- a/app/Console/Commands/AutomaticallyStartActivity.php +++ b/app/Console/Commands/AutomaticallyStartActivity.php @@ -69,11 +69,13 @@ class AutomaticallyStartActivity extends Command // 启动 新模式 if ($start) { $where = [ - ['status', '=', 0], - ['start_time', '>=', $now_time], - ['end_time', '<=', $now_time] + ['status', '=', 0] ]; - $res = EventCalendar::query()->where($where)->orderBy('start_time') + $res = EventCalendar::query()->where($where)->where(function ($query) use ($now_time) { + $query->whereRaw( + "'{$now_time}' BETWEEN start_time AND end_time" + ); + })->orderBy('start_time') ->first(['id']); if ($res) { // 新活动运行 直接关闭旧活动