From cfca94b33a8371bfe50936c9354b54f244966afb Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Fri, 10 Jul 2026 15:41:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD=E8=B6=85?= =?UTF-8?q?=E8=BF=87=E6=97=B6=E9=97=B4=E7=9A=84=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/AutomaticallyStartActivity.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/Console/Commands/AutomaticallyStartActivity.php b/app/Console/Commands/AutomaticallyStartActivity.php index b9b6d20..ccc9b4e 100644 --- a/app/Console/Commands/AutomaticallyStartActivity.php +++ b/app/Console/Commands/AutomaticallyStartActivity.php @@ -45,6 +45,7 @@ class AutomaticallyStartActivity extends Command { $now_times = time(); $now_time = date("Y-m-d H:i:s", $now_times); + $this->endActivity($now_time); // 结束活动,调整为默认模式 $where = [ ['status', '=', 1] @@ -104,4 +105,37 @@ class AutomaticallyStartActivity extends Command } } } + + // 超过当前时间的活动全部结束 + protected function endActivity($now_time) + { + $model = EventCalendar::query()->where('end_time', '<=', $now_time) + ->where('status', 0)->select(); + if ($model) { + $oldValue = $model->get()->toArray(); + if (!$oldValue) { + return ; + } + $updated_at = date("Y-m-d H:i:s", time()); + $model->update([ + 'status' => 2, + 'admin_user_id' => $this->user_id, + 'updated_at' => $updated_at + ]); + $newValue = []; + foreach ($oldValue as $value) { + $value['status'] = 2; + $value['admin_user_id'] = $this->user_id; + $value['updated_at'] = $updated_at; + $newValue[] = $value; + } + // 记录日志 + $this->logService->logUpdatedData( + new EventCalendar(), + $oldValue, + 'event_calendar.update', + $newValue + ); + } + } }