Просмотр исходного кода

用户-新增-根据昵称和账号模糊搜索用户数据

sunxbiao 1 год назад
Родитель
Сommit
314b0cf38d
1 измененных файлов с 26 добавлено и 14 удалено
  1. 26 14
      app/controller/admin/user/User.php

+ 26 - 14
app/controller/admin/user/User.php

@@ -1906,20 +1906,32 @@ class User extends BaseController
1906 1906
         $isExist = Db::name('user_zero_line')
1907 1907
             ->where('team_uid', '=', $team_uid)
1908 1908
             ->find();
1909
-        if ($isExist) {
1910
-            $result = Db::name('user_zero_line')
1911
-                ->where('team_uid', '=', $team_uid)
1912
-                ->update([
1913
-                    'team_name' => $team_name,
1914
-                    'status' => $status
1915
-                ]);
1916
-        } else {
1917
-            $result = Db::name('user_zero_line')
1918
-                ->insert([
1919
-                    'team_uid' => $team_uid,
1920
-                    'team_name' => $team_name,
1921
-                    'status' => $status
1922
-                ]);
1909
+
1910
+        Db::startTrans();
1911
+        try {
1912
+            Db::name('user')
1913
+                ->where('uid', '=', $team_uid)
1914
+                ->where('is_del', '=', 0)
1915
+                ->update(['level_id' => 0]);
1916
+            if ($isExist) {
1917
+                $result = Db::name('user_zero_line')
1918
+                    ->where('team_uid', '=', $team_uid)
1919
+                    ->update([
1920
+                        'team_name' => $team_name,
1921
+                        'status' => $status
1922
+                    ]);
1923
+            } else {
1924
+                $result = Db::name('user_zero_line')
1925
+                    ->insert([
1926
+                        'team_uid' => $team_uid,
1927
+                        'team_name' => $team_name,
1928
+                        'status' => $status
1929
+                    ]);
1930
+            }
1931
+            Db::commit();
1932
+        } catch (\Exception $exception) {
1933
+            Db::rollback();
1934
+            return app('json')->fail('设置失败');
1923 1935
         }
1924 1936
         if ($result) {
1925 1937
             return app('json')->success('设置成功', $result);