|
@@ -657,7 +657,7 @@ class Headquarters extends BaseController
|
|
|
|
|
|
if (empty($tmp)) Db::name('supplier_contact')->insert(array_merge($param['contact'], ['addtime' => $param['contact']['updatetime']]));
|
|
|
else Db::name('supplier_contact')->where(['id' => $tmp['id'], 'is_del' => 0])->update($param['contact']);
|
|
|
-
|
|
|
+
|
|
|
Db::name('headquarters')
|
|
|
->where(['code' => $param['contact']['code'], 'is_del' => 0])
|
|
|
->update([
|
|
@@ -677,7 +677,7 @@ class Headquarters extends BaseController
|
|
|
'updaterid' => $param['data']['updaterid'],
|
|
|
'updatetime' => date("Y-m-d H:i:s"),
|
|
|
]);
|
|
|
-
|
|
|
+ $this->checkSupplier($param['data']);
|
|
|
Db::commit();
|
|
|
$param['data']['type']=3;
|
|
|
Cache::store("redis")->handler()->lpush("companycopy",json_encode($param['data'],JSON_UNESCAPED_UNICODE));
|
|
@@ -1128,4 +1128,36 @@ class Headquarters extends BaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private function checkSupplier($supplier){
|
|
|
+ $hquest = Db::name("headquarters")->where(["code"=>$supplier["code"],"is_del"=>0])->findOrEmpty();
|
|
|
+ if(empty($hquest)) throw new Exception("未找到供应商关联数据");
|
|
|
+ if($hquest['relation_code']!='' && $hquest['type']==3){
|
|
|
+ $comp = Db::name('headquarters')->where(['code'=>$hquest['relation_code'],'is_del'=>0])->findOrEmpty();
|
|
|
+ if(empty($comp)) throw new Exception('未找到供应商关联业务公司数据');
|
|
|
+ $business = Db::name("business")->where(['companyNo'=>$hquest['relation_code'],'is_del'=>0])->findOrEmpty();
|
|
|
+ if(empty($business)) throw new Exception('未找到供应商关联业务公司数据');
|
|
|
+ $comp['name'] = $supplier['name'];
|
|
|
+ $comp['invoice_title'] = $supplier['name'];
|
|
|
+ $comp['invoice_people'] = $supplier['legaler'];
|
|
|
+ $comp['invoice_addr'] = $supplier['addr'];
|
|
|
+ $comp['invoice_code'] = $supplier['registercode'];
|
|
|
+ $comp['invoice_img'] = $supplier['license_img'];
|
|
|
+ $comp['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $ip = Db::name('headquarters')->save($comp);
|
|
|
+ if($ip==false) throw new Exception('供应商关联业务公司数据更新失败');
|
|
|
+ $business['company'] =$supplier['name'];
|
|
|
+ $business['inv_code'] =$supplier['registercode'];
|
|
|
+ $business['invoice_title'] =$supplier['name'];
|
|
|
+ $business['inv_legaler'] =$supplier['legaler'];
|
|
|
+ $business['inv_time'] =$supplier['registertime'];
|
|
|
+ $business['inv_addr'] =$supplier['addr'];
|
|
|
+ $business['inv_scope'] =$supplier['scope'];
|
|
|
+ $business['license_img'] =$supplier['license_img'];
|
|
|
+ $business['creater'] =$supplier['updater'];
|
|
|
+ $business['createrid'] =$supplier['updaterid'];
|
|
|
+ $business['updatetime'] = date('Y-m-d H:i:s');
|
|
|
+ $bp = Db::name('business')->save($business);
|
|
|
+ if($bp==false) throw new Exception('业务公司数据更新失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|