<?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_apply_record')
                ->where('add_time','<=',time())
                ->where('status',1)
                ->limit(150)
                ->pluck('id')
                ->toArray();
            foreach ($taskData as $k=>$v){
                TaskBusiness::TaskRefund($v);
            }


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