setName('gold') ->setDescription('the gold command'); } protected function execute(Input $input, Output $output) { // 指令输出 $lsu=$this->getData(); foreach ($lsu as $value){ $uqi = Db::name("gold_price")->where(["uiq"=>$value['uiq']])->find(); $value['type']=$value['type'] =="18K" ? 1 :($value['type'] =="24K" ? 2 :3); if($uqi){ // Db::name("gold_price")->where(["uiq"=>$value['uiq']])->save($value); continue; }else{ Db::name("gold_price")->save($value); } echo $value['addtime']; } $output->writeln('gold'); } public function getData(){ $date=date("Y-m-d H:i:s",strtotime("-1 day")); $db = Db::connect("mysql2"); $var=" SELECT id as 'uiq', SUBSTRING(`name`,1,3) AS 'action_name',createdTime AS 'addtime', ShortText1619628038544 AS 'type',ifnull(Number1619628088467,0) AS 'price' FROM iw48m_GXJJ where createdTime>='{$date}' "; $list=$db->query($var); return $list; } }