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 @@
用户信息 | +推荐人信息 | +注册时间 | ++ |
---|---|---|---|
+
+
+
+
+ {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'}
+
+
+
+ 永久
+
+ 临时
+
+
+
+
+ {else}
+
+ {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='-'}
+ 没有推荐人
+ {/notempty}
+ |
+
+ 使用状态:{if $vo.status eq 0}已冻结{elseif $vo.status eq 1}已激活{/if} + 注册时间:{$vo.create_at|format_datetime} + |
+ + + + 确认选择 + + + | +