|
|
@ -4,6 +4,7 @@ namespace App\Console\Commands; |
|
|
|
|
|
|
|
|
use App\Models\EventCalendar; |
|
|
use App\Models\EventCalendar; |
|
|
use App\Services\AdminNoticeService; |
|
|
use App\Services\AdminNoticeService; |
|
|
|
|
|
use App\Services\EventCalendarService; |
|
|
use App\Services\OperationLogService; |
|
|
use App\Services\OperationLogService; |
|
|
use Illuminate\Console\Command; |
|
|
use Illuminate\Console\Command; |
|
|
use Illuminate\Support\Facades\DB; |
|
|
use Illuminate\Support\Facades\DB; |
|
|
@ -24,11 +25,17 @@ class AutomaticallyStartActivity extends Command |
|
|
|
|
|
|
|
|
protected OperationLogService $logService; |
|
|
protected OperationLogService $logService; |
|
|
|
|
|
|
|
|
|
|
|
protected int $user_id; |
|
|
|
|
|
|
|
|
public function __construct(OperationLogService $log) |
|
|
public function __construct(OperationLogService $log) |
|
|
{ |
|
|
{ |
|
|
parent::__construct(); |
|
|
parent::__construct(); |
|
|
$this->logService = $log; |
|
|
$this->logService = $log; |
|
|
$this->logService->menuTitle = 'event_calendar'; |
|
|
$this->logService->menuTitle = 'event_calendar'; |
|
|
|
|
|
|
|
|
|
|
|
// 默认超级管理员修改 |
|
|
|
|
|
$this->user_id = DB::table('admin_users')->where('username', 'Admin') |
|
|
|
|
|
->value('id'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -69,12 +76,21 @@ class AutomaticallyStartActivity extends Command |
|
|
$res = EventCalendar::query()->where($where)->orderBy('start_time') |
|
|
$res = EventCalendar::query()->where($where)->orderBy('start_time') |
|
|
->first(['id']); |
|
|
->first(['id']); |
|
|
if ($res) { |
|
|
if ($res) { |
|
|
// 新活动运行 直接关闭就活动 |
|
|
// 新活动运行 直接关闭旧活动 |
|
|
$new_id = $res['id']; |
|
|
$new_id = $res['id']; |
|
|
if ($runRes && $runRes['id'] != $new_id) { |
|
|
if ($runRes && $runRes['id'] != $new_id) { |
|
|
$this->updateStatus($run_id, 2); |
|
|
$this->updateStatus($run_id, 2); |
|
|
} |
|
|
} |
|
|
$this->updateStatus($new_id, 1, true); |
|
|
$this->updateStatus($new_id, 1, true); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果不存在新活动模式,撤回默认模式 |
|
|
|
|
|
$pattern_id = EventCalendarService::getTargetModeId(); |
|
|
|
|
|
if ($pattern_id) { |
|
|
|
|
|
// 更新车位类型 |
|
|
|
|
|
(new EventCalendarService($this->logService))->syncUpdateSpaceType($pattern_id); |
|
|
|
|
|
// 记录日志 |
|
|
|
|
|
AdminNoticeService::addChangeModeNotice($pattern_id, $this->user_id); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -92,12 +108,9 @@ class AutomaticallyStartActivity extends Command |
|
|
): void { |
|
|
): void { |
|
|
$model = EventCalendar::query()->findOrFail($id); |
|
|
$model = EventCalendar::query()->findOrFail($id); |
|
|
$oldValue = $model->toArray(); |
|
|
$oldValue = $model->toArray(); |
|
|
// 默认超级管理员修改 |
|
|
|
|
|
$user_id = DB::table('admin_users')->where('username', 'Admin') |
|
|
|
|
|
->value('id'); |
|
|
|
|
|
$model->update([ |
|
|
$model->update([ |
|
|
'status' => $status, |
|
|
'status' => $status, |
|
|
'admin_user_id' => $user_id, |
|
|
'admin_user_id' => $this->user_id, |
|
|
'updated_at' => date("Y-m-d H:i:s", time()) |
|
|
'updated_at' => date("Y-m-d H:i:s", time()) |
|
|
]); |
|
|
]); |
|
|
// 记录日志 |
|
|
// 记录日志 |
|
|
@ -106,10 +119,13 @@ class AutomaticallyStartActivity extends Command |
|
|
$oldValue, |
|
|
$oldValue, |
|
|
'event_calendar.update' |
|
|
'event_calendar.update' |
|
|
); |
|
|
); |
|
|
// 记录警报信息, 切换任务 |
|
|
// 记录警报信息, 切换任务, 同步更新指定模式车位类型 |
|
|
if ($is_notice) { |
|
|
if ($is_notice) { |
|
|
$pattern_id = $oldValue['pattern_id']; |
|
|
$pattern_id = $oldValue['pattern_id']; |
|
|
AdminNoticeService::addChangeModeNotice($pattern_id, $user_id); |
|
|
// 更新车位类型 |
|
|
|
|
|
(new EventCalendarService($this->logService))->syncUpdateSpaceType($pattern_id); |
|
|
|
|
|
// 记录日志 |
|
|
|
|
|
AdminNoticeService::addChangeModeNotice($pattern_id, $this->user_id); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|