1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-25 04:07:17 +08:00
course-tencent-cloud/app/Console/Tasks/RenewLiveCourseDemoTask.php
xiaochong0302 aab39aee93 第三方开放登录增加公众号通知
顺延演示直播课程日期
2020-12-21 17:29:42 +08:00

66 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Console\Tasks;
use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo;
use App\Services\CourseStat as CourseStatService;
class RenewLiveCourseDemoTask extends Task
{
/**
* 25号顺延直播课程日期日期顺延一个月
*/
public function mainAction()
{
$day = date('d');
if ($day != 25) return;
$courseRepo = new CourseRepo();
$course = $courseRepo->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);
}
}