You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\job\schedule;
|
|
|
|
use app\model\course_schedule\CourseSchedule;
|
|
use core\base\BaseJob;
|
|
use think\facade\Log;
|
|
|
|
/**
|
|
* 队列异步调用定时任务
|
|
*/
|
|
class HandleCourseSchedule extends BaseJob
|
|
{
|
|
public function doJob()
|
|
{
|
|
Log::write('课程状态自动化任务开始' . date('Y-m-d h:i:s'));
|
|
$this->handleCourseStatus();
|
|
return true;
|
|
}
|
|
|
|
private function handleCourseStatus()
|
|
{
|
|
$list = CourseSchedule::where('course_date','<',date('Y-m-d'))->select();
|
|
if (!empty($list)) {
|
|
foreach ($list as $item) {
|
|
CourseSchedule::update([
|
|
'status' => 'completed'
|
|
], [
|
|
'id' => $item['id']
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|