46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?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()
|
|
{
|
|
$this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
|
|
// $this->everyMinute();//每分钟
|
|
}
|
|
/**
|
|
* 小组服务公司任务结算
|
|
* @return mixed
|
|
*/
|
|
protected function execute()
|
|
{
|
|
//yesterday
|
|
// $all=TaskSchedulingPlan::whereDay('end_time','yesterday')
|
|
// ->where('is_pay',0)
|
|
// ->with(['template_info','scheduling'=>function($query){
|
|
// $query->where('company_type', 18);
|
|
// }])
|
|
// ->select()
|
|
// ->toArray();
|
|
$all = TaskSchedulingPlan::whereDay('end_time','yesterday')
|
|
->withJoin(['scheduling'], 'left')
|
|
->where('scheduling.company_type', 18)
|
|
->where('is_pay',0)
|
|
->with(['template_info'])
|
|
->select()
|
|
->toArray();
|
|
foreach($all as $k=>$v){
|
|
queue(TaskInformationJob::class,$v);
|
|
}
|
|
Log::info('定时任务结算执行成功'.date('Y-m-d H:i:s'));
|
|
|
|
//...具体的任务执行
|
|
}
|
|
}
|