From aab39aee938e50d503c36b87ede8fa06d773cb6d Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Mon, 21 Dec 2020 17:29:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A2=9E=E5=8A=A0=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=20=E9=A1=BA=E5=BB=B6=E6=BC=94=E7=A4=BA?= =?UTF-8?q?=E7=9B=B4=E6=92=AD=E8=AF=BE=E7=A8=8B=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/RenewLiveCourseDemoTask.php | 65 +++++++++++++++++++ app/Http/Admin/Services/Setting.php | 2 +- scheduler.php | 3 + 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 app/Console/Tasks/RenewLiveCourseDemoTask.php diff --git a/app/Console/Tasks/RenewLiveCourseDemoTask.php b/app/Console/Tasks/RenewLiveCourseDemoTask.php new file mode 100644 index 00000000..18c9d516 --- /dev/null +++ b/app/Console/Tasks/RenewLiveCourseDemoTask.php @@ -0,0 +1,65 @@ +findById(1393); + + $chapters = $courseRepo->findLessons($course->id); + + $chapterRepo = new ChapterRepo(); + + foreach ($chapters as $chapter) { + + $live = $chapterRepo->findChapterLive($chapter->id); + + if ($live->start_time > time()) { + continue; + } + + $startTime = strtotime('+1 month', $live->start_time); + $endTime = strtotime('+1 month', $live->end_time); + + $live->start_time = $startTime; + $live->end_time = $endTime; + + $live->update(); + + $attrs = $chapter->attrs; + + $attrs['start_time'] = $startTime; + $attrs['end_time'] = $endTime; + + $chapter->attrs = $attrs; + + $chapter->update(); + } + + $statService = new CourseStatService(); + + $statService->updateLiveAttrs($course->id); + + $cache = new CourseChapterListCache(); + + $cache->rebuild($course->id); + } + +} diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index e8779d8e..6d2cce3a 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -101,7 +101,7 @@ class Setting extends Service */ if ($items->count() > 0) { foreach ($items as $item) { - $case1 = preg_match('/(id|auth|key|secret|password|pwd)$/', $item->item_key); + $case1 = preg_match('/(id|auth|key|secret|token|password|pwd)$/', $item->item_key); $case2 = $this->dispatcher->getControllerName() == 'setting'; if ($case1 && $case2) { $item->item_value = '***'; diff --git a/scheduler.php b/scheduler.php index f363c2e7..b1175a1b 100644 --- a/scheduler.php +++ b/scheduler.php @@ -52,4 +52,7 @@ $scheduler->php($script, $bin, ['--task' => 'revoke_vip', '--action' => 'main']) $scheduler->php($script, $bin, ['--task' => 'sitemap', '--action' => 'main']) ->daily(4, 3); +$scheduler->php($script, $bin, ['--task' => 'renew_live_course_demo', '--action' => 'main']) + ->daily(4, 7); + $scheduler->run(); \ No newline at end of file