setName('queue') ->setDescription('the queue command'); } protected function execute(Input $input, Output $output) { $redis = Cache::store("redis"); $jobHandlerClassName = 'app\Admin\JobInv@fire'; //业务数据 对象需要手 //动转序列化 $invoce_tab = $redis->get("invoce_tab"); if($invoce_tab==0){ $redis->set("invoce_tab",1,1200); }else{ return; } $jobQueueName = "createOrderJob1"; $list=Db::name("invoice_img")->where([["status","=",1],["is_del","=",0],['crontab',"=",0]])->select(); foreach ($list as $key=>$value){ //入队列,later延时发送,单位秒。push立即发送 $isPushed = $redis->handler()->lPush($jobQueueName, json_encode($value)); if( $isPushed !== false ){ Db::name("invoice_img")->where("id","=",$value['id'])->save(['crontab'=>1]); echo "执行成功"; }else{ echo '执行失败'; } } $redis->set("invoce_tab",0); // $this->Jobdo(); $output->writeln('queue'); } }