<?php
namespace process;


use app\business\TaskBusiness;
use support\Db;
use support\Log;
use Workerman\Timer;

/** 重启任务 */
class TaskRestart
{
    public function onWorkerStart()
    {
        Timer::add(20, function(){
            $this->task();
        });

    }
    public function task()
    {
        try {
            $taskData=Db::table('wa_cron_task_four')
                ->where('day_dividend_time','<=',time())
                ->where('is_finish',1)
                ->limit(600)
                ->pluck('id')
                ->toArray();
            foreach ($taskData as $k=>$v){
                TaskBusiness::TaskRefund($v);
            }


        }catch (\Throwable $exception){
            Log::channel('task')->error($exception->getMessage());
        }
    }
}
