123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\input\Option;
- use think\console\Output;
- use think\facade\Cache;
- use think\facade\Db;
- class CopySupplier extends Command
- {
- private $_delaway=["供应商发货","公司自提"];
- private $_applyway=["正式供应商","临时供应商"];
- private $_source=["客户提供","供应商","公司开发"];
- private $_cat=["生产厂家","代理商","经销商","分销商","电商平台"];
- private $_level=["生产厂家","一级代理","二级代理"];
- private $_payway=["现结","月清","双月请"];
- private $_catpay=["个人独私企业","合伙企业","有限责任公司","供应商","股份有限责任公司","有限责任公司(自然人独资)","有限责任公司(自然人独资或控股)","村级集体经济组织","股份有限公司"];
- protected function configure()
- {
- // 指令配置
- $this->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);
- }
- }
|