wugg há 2 anos atrás
pai
commit
a5a6bb4526
1 ficheiros alterados com 18 adições e 4 exclusões
  1. 18 4
      app/controller/UserInfo.php

+ 18 - 4
app/controller/UserInfo.php

@@ -5,7 +5,7 @@ namespace app\controller;
 
 use app\BaseController;
 use app\model\Account;use app\model\AccountCompany;use think\App;
-use think\facade\Db;use think\facade\Validate;
+use think\Exception;use think\facade\Db;use think\facade\Validate;
 
 class UserInfo extends BaseController
 {
@@ -356,10 +356,9 @@ class UserInfo extends BaseController
                 ];
                 $user=Db::table("sys_user")->insert($data);
                 if($user!=false){
+                		$acount =new AccountCompany();
 						 if(!empty($post['companyArr'])){
 						 	$company_insert=[];
-							$acount =new AccountCompany();
-
 					         foreach ($post['companyArr'] as $company){
 								$company_insert[]=[
 									"account_id"=>$reuslt,
@@ -373,8 +372,23 @@ class UserInfo extends BaseController
 									"updatetime"=>date("Y-m-d H:i:s"),
 									];
 					         }
-					         $acount->saveAll($company_insert);
+					        $u= $acount->saveAll($company_insert);
+						 }else{
+						 	$company_insert=[
+									"account_id"=>$reuslt,
+									"companyCode"=>'',
+									"companyName"=>'',
+									"company_type"=>'0',
+									"is_main"=>1,
+									"status"=>1,
+									"is_del"=>0,
+									"addtime"=>date("Y-m-d H:i:s"),
+									"updatetime"=>date("Y-m-d H:i:s"),
+									];
+						 	$u= $acount->save($company_insert);
 						 }
+
+						 if($u==false)throw new Exception("账户新建失败");
                         Db::commit();
                         return json_show(0,"账户注册成功");
                 }