From 127475e539f2f477e741204dcd7a19bc06db860d Mon Sep 17 00:00:00 2001 From: hajimi Date: Sat, 13 Jun 2026 12:42:06 +0800 Subject: [PATCH] deploy: auto commit repo-root changes 2026-06-13 12:42:06 --- server/app/adminapi/lists/user/UserLists.php | 24 ++++++- .../service/user/UserAccountTypeService.php | 70 +++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 server/app/common/service/user/UserAccountTypeService.php diff --git a/server/app/adminapi/lists/user/UserLists.php b/server/app/adminapi/lists/user/UserLists.php index d33ed6a..cd49aa8 100644 --- a/server/app/adminapi/lists/user/UserLists.php +++ b/server/app/adminapi/lists/user/UserLists.php @@ -17,6 +17,7 @@ use app\adminapi\lists\BaseAdminDataLists; use app\common\enum\user\UserTerminalEnum; use app\common\lists\ListsExcelInterface; use app\common\model\user\User; +use app\common\service\user\UserAccountTypeService; /** @@ -36,6 +37,9 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface public function setSearch(): array { $allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end']; + if (($this->params['account_scope'] ?? '') === UserAccountTypeService::SCOPE_SYSTEM) { + $allowSearch = array_diff($allowSearch, ['channel']); + } return array_intersect(array_keys($this->params), $allowSearch); } @@ -52,13 +56,15 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface public function lists(): array { $field = "id,sn,nickname,sex,avatar,account,mobile,channel,user_money,user_points,create_time"; - $lists = User::withSearch($this->setSearch(), $this->params) + $lists = $this->buildQuery() ->limit($this->limitOffset, $this->limitLength) ->field($field) ->order('id desc') ->select()->toArray(); foreach ($lists as &$item) { + $accountType = UserAccountTypeService::resolveType($item); + $item = array_merge($item, $accountType); $item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']); } @@ -74,7 +80,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface */ public function count(): int { - return User::withSearch($this->setSearch(), $this->params)->count(); + return $this->buildQuery()->count(); } @@ -103,9 +109,23 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface 'nickname' => '用户昵称', 'account' => '账号', 'mobile' => '手机号码', + 'account_scope_desc' => '账号归属', + 'account_type_desc' => '账号类型', 'channel' => '注册来源', 'create_time' => '注册时间', ]; } + protected function buildQuery() + { + $query = User::withSearch($this->setSearch(), $this->params); + $accountScope = (string) ($this->params['account_scope'] ?? ''); + if ($accountScope === UserAccountTypeService::SCOPE_REGISTERED) { + $query->whereIn('channel', UserAccountTypeService::registeredChannels()); + } elseif ($accountScope === UserAccountTypeService::SCOPE_SYSTEM) { + $query->whereNotIn('channel', UserAccountTypeService::registeredChannels()); + } + return $query; + } + } diff --git a/server/app/common/service/user/UserAccountTypeService.php b/server/app/common/service/user/UserAccountTypeService.php new file mode 100644 index 0000000..3d41a09 --- /dev/null +++ b/server/app/common/service/user/UserAccountTypeService.php @@ -0,0 +1,70 @@ + self::SCOPE_REGISTERED, + 'account_scope_desc' => '自注册账号', + 'account_type' => self::TYPE_REGISTERED, + 'account_type_desc' => '自注册账号', + 'is_system_account' => 0, + ]; + } + + if (str_starts_with($account, 'ai_comment_')) { + $type = self::TYPE_COMMENT; + $desc = '评论账号'; + } elseif ($account === 'realDonaldTrump' || str_contains($lowerAccount, 'trump') || str_contains($lowerAccount, 'truth')) { + $type = self::TYPE_TRUMP; + $desc = '特朗普特殊账号'; + } elseif (str_contains($lowerAccount, 'lottery')) { + $type = self::TYPE_LOTTERY; + $desc = '彩票账号'; + } else { + $type = self::TYPE_SYSTEM; + $desc = '系统账号'; + } + + return [ + 'account_scope' => self::SCOPE_SYSTEM, + 'account_scope_desc' => '系统账号', + 'account_type' => $type, + 'account_type_desc' => $desc, + 'is_system_account' => 1, + ]; + } +}