7 changed files with 119 additions and 6 deletions
@ -0,0 +1,43 @@ |
|||
<?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'] |
|||
]); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue