setName('thdata') ->setDescription('the thdata command'); } protected function execute(Input $input, Output $output) { $redis = Cache::store('redis'); $iscgd = $redis->get("thdata"); if($iscgd==0){ $redis->set("thdata",1,1200); }else{ return; } $this->db =Db::connect("mysql2"); $data = $this->getdata(); foreach ($data as $value){ $ist=Db::name("th_source")->where("thNo","=",$value['thNo'])->find(); if($ist){ Db::name("th_source")->where("thNo","=",$value['thNo'])->save($value); }else{ Db::name("th_source")->save($value); } } $redis->set("thdata",0); } protected function getdata(){ $time = date("Y-m-d H:i:s",strtotime("-3 day")); $sql="SELECT `b`.`sequenceNo` AS `thNo`, case `b`.`sequenceStatus` when 'COMPLETED' then 1 when 'PROCESSING' then 2 else 3 end AS `th_status`, `b`.`createdTime` AS `createtime`, `b`.`ShortText1622039439558` AS `th_company`,( SELECT `b_`.`name` FROM `h_org_user` `b_` WHERE ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`creater` )) AS `th_user`, cast( `b`.`Number1615968695370` AS signed ) AS `th_num`, round( `b`.`Number1619615193432`, 2 ) AS `th_qrd_fee`, round( `b`.`Number1619492129873`, 2 ) AS `th_cgd_fee`, if(`b`.`ShortText1615968975747`='是',1,2) AS `is_th`, CONCAT(ifnull(`b`.`ShortText1619614836899`,''),ifnull(`b`.`ShortText1619623237989`,'')) AS `th_remark`, `b`.`ShortText1615969167025` AS `th_post_company`, `b`.`ShortText1615969170779` AS `th_post_code`, ifnull(`b`.`Number1615969017987`,0) AS `th_post_fee`, `b`.`ShortText1615969178999` AS `th_receiver`, `b`.`ShortText1615969187428` AS `th_phone`, `b`.`text1615969189698` AS `th_mobile`, `b`.`ShortText1619623279832` AS `th_addr`, `a`.`sequenceNo` as `th_qrdcpNo`, `a`.`ShortText1617650701648` as `th_qrdNo`, ifnull(`b2`.`ShortText1618315935182`,'') AS `th_cgdNo`, b.modifiedTime as addtime FROM (((`ifi4s_THGL_THJL` `b` LEFT JOIN `il150_querendanchanpin` `a` ON ((`b`.`ShortText1620718909731` = `a`.`sequenceNo` )))) LEFT JOIN `iw48m_CGDJL` `b2` ON (((`a`.`ShortText1617650701648` = `b2`.`ShortText1617866360004` ) AND ( `a`.`ShortText1619146965777` = `b2`.`ShortText1619147112929` )))) WHERE `b`.`modifiedTime`>='{$time}' ORDER BY `b`.`createdTime`"; $data=$this->db->query($sql); echo $sql; return $data; } }