setName('copysupplier') ->setDescription('the copysupplier command'); } protected function execute(Input $input, Output $output) { $supplier= Cache::store("redis")->handler()->rpop("companycopy"); if($supplier==false) return; $output->writeln($supplier); $supplier =json_decode($supplier,true); if($supplier['type']==1){ $this->checkcompany($supplier); } if($supplier['type']==2){ $this->checkcustomer($supplier); } if($supplier['type']==3){ $this->checkSupplier($supplier); } } private function checkcompany($supplier){ $comp= Db::name("company_info")->where(["companyNo"=>$supplier["companyNo"],"is_del"=>0])->findOrEmpty(); if(empty($comp)){ $data = [ "companyNo"=>$supplier['companyNo'], "company_name"=>$supplier['company'], "company_address"=>$supplier['inv_addr'], "company_license"=>$supplier['inv_code'], "bank_name"=>$supplier['inv_bank'], "bankNo"=>$supplier['inv_bankNo'], "contector"=>$supplier['contactor'], "mobile"=>$supplier['mobile']??$supplier['invoice_mobile'], "company_img"=>$supplier['license_img'], "input_ticket"=>0, "out_ticket"=>0, "voider"=>'', "payee"=>'', "drawer"=>'', "reviewer"=>'', "ownerPlace"=>'', "denomination"=>'', "invoiceType"=>"", 'invoice_title'=>$supplier['invoice_title'], "status"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; }else{ $datas = [ // "companyNo"=>$supplier['companyNo'], 'company_name'=>$supplier['company']??$comp['company_name'], 'company_address'=>$supplier['inv_addr'], 'company_license'=>$supplier['inv_code']??$comp['company_license'], 'bank_name'=>$supplier['inv_bank'], 'bankNo'=>$supplier['inv_bankNo'], 'contector'=>$supplier['contactor']??$comp['contector'], 'mobile'=>$supplier['invoice_mobile'], 'company_img'=>$supplier['license_img']??$comp['company_img'], 'invoice_title'=>$supplier['invoice_title'], 'updatetime'=>date('Y-m-d H:i:s') ]; $data=array_merge($comp,$datas); } Db::name("company_info")->save($data); } private function checkcustomer($supplier){ $comp= Db::name("customer_info")->where(["companyNo"=>$supplier["companyNo"],"is_del"=>0])->findOrEmpty(); if(empty($comp)){ $data = [ "companyNo"=>$supplier['companyNo'], "companyName"=>$supplier['companyName'], "creater"=>$supplier['creater'], "area"=>$supplier['area'], "status"=>1, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; }else{ $datas = [ "companyNo"=>$supplier['companyNo'], "companyName"=>$supplier['companyName'], "is_del"=>$supplier['is_del'], "updatetime"=>date("Y-m-d H:i:s") ]; $data=array_merge($comp,$datas); } Db::name("customer_info")->save($data); } private function checkSupplier($supplier){ $comp= Db::name("supplier_info")->where(["code"=>$supplier["code"]])->findOrEmpty(); if(empty($comp)){ $data= [ 'name' => $supplier['name'], 'code' => $supplier['code'], 'source' => $this->_source[$supplier['source']]??$this->_source[0], 'contector' => $supplier['contactor']??"", 'post' => $supplier['position']??"", 'type' => 1, 'nature' => $supplier['nature']??"", 'corporation' => $supplier['legaler']??"", 'registertime' => $supplier['registertime']??"", 'capital' => $supplier['capital']??"", 'supplier_type' => $this->_cat[$supplier['supplier_type']]??"", 'pay_method' => $this->_payway[$supplier['pay_type']], 'paydays' => $supplier['pay_day'], 'mobile' => $supplier['mobile']??"", 'address' => $supplier['addr']??"", 'return_ticket' => $supplier['ticket_type'], 'delivery' => $this->_delaway[$supplier['delivery_way']]??"", 'status' => 1, 'addtime' => $supplier['addtime']??date("Y-m-d H:i:s"), 'updatetime' => $supplier['updatetime']??date("Y-m-d H:i:s"), 'registercode' => $supplier['registercode']??"", 'level' => $this->_level[$supplier['level']]??"", 'product_category' => $supplier['product_category'], 'license_img' => $supplier['license_img'] ]; }else{ $datas = [ 'name' => $supplier['name'], 'source' => $supplier['source'], 'contector' => $supplier['contactor']??"", 'post' => $supplier['position']??"", 'type' => 1, 'nature' => $supplier['nature'], 'corporation' => $supplier['legaler'], 'registertime' => $supplier['registertime'], 'capital' => $supplier['capital']??"", 'supplier_type' => $this->_cat[$supplier['supplier_type']]??"", 'pay_method' => $supplier['pay_type'], 'paydays' => $supplier['pay_day']??"0", 'mobile' => $supplier['mobile']??"", 'address' => $supplier['addr'], 'return_ticket' => $supplier['ticket_type'], 'delivery' => $this->_delaway[$supplier['delivery_way']]??"", 'status' => 1, 'addtime' => $supplier['addtime'], 'updatetime' => $supplier['updatetime'], 'registercode' => $supplier['registercode'], 'level' => $this->_level[$supplier['level']]??"", 'product_category' => $supplier['product_category'], ]; $data=array_merge($comp,$datas); } Db::name("supplier_info")->save($data); } }