diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index 578812654..e41ac8d88 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -61,13 +61,13 @@ class Order extends Auth [$items, $order, $truckType, $allowPayments] = [[], [], -1, null]; $order['uid'] = $this->uuid; $order['order_no'] = CodeExtend::uniqidDate(18, 'N'); - // 推荐人处理 + // 代理处理 $order['puid1'] = input('from', $this->user['pid1']); if ($order['puid1'] == $this->uuid) $order['puid1'] = 0; if ($order['puid1'] > 0) { $map = ['id' => $order['puid1'], 'status' => 1]; $order['puid2'] = $this->app->db->name('DataUser')->where($map)->value('pid2'); - if (is_null($order['puid2'])) $this->error('推荐人异常'); + if (is_null($order['puid2'])) $this->error('代理异常'); } // 订单商品处理 foreach (explode('||', $rules) as $rule) { diff --git a/app/data/controller/shop/Order.php b/app/data/controller/shop/Order.php index 6f05095c6..ac40f12b5 100644 --- a/app/data/controller/shop/Order.php +++ b/app/data/controller/shop/Order.php @@ -65,7 +65,7 @@ class Order extends Controller // 用户搜索查询 $db = $this->_query('DataUser')->like('phone#user_phone,nickname#user_nickname')->db(); if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}"); - // 推荐人搜索查询 + // 代理搜索查询 $db = $this->_query('DataUser')->like('phone#from_phone,nickname#from_nickname')->db(); if ($db->getOptions('where')) $query->whereRaw("puid1 in {$db->field('id')->buildSql()}"); // 列表选项卡 diff --git a/app/data/controller/user/Admin.php b/app/data/controller/user/Admin.php index 14844e4b4..de9647644 100644 --- a/app/data/controller/user/Admin.php +++ b/app/data/controller/user/Admin.php @@ -29,14 +29,30 @@ class Admin extends Controller */ public function index() { + // 用户等级分组 + $levels = UserUpgradeService::instance()->levels(); + $totals = ['ta' => ['name' => '全部用户', 'count' => 0, 'vips' => '']]; + foreach ($levels as $k => $v) $totals["t{$k}"] = ['name' => $v['name'], 'count' => 0, 'vips' => $k]; + $totals['to'] = ['name' => '其他用户', 'count' => 0, 'vips' => '']; + foreach ($this->app->db->name($this->table)->field('vip_code vip,count(1) count')->group('vip_code')->cursor() as $v) { + [$name, $count, $totals['ta']['count']] = ["t{$v['vip']}", $v['count'], $v['count']]; + isset($totals[$name]) ? $totals[$name]['count'] += $count : $totals['to']['count'] += $count; + } + if (empty($totals['to']['count'])) unset($totals['to']); + $this->total = $totals; + // 设置页面标题 $this->title = '普通用户管理'; - $query = $this->_query($this->table); + // 创建查询对象 + $query = $this->_query($this->table)->order('id desc'); + // 数据筛选选项 + $this->type = ltrim(input('type', 'ta'), 't'); + if (is_numeric($this->type)) $query->where(['vip_code' => $this->type]); + elseif ($this->type === 'o') $query->whereNotIn('vip_code', array_keys($levels)); // 用户搜索查询 - $db = $this->_query('DataUser')->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db(); + $db = $this->_query($this->table)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db(); if ($db->getOptions('where')) $query->whereRaw("pid1 in {$db->field('id')->buildSql()}"); // 数据查询分页 - $query->like('phone,username|nickname#username')->equal('status,vip_code'); - $query->order('id desc')->dateBetween('create_at')->page(); + $query->like('phone,username|nickname#username')->equal('status,vip_code')->dateBetween('create_at')->page(); } /** @@ -59,7 +75,7 @@ class Admin extends Controller public function parent() { $data = $this->_vali(['pid.default' => '', 'uid.require' => '待操作UID不能为空']); - if ($data['uid'] === $data['pid']) $this->error('推荐人不能是自己'); + 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'); @@ -68,10 +84,10 @@ class Admin extends Controller $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('读取推荐人数据失败!'); + if (empty($parent)) $this->error('读取代理数据失败!'); $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('推荐人不能绑下属'); + 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([ @@ -92,7 +108,7 @@ class Admin extends Controller // } }); exit; - $this->success('修改推荐人成功!'); + $this->success('修改代理成功!'); } catch (\think\exception\HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { diff --git a/app/data/service/RebateService.php b/app/data/service/RebateService.php index 5de0e8a58..6c69f6a3f 100644 --- a/app/data/service/RebateService.php +++ b/app/data/service/RebateService.php @@ -85,17 +85,17 @@ class RebateService extends Service $map = ['id' => $this->order['uid'], 'deleted' => 0]; $this->user = $this->app->db->name('DataUser')->where($map)->find(); if (empty($this->user)) throw new Exception('用户不存在'); - // 获取直接推荐人数据 + // 获取直接代理数据 if ($this->order['puid1'] > 0) { $map = ['id' => $this->order['puid1']]; $this->from1 = $this->app->db->name('DataUser')->where($map)->find(); - if (empty($this->from1)) throw new Exception('直接推荐人不存在'); + if (empty($this->from1)) throw new Exception('直接代理不存在'); } - // 获取间接推荐人数据 + // 获取间接代理数据 if ($this->order['puid2'] > 0) { $map = ['id' => $this->order['puid2']]; $this->from2 = $this->app->db->name('DataUser')->where($map)->find(); - if (empty($this->from2)) throw new Exception('间接推荐人不存在'); + if (empty($this->from2)) throw new Exception('间接代理不存在'); } // 批量发放配置奖励 foreach (self::PRIZES as $vo) if (method_exists($this, $vo['func'])) { diff --git a/app/data/service/UserUpgradeService.php b/app/data/service/UserUpgradeService.php index 30c129a0e..ee00c7170 100644 --- a/app/data/service/UserUpgradeService.php +++ b/app/data/service/UserUpgradeService.php @@ -36,13 +36,13 @@ class UserUpgradeService extends Service { $user = $this->app->db->name('DataUser')->where(['id' => $uid])->find(); if (empty($user)) return [0, '用户查询失败']; - if (!empty($user['pids'])) return [1, '已绑定推荐人']; + if (!empty($user['pids'])) return [1, '已绑定代理']; // 检查代理用户 if (empty($pid)) $pid = $user['pid0']; - if (empty($pid)) return [0, '绑定推荐人不存在']; - if ($uid == $pid) return [0, '推荐人不能是自己']; + if (empty($pid)) return [0, '绑定代理不存在']; + if ($uid == $pid) return [0, '代理不能是自己']; $parant = $this->app->db->name('DataUser')->where(['id' => $pid])->find(); - if (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/shop/order/index.html b/app/data/view/shop/order/index.html index 69f1b525b..fe0b1baed 100644 --- a/app/data/view/shop/order/index.html +++ b/app/data/view/shop/order/index.html @@ -47,7 +47,7 @@
- - | -用户信息 | -推荐人信息 | -余额统计 | -返利统计 | -团队统计 | -用户状态 | -- | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
- - | -
-
-
-
- {notempty name='vo.username'}
- 用户姓名:{$vo.username|default='-'}
- {else}
- 用户昵称:{$vo.nickname|default='-'}
- {/notempty}
+
+
+ {include file='user/admin/index_search'}
+
|
+