=',$this->hour]]; $list = $cgd->with(["originCgd"])->where($where)->select(); $cgdArr=[]; foreach ($list as $item){ echo date('Y-m:d H:i:s')."|".$item->cgdNo."--".$item->mainCode."\r\n"; $unique = md5($item->cgdNo.$item->updatetime); $temp=['order_type'=>2,'uniqkey'=>$unique,'status'=>1,'addtime'=>date('Y-m:d H:i:s')]; if($this->isInCfp($unique)){ $order_type= is_null($item->mainCode)?($item->order_source!=8?1:2):3; $item['inv_cat_info'] = OrderTax::spuCat($item->spuCode,2,$order_type); $item['cat_name'] = json_decode($item->cat_name); $temp['data']= json_encode($item,JSON_UNESCAPED_UNICODE); $cgdArr[]=$temp; } } if(empty($cgdArr)==false) $this->table->insertAll($cgdArr); } protected function configure() { // 指令配置 $this->setName('caixiao') ->setDescription('the caixiao command'); } protected function execute(Input $input, Output $output) { // 指令输出 $key="caixiao_copy"; $rs = Cache::store('redis')->get($key); if ($rs!=0) return true; Cache::store('redis')->set($key,1,180); $this->hour=date('Y-m-d H:i:s',strtotime('-1 hours')); $this->contect= Db::connect('mysql_cxinv'); $this->table =$this->contect->name("caixiao_data"); $this->sale(); $this->cgd(); $output->writeln('caixiao'); } protected function getPay($plat_id=0){ $plat =new Platform(); return $plat->where("id",$plat_id)->value("platform_name",""); } protected function sale(){ $sale=new SaleCaixiao(); $where=[["updatetime",">=",$this->hour]]; $list = $sale->where($where)->cursor(); $qrd=[]; foreach ($list as $item){ $unique = md5($item->orderCode.$item->updatetime); echo date('Y-m:d H:i:s').'|'.$item->orderCode."\r\n"; $temp=["order_type"=>1,"uniqkey"=>$unique,"status"=>1,"addtime"=>date('Y-m:d H:i:s')]; if($this->isInCfp($unique)){ $item['inv_cat_info'] = OrderTax::spuCat($item->good_code,2); $item['cat_name'] = json_decode($item->cat_name); $item['remark'] = Sale::where("orderCode",$item->cxCode==""?$item->orderCode:$item->cxCode)->value("remark",""); $temp["data"]= json_encode($item,JSON_UNESCAPED_UNICODE); $qrd[]=$temp; } } if(empty($qrd)==false) $this->table->insertAll($qrd); } protected function isInCfp($unique){ $ist = $this->contect->name("caixiao_data")->where("uniqkey",$unique)->findOrEmpty(); return empty($ist); } }