setName('createfz') ->setDescription('the createfz command'); } protected function execute(Input $input, Output $output) { $list = Business::where([["status","=",1],["is_del","=",0]])->select(); foreach ($list as $item){ $this->createFz($item); } // 指令输出 $output->writeln('createfz'); } public function createFz($item){ $fz_date = date('Y-m'); $fzInfo = ProductFz::where([['company_code','=',$item['inv_code']],['fz_date','=',$fz_date]])->findOrEmpty(); if($fzInfo->isEmpty()){ $fzInfo = [ "fzCode"=>makeNo("CWFZ"), 'company_code'=>$item['inv_code'], 'company_name'=>$item['company'], 'fz_date'=>$fz_date, 'status'=>0, 'remark'=>'', ]; (new ProductFz)->save($fzInfo); } } }