فهرست منبع

供应商升级逻辑修改

wufeng 2 سال پیش
والد
کامیت
3bd0f1e3b2
1فایلهای تغییر یافته به همراه34 افزوده شده و 7 حذف شده
  1. 34 7
      app/controller/Headquarters.php

+ 34 - 7
app/controller/Headquarters.php

@@ -745,7 +745,7 @@ class Headquarters extends BaseController
     //供应商升级成业务公司
     public function supplerUpgrade()
     {
-        $post = $this->request->only(['code', 'inv_bank', 'inv_bankNo', 'inv_addr', 'mobile', 'uid', 'uname','invoice_title'], 'post', 'trim');
+        $post = $this->request->only(['code', 'inv_bank', 'inv_bankNo', 'inv_addr', 'mobile', 'uid', 'uname', 'invoice_title'], 'post', 'trim');
 
         $val = Validate::rule([
             'code|供应商编码' => 'require',
@@ -783,11 +783,11 @@ class Headquarters extends BaseController
 
             $business_code = makeNo('GS');
 
-            //业务公司列表
+            //业务公司列表
             Db::name('business')
                 ->insert([
                     'company' => $res['name'],
-                    'companyNo' =>$business_code,
+                    'companyNo' => $business_code,
                     'inv_code' => $res['registercode'],
                     'company_type' => $res['nature'],
                     'type' => $temp['id'] ?? 0,
@@ -814,16 +814,35 @@ class Headquarters extends BaseController
             Db::name('headquarters')
                 ->where(['code' => $post['code'], 'type' => 3])
                 ->update([
-                    'type' => '1,3',//既是供应商,也是业务公司
+                    'relation_code' => $business_code,
+                    'updater' => $post['uname'],
+                    'updaterid' => $post['uid'],
+                    'updatetime' => $date,
+                ]);
+
+            Db::name('headquarters')
+                ->insert([
+                    'code' => $business_code,
+                    'name' => $res['name'],
+                    'type' => 1,//业务公司
                     'company_type' => $temp['id'] ?? 0,
+                    'invoice_title' => $res['invoice_title'],
+                    'invoice_people' => $res['invoice_people'],
                     'invoice_addr' => $post['inv_addr'],
                     'invoice_mobile' => $post['mobile'],
+                    'invoice_code' => $res['invoice_code'],
                     'invoice_bank' => $post['inv_bank'],
                     'invoice_bankNo' => $post['inv_bankNo'],
+                    'invoice_img' => $res['invoice_img'],
+                    'status' => $res['status'],
+                    'is_del' => $res['is_del'],
+                    'creater' => $post['uname'],
+                    'createrid' => $post['uid'],
+                    'addtime' => $date,
                     'updater' => $post['uname'],
                     'updaterid' => $post['uid'],
                     'updatetime' => $date,
-                    'relation_code'=>$business_code
+                    'relation_code' => $post['code']
                 ]);
 
             //供应商
@@ -833,8 +852,16 @@ class Headquarters extends BaseController
 
             //账号与公司的关联关系
             Db::name('account_company')
-                ->where(['companyCode' => $post['code'], 'company_type' => 1])
-                ->update(['company_type' => 2]);
+                ->insert([
+                    'account_id' => $post['uid'],
+                    'companyCode' => $business_code,
+                    'companyName' => $res['name'],
+                    'company_type' => 2,
+                    'status' => 1,
+                    'is_del' => 0,
+                    'addtime' => $date,
+                    'updatetime' => $date,
+                ]);
 
             Db::commit();
             return json_show(0, '升级成功');