From 2b0dea961c0322ec8fb2d0c8cf3da5c98ce06dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Wed, 24 Mar 2021 15:46:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/User.php | 40 +++++++++++++ app/data/service/UserUpgradeService.php | 2 +- app/data/view/user/index.html | 8 ++- app/data/view/user/parent.html | 76 +++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 app/data/view/user/parent.html diff --git a/app/data/controller/User.php b/app/data/controller/User.php index 9ff2ad35c..ed1130072 100644 --- a/app/data/controller/User.php +++ b/app/data/controller/User.php @@ -45,6 +45,46 @@ class User extends Controller UserAdminService::instance()->buildByUid($data, 'pid1', 'from'); } + /** + * 修改用户上传 + * @auth true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function parent() + { + $data = $this->_vali(['pid.default' => '', 'uid.require' => '待操作UID不能为空']); + if ($data['uid'] === $data['pid']) $this->error('推荐人不能是自己'); + if (empty($data['pid'])) { + $map = [['id', '<>', $data['uid']], ['deleted', '=', 0]]; + $query = $this->_query($this->table)->where($map)->equal('status,vip_code'); + $query->like('phone,username|nickname#username')->dateBetween('create_at')->order('id desc')->page(); + } else try { + $user = $this->app->db->name('DataUser')->where(['id' => $data['uid']])->find(); + $parent = $this->app->db->name('DataUser')->where(['id' => $data['pid']])->find(); + if (empty($user)) $this->error('读取用户信息失败!'); + if (empty($parent)) $this->error('推荐人UID不能为空!'); + $this->app->db->transaction(function () use ($data, $user, $parent) { + if (empty($parent['vip_code'])) $this->error('推荐人无推荐资格'); + if (is_numeric(strpos($parent['path'], "-{$data['uid']}-"))) $this->error('推荐人不能绑下属'); + // 组装代理数据 + $path = rtrim($parent['path'] ?: '-', '-') . "-{$parent['id']}-"; + $this->app->db->name('DataUser')->where(['id' => $data['uid']])->update([ + 'pid0' => $parent['id'], 'pid1' => $parent['id'], 'pid2' => $parent['pid1'], + 'path' => $path, 'layer' => substr_count($path, '-'), + ]); + $newPath = rtrim($path, '-') . "-{$user['id']}-"; + $oldPath = rtrim($user['path'], '-') . "-{$user['id']}-"; + $this->app->db->name('DataUser')->whereLike('path', "{$oldPath}%")->ex; + }); + $this->success('修改推荐人成功!'); + } catch (\think\exception\HttpResponseException $exception) { + throw $exception; + } catch (\Exception $exception) { + $this->error($exception->getMessage()); + } + } /** * 重新计算用户余额返利 diff --git a/app/data/service/UserUpgradeService.php b/app/data/service/UserUpgradeService.php index 444a13455..e1e884e08 100644 --- a/app/data/service/UserUpgradeService.php +++ b/app/data/service/UserUpgradeService.php @@ -122,7 +122,7 @@ class UserUpgradeService extends Service if (empty($pid)) return [0, '绑定推荐人不存在']; if ($uid == $pid) return [0, '推荐人不能是自己']; $parant = $this->app->db->name('DataUser')->where(['id' => $pid])->find(); - if (empty($parant['pids']) || empty($parant['vip_code'])) return [0, '推荐人无推荐资格']; + if (empty($parant['vip_code'])) return [0, '推荐人无推荐资格']; if (stripos($parant['path'], "-{$uid}-") !== false) return [0, '不能绑定下属']; // 组装代理数据 $path = rtrim($parant['path'] ?: '-', '-') . "-{$parant['id']}-"; diff --git a/app/data/view/user/index.html b/app/data/view/user/index.html index 62629197c..9f39c5290 100644 --- a/app/data/view/user/index.html +++ b/app/data/view/user/index.html @@ -2,7 +2,7 @@ {block name="button"} - + {/block} @@ -79,12 +79,16 @@ + + 修改上级 + + 余额充值 - 冻结账号 + 冻结账号 diff --git a/app/data/view/user/parent.html b/app/data/view/user/parent.html new file mode 100644 index 000000000..4b55216d6 --- /dev/null +++ b/app/data/view/user/parent.html @@ -0,0 +1,76 @@ +{extend name="../../admin/view/full"} + +{block name="content"} +
+ {include file='user/index_search'} + + {notempty name='list'} + + + + + + + + + {/notempty} + + {foreach $list as $key=>$vo} + + + + + + + {/foreach} + +
用户信息推荐人信息注册时间
+
+
+
+ {notempty name='vo.username'} + 姓名:{$vo.username|default='-'} + {else} + 昵称:{$vo.nickname|default='-'} + {/notempty} + [ VIP{$vo.vip_code} ] {$vo.vip_name} +
+
手机:{$vo.phone|default='-'}
+
+
+ {notempty name='vo.from'} +
+
+ + 永久 + + 临时 + +
+
+
+ {notempty name='vo.from.username'} + 姓名:{$vo.from.username|default='-'} + {else} + 昵称:{$vo.from.nickname|default='-'} + {/notempty} + [ VIP{$vo.from.vip_code} ] {$vo.from.vip_name} +
+
手机:{$vo.from.phone|default='-'}
+
+ {else} +
没有推荐人
+ {/notempty} +
+ 使用状态:{if $vo.status eq 0}已冻结{elseif $vo.status eq 1}已激活{/if}
+ 注册时间:{$vo.create_at|format_datetime} +
+ + + 确认选择 + + +
+ {empty name='list'}没有记录哦{else}{$pagehtml|raw|default=''}{/empty} +
+{/block}