From 45b10f52ec4fffc33d7614a896b8a54824abb2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Wed, 7 Apr 2021 19:15:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/user/Admin.php | 20 +++++++++++--------- app/data/view/user/admin/index.html | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/data/controller/user/Admin.php b/app/data/controller/user/Admin.php index 5a3272846..f0c530236 100644 --- a/app/data/controller/user/Admin.php +++ b/app/data/controller/user/Admin.php @@ -30,16 +30,18 @@ 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' => '']; + [$ts, $ls] = [[], UserUpgradeService::instance()->levels()]; + $ts['ta'] = ['vip' => '', 'name' => '全部用户', 'count' => 0]; + foreach ($ls as $k => $v) $ts["t{$k}"] = ['vip' => $k, 'name' => $v['name'], 'count' => 0,]; + $ts['to'] = ['vip' => '', 'name' => '其他用户', 'count' => 0]; + // 等级分组统计 foreach ($this->app->db->name($this->table)->field('vip_code vip,count(1) count')->group('vip_code')->cursor() as $v) { - [$name, $count] = ["t{$v['vip']}", $v['count'], $totals['ta']['count'] += $v['count']]; - isset($totals[$name]) ? $totals[$name]['count'] += $count : $totals['to']['count'] += $count; + [$name, $count] = ["t{$v['vip']}", $v['count'], $ts['ta']['count'] += $v['count']]; + isset($ts[$name]) ? $ts[$name]['count'] += $count : $ts['to']['count'] += $count; } - if (empty($totals['to']['count'])) unset($totals['to']); - $this->total = $totals; + if (empty($ts['to']['count'])) unset($ts['to']); + $this->total = $ts; + // 设置页面标题 $this->title = '普通用户管理'; // 创建查询对象 @@ -47,7 +49,7 @@ class Admin extends Controller // 数据筛选选项 $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)); + elseif ($this->type === 'o') $query->whereNotIn('vip_code', array_keys($ls)); // 用户搜索查询 $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()}"); diff --git a/app/data/view/user/admin/index.html b/app/data/view/user/admin/index.html index a966751ee..9ac272a25 100644 --- a/app/data/view/user/admin/index.html +++ b/app/data/view/user/admin/index.html @@ -11,12 +11,12 @@