TaskSystem/app/task/TaskSettlementCron.php

33 lines
883 B
PHP
Raw Permalink Normal View History

2023-08-18 16:32:41 +08:00
<?php
namespace app\task;
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\job\TaskInformationJob;
use think\facade\Log;
use yunwuxin\cron\Task;
class TaskSettlementCron extends Task{
public function configure()
{
2023-08-18 18:11:32 +08:00
$this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
2023-08-28 11:13:03 +08:00
// $this->everyMinute();//每分钟
2023-08-18 16:32:41 +08:00
}
/**
* 任务结算
* @return mixed
*/
protected function execute()
{
2023-08-18 17:07:31 +08:00
//yesterday
2023-08-18 16:32:41 +08:00
$all=TaskSchedulingPlan::whereDay('end_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
foreach($all as $k=>$v){
queue(TaskInformationJob::class,$v);
}
2023-08-28 14:45:37 +08:00
Log::info('定时任务结算执行成功'.date('Y-m-d H:i:s'));
2023-08-18 16:32:41 +08:00
//...具体的任务执行
}
}