浏览代码

优化降级情况

devolp 3 年之前
父节点
当前提交
7839704fb5
共有 2 个文件被更改,包括 15 次插入2 次删除
  1. 4 2
      app/admin/logic/UserLogic.php
  2. 11 0
      app/admin/model/dao/User.php

+ 4 - 2
app/admin/logic/UserLogic.php

@@ -500,7 +500,7 @@ class UserLogic
     {
     {
         $newUserPathArr[] = $pid;
         $newUserPathArr[] = $pid;
 
 
-        $this->updatePidAndPathByPath($prefixPath);
+        $this->updatePidAndPathByPath($id, $prefixPath);
 
 
         $parentUser       = User::getUserById($pid);
         $parentUser       = User::getUserById($pid);
         $newUserPathArr   = explode(',', $parentUser['path']);
         $newUserPathArr   = explode(',', $parentUser['path']);
@@ -537,13 +537,15 @@ class UserLogic
         return [false, null];
         return [false, null];
     }
     }
 
 
-    private function updatePidAndPathByPath($prefixPath)
+    private function updatePidAndPathByPath($uid, $prefixPath)
     {
     {
         $newTopUid = $prefixPath[count($prefixPath) - 1];
         $newTopUid = $prefixPath[count($prefixPath) - 1];
 
 
         // 从阶段处更新,分支出来作为第一层
         // 从阶段处更新,分支出来作为第一层
         User::modifyUserPidAndPath($newTopUid, 0, '');
         User::modifyUserPidAndPath($newTopUid, 0, '');
 
 
+        User::modifyUserPidAndPathByPid($uid, 0, '');
+
         $newUserPathArr = [];
         $newUserPathArr = [];
         return $this->iteraMidifyPathByPid($newUserPathArr, $newTopUid);
         return $this->iteraMidifyPathByPid($newUserPathArr, $newTopUid);
 
 

+ 11 - 0
app/admin/model/dao/User.php

@@ -100,6 +100,17 @@ class User extends BaseDao
         Db::table(self::$table)->whereIn('id', $path)->inc('total_team_withdraw', $apply_money)->update();
         Db::table(self::$table)->whereIn('id', $path)->inc('total_team_withdraw', $apply_money)->update();
     }
     }
 
 
+    public static function modifyUserPidAndPathByPid($uid, int $pid, string $path)
+    {
+        return Db::table(self::$table)
+            ->where(['pid' => $uid])
+            ->update([
+                'pid'         => $pid,
+                'path'        => $path,
+                'update_time' => sr_getcurtime(time())
+            ]);
+    }
+
     public function getUserDetail($id)
     public function getUserDetail($id)
     {
     {
         return $this->model
         return $this->model