daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释 // $this->everyMinute();//每分钟 } /** * 镇农科公司任务结算 * @return mixed */ protected function execute() { Log::info('定时任务结算执行-开始'.date('Y-m-d H:i:s')); //yesterday 昨日未结算的任务计划 $taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','yesterday') ->withJoin(['scheduling'], 'left') ->where('scheduling.company_type', 41) ->where('is_pay',0) ->with(['template_info']) ->select() ->toArray(); foreach($taskSchedulingPlanList as $taskSchedulingPlan){ queue(TownTaskSettlementJob::class, $taskSchedulingPlan); } Log::info('定时任务结算执行-结束'.date('Y-m-d H:i:s')); //...具体的任务执行 } }