setName('CopyData') ->setDescription('the CopyData command'); } protected function execute(Input $input, Output $output) { $redis = Cache::store('redis'); $iscgd = $redis->get("fhstatus"); if ($iscgd == 0) { $redis->set("fhstatus", 1,1200); } else { return; } $data= $this->GetData(); if(empty($data)){ return; } foreach ($data as $key=>$value){ if($value['cgdNo']!=''){ $cgd = Db::name("cgd_info")->where([['ShortText1618315935182','=',$value['cgdNo']]])->find(); if(empty($cgd)){ continue; } $thnum = Db::table('fh_source')->where([['cgdNo',"=",$value['cgdNo']],['status','=',1]]) ->sum('send'); $cgd['ShortText1618859321070'] = isset($thnum) && $thnum>0 ? ($cgd['Number1618240600907']>$thnum ? 2 : 3) :1; Db::name("cgd_info")->save($cgd); } } $redis->set("fhstatus",0); $output->writeln('CopyData'); } protected function GetData(){ $date = date("Y-m-d H:i:s",strtotime("-3 day")); $list = Db::table('fh_source')->where([['updatetime',">=",$date],['status','=',1]])->select(); return $list; } }