|
|
@ -77,57 +77,24 @@ class AutomaticallyStartActivity extends Command |
|
|
); |
|
|
); |
|
|
})->orderBy('start_time') |
|
|
})->orderBy('start_time') |
|
|
->first(['id']); |
|
|
->first(['id']); |
|
|
|
|
|
$EventCalendarService = (new EventCalendarService($this->logService)); |
|
|
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); |
|
|
$EventCalendarService->updateStatus($run_id, $this->user_id, 2); |
|
|
} |
|
|
} |
|
|
$this->updateStatus($new_id, 1, true); |
|
|
$EventCalendarService->updateStatus($new_id, $this->user_id, 1, true); |
|
|
} else { |
|
|
} else { |
|
|
// 如果不存在新活动模式,撤回默认模式 |
|
|
// 如果不存在新活动模式,撤回默认模式 |
|
|
$pattern_id = EventCalendarService::getTargetModeId(); |
|
|
$pattern_id = EventCalendarService::getTargetModeId(); |
|
|
if ($pattern_id) { |
|
|
if ($pattern_id) { |
|
|
// 更新车位类型 |
|
|
// 更新车位类型 |
|
|
(new EventCalendarService($this->logService))->syncUpdateSpaceType($pattern_id); |
|
|
$EventCalendarService->syncUpdateSpaceType($pattern_id); |
|
|
// 记录日志 |
|
|
// 记录日志 |
|
|
AdminNoticeService::addChangeModeNotice($pattern_id, $this->user_id); |
|
|
AdminNoticeService::addChangeModeNotice($pattern_id, $this->user_id); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param $id |
|
|
|
|
|
* @param int $status // 1运行 、 2结束 |
|
|
|
|
|
* @param bool $is_notice |
|
|
|
|
|
* @return void |
|
|
|
|
|
*/ |
|
|
|
|
|
protected function updateStatus( |
|
|
|
|
|
$id, |
|
|
|
|
|
int $status = 1, |
|
|
|
|
|
bool $is_notice = false |
|
|
|
|
|
): void { |
|
|
|
|
|
$model = EventCalendar::query()->findOrFail($id); |
|
|
|
|
|
$oldValue = $model->toArray(); |
|
|
|
|
|
$model->update([ |
|
|
|
|
|
'status' => $status, |
|
|
|
|
|
'admin_user_id' => $this->user_id, |
|
|
|
|
|
'updated_at' => date("Y-m-d H:i:s", time()) |
|
|
|
|
|
]); |
|
|
|
|
|
// 记录日志 |
|
|
|
|
|
$this->logService->logUpdated( |
|
|
|
|
|
$model, |
|
|
|
|
|
$oldValue, |
|
|
|
|
|
'event_calendar.update' |
|
|
|
|
|
); |
|
|
|
|
|
// 记录警报信息, 切换任务, 同步更新指定模式车位类型 |
|
|
|
|
|
if ($is_notice) { |
|
|
|
|
|
$pattern_id = $oldValue['pattern_id']; |
|
|
|
|
|
// 更新车位类型 |
|
|
|
|
|
(new EventCalendarService($this->logService))->syncUpdateSpaceType($pattern_id); |
|
|
|
|
|
// 记录日志 |
|
|
|
|
|
AdminNoticeService::addChangeModeNotice($pattern_id, $this->user_id); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|