Ver Fonte

供应商升级优化,新增账号加事务控制

wufeng há 2 anos atrás
pai
commit
09fb275142
2 ficheiros alterados com 11 adições e 1 exclusões
  1. 5 0
      app/controller/Headquarters.php
  2. 6 1
      app/controller/UserInfo.php

+ 5 - 0
app/controller/Headquarters.php

@@ -806,6 +806,11 @@ class Headquarters extends BaseController
                 ->where(['code' => $post['code'], 'is_upgrade' => 0, 'is_del' => 0])
                 ->update(['is_upgrade' => 1, 'updatetime' => $date]);
 
+            //账号与公司的关联关系
+            Db::name('account_company')
+                ->where(['companyCode' => $post['code'], 'company_type' => 1])
+                ->update(['company_type' => 2]);
+
             Db::commit();
             return json_show(0, '升级成功');
 

+ 6 - 1
app/controller/UserInfo.php

@@ -391,6 +391,8 @@ class UserInfo extends BaseController
             return json_show(1002, "手机号已注册!");
         }
 
+        Db::startTrans();
+
         try {
             $salt = makeSalt();
             $password = sha1("dingding123" . $salt);
@@ -491,6 +493,7 @@ class UserInfo extends BaseController
             ->findOrEmpty();
         if ($tmp) return json_show(1002, "手机号已注册");
 
+        Db::startTrans();
         try {
             $date = date("Y-m-d H:i:s");
             $salt = makeSalt();
@@ -582,6 +585,8 @@ class UserInfo extends BaseController
             ->findOrEmpty();
         if ($tmp) return json_show(1002, "手机号已注册");
 
+        Db::startTrans();
+
         try {
             $date = date("Y-m-d H:i:s");
             $salt = makeSalt();
@@ -649,7 +654,7 @@ class UserInfo extends BaseController
             Db::rollback();
             return json_show(1002, "注册失败");
 
-        } catch (\Exception $e) {
+        } catch (Exception $e) {
             Db::rollback();
             return json_show(1002, "注册失败," . $e->getMessage());
         }