|
|
@@ -116,7 +116,7 @@ class UserLogic
|
|
|
$user = User::getUserById($post['id']);
|
|
|
if (empty($user)) return '用户不存在';
|
|
|
|
|
|
- if (empty($post['recycle_count']) || $post['recycle_count'] < 0 || $post['recycle_count'] > 500) {
|
|
|
+ if (empty($post['recycle_count']) || !preg_match("/^[1-9][0-9]*$/", $post['recycle_count']) || $post['recycle_count'] > 500) {
|
|
|
return '回收卡数量格式有误';
|
|
|
}
|
|
|
|
|
|
@@ -281,7 +281,6 @@ class UserLogic
|
|
|
try {
|
|
|
|
|
|
if ($operateType) {
|
|
|
- // 死循环,分支
|
|
|
$result = $this->modifypidByResetTopLevel($user['id'], $user['path'], $pid, $parentUser['path'], $prefixPath);
|
|
|
} else {
|
|
|
// 正常,迭代修改下级
|
|
|
@@ -302,10 +301,6 @@ class UserLogic
|
|
|
|
|
|
// 升级,abcdef,e升级到b后 分为两种情况 1.abef 2.abcd
|
|
|
|
|
|
- // 插入位置的 path 作为新的path
|
|
|
- // 插入位置的 前一位的 作为新的pid
|
|
|
- // 迭代修改父节点的子节点
|
|
|
-
|
|
|
// 降级 abcdef,c降级到e后 分为两种情况 1. ecf 2.abcd
|
|
|
|
|
|
// 插入 abcdef,插入j到b后 分为两种情况 1.abj 2.abcdef
|
|
|
@@ -319,6 +314,10 @@ class UserLogic
|
|
|
*/
|
|
|
public function ModifyMoney($post)
|
|
|
{
|
|
|
+ if (strlen(substr(strrchr($post['money'], "."), 1)) > 4) {
|
|
|
+ return "变更金额格式错误";
|
|
|
+ }
|
|
|
+
|
|
|
$user = User::getUserById($post['uid']);
|
|
|
if (empty($user)) {
|
|
|
return "用户不存在";
|
|
|
@@ -334,7 +333,7 @@ class UserLogic
|
|
|
return "账号余额不足";
|
|
|
}
|
|
|
}
|
|
|
- $afterMoney = round($afterMoney, 2);
|
|
|
+ $afterMoney = round($afterMoney, 4);
|
|
|
|
|
|
$moneyLog = [
|
|
|
'uid' => $post['uid'],
|
|
|
@@ -474,16 +473,14 @@ class UserLogic
|
|
|
|
|
|
private function modifypidByUpdateNextLevel($id, $userPid, $path, $pid, $parentUserPath)
|
|
|
{
|
|
|
- $userPath = explode(',', $path);
|
|
|
- // 上级的节点信息
|
|
|
- User::modifyUserPidAndPath($pid, $userPid, $path);
|
|
|
- $this->iteraMidifyPathByPid($userPath, $pid);
|
|
|
+ $newPath = explode(',', $parentUserPath);
|
|
|
+ $newPath[] = $pid;
|
|
|
+ // 1. 修改$pidUser['pid'] = $idUser['pid'], $pidUser['path'] = $idUser['path']
|
|
|
+ User::modifyUserPidAndPath($id, $pid, implode(',', $newPath));
|
|
|
+
|
|
|
+ // 迭代更新子级path
|
|
|
+ $this->iteraMidifyPathByPid($newPath, $id);
|
|
|
|
|
|
- // 更新被修改的节点信息
|
|
|
- $newUserPathArr = $userPath;
|
|
|
- $newUserPathArr[] = $pid;
|
|
|
- User::modifyUserPidAndPath($id, $pid, implode(',', $newUserPathArr));
|
|
|
- $this->iteraMidifyPathByPid($newUserPathArr, $id);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -506,22 +503,27 @@ class UserLogic
|
|
|
|
|
|
private function modifypidByResetTopLevel($id, $path, $pid, $parentUserPath, $prefixPath)
|
|
|
{
|
|
|
- $newUserPathArr[] = $pid;
|
|
|
+ // 1.迭代更新id所有下级的path,从path = ‘’开始
|
|
|
+ $usersList = Db::table(User::$table)
|
|
|
+ ->where(['pid' => $id])
|
|
|
+ ->field(['id', 'path'])
|
|
|
+ ->select();
|
|
|
+ foreach ($usersList as $user) {
|
|
|
+ $this->iteraMidifyPathByPid([], $user['id']);
|
|
|
+ }
|
|
|
|
|
|
- $this->updatePidAndPathByPath($id, $prefixPath);
|
|
|
+ // 2.修改id的下一级用户的pid =0 ,path = ‘’
|
|
|
+ User::modifyUserPidAndPathByPid($id, 0, '');
|
|
|
|
|
|
- $parentUser = User::getUserById($pid);
|
|
|
- $newUserPathArr = explode(',', $parentUser['path']);
|
|
|
+ // 3. 修改$post['id']的pid = post['pid'],path = pUserPath.',pid'
|
|
|
+ $parentUser = User::getUserById($pid);
|
|
|
+ if (!empty($parentUser['path'])) {
|
|
|
+ $newUserPathArr = explode(',', $parentUser['path']);
|
|
|
+ }
|
|
|
$newUserPathArr[] = $pid;
|
|
|
-
|
|
|
User::modifyUserPidAndPath($id, $pid, implode(',', $newUserPathArr));
|
|
|
|
|
|
- $this->iteraMidifyPathByPid($newUserPathArr, $id);
|
|
|
-
|
|
|
return true;
|
|
|
-// $result = User::modifyUserPidAndPath($pid, 0, '');
|
|
|
-// if (!$result) return false;
|
|
|
-// return User::modifyUserPidAndPath($id, $pid, implode(',', $newUserPathArr));
|
|
|
}
|
|
|
|
|
|
private function isFallLevel($uid, $pid)
|