Browse Source

Merge commit '6f262d14e0d795fd12a22482af69d6654f183b0f'

# Conflicts:
#	config/type.php
wesmiler 3 years ago
parent
commit
a98d027408

+ 1 - 1
app/admin/logic/ScoreLogLogic.php

@@ -48,7 +48,7 @@ class ScoreLogLogic
         return self::$typeMap;
     }
 
-    public static function scoreLog(mixed $page, mixed $limit, mixed $where, array $sort)
+    public static function scoreLog($page, $limit, $where, $sort)
     {
         $model     = new ScoreLogModel();
         $count     = $model

+ 28 - 26
app/admin/logic/UserLogic.php

@@ -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)

+ 1 - 1
app/admin/logic/WithdrawLogLogic.php

@@ -227,7 +227,7 @@ class WithdrawLogLogic
     private function isShowReturnServiceMoney($id)
     {
         $key = 'WITHDRAWLOGRETURNSERVICEMONEY_' . $id;
-        if (Cache::has($key) && 1 == 2) {
+        if (Cache::has($key)) {
             return Cache::get($key);
         }
 

+ 1 - 1
app/admin/model/dao/MoneyLog.php

@@ -24,7 +24,7 @@ class MoneyLog extends BaseDao
     {
         return Db::table(self::$table)
             ->where([
-                'type'            => 14,
+                'type'            => 12,
                 'state'           => 1,
                 'withdraw_log_id' => $id,
             ])

+ 3 - 3
app/admin/view/user/user/modifymoney.html

@@ -39,11 +39,11 @@
         </div>
 
         <div class="layui-form-item  layui-row layui-col-xs12">
-            <label class="layui-form-label required">变更数量</label>
+            <label class="layui-form-label required">变更金额</label>
             <div class="layui-input-block">
                 <input type="text" name="money" id="money" class="layui-input" lay-verify="required"
-                       lay-reqtext="请输入变更数量"
-                       placeholder="请输入变更数量" value="">
+                       lay-reqtext="请输入变更金额"
+                       placeholder="请输入变更金额" value="">
             </div>
         </div>
 

+ 1 - 1
app/validate/admin/user/user/ModifyMoney.php

@@ -21,7 +21,7 @@ class ModifyMoney extends Validate
         'uid.integer'     => 'UID格式错误',
         'money.require'   => '余额不能为空',
         'money.float'    => '余额格式错误',
-        'money.between'   => '余额变更数量超出范围',
+        'money.between'   => '余额变更金额超出范围',
         'state.require'   => '变动类型不能为空',
         'state.integer'   => '变动类型格式错误',
         'type.require'    => '余额类型不能为空',

+ 1 - 1
config/type.php

@@ -24,7 +24,7 @@ return [
         3=>'预约福袋空盒退回',
         4=>'奖金流失',
         5=>'直推收益到奖金',
-        6=>'今日奖金领取',
+        6=>'奖金领取',
         7=>'团队收益到奖金',
         8=>'利润结算',
         9=>'提现',

+ 3 - 3
public/static/admin/js/user/user.js

@@ -98,9 +98,9 @@ define(["jquery", "easy-admin"], function ($, ea) {
                             if (ea.checkAuth('lookpidlevel', init.table_elem)) {
                                 button += '<button class="layui-btn layui-btn-xs layui-btn-normal" data-open="user.user/lookpidlevel?id=' + d.id + '" data-title="查看上级">上级</button>';
                             }
-                            if (ea.checkAuth('modifypid', init.table_elem)) {
-                                button += '<button class="layui-btn layui-btn-xs layui-btn-normal" data-open="user.user/modifypid?id=' + d.id + '" data-title="修改上级">修改上级</button>';
-                            }
+                            // if (ea.checkAuth('modifypid', init.table_elem)) {
+                            //     button += '<button class="layui-btn layui-btn-xs layui-btn-normal" data-open="user.user/modifypid?id=' + d.id + '" data-title="修改上级">修改上级</button>';
+                            // }
                             if (ea.checkAuth('modifyscore', init.table_elem)) {
                                 button += '<button class="layui-btn layui-btn-xs layui-btn-normal" data-open="user.user/modifyscore?id=' + d.id + '" data-title="修改积分">修改积分</button>';
                             }