deploy: auto commit repo-root changes 2026-06-13 12:42:06
This commit is contained in:
@@ -17,6 +17,7 @@ use app\adminapi\lists\BaseAdminDataLists;
|
|||||||
use app\common\enum\user\UserTerminalEnum;
|
use app\common\enum\user\UserTerminalEnum;
|
||||||
use app\common\lists\ListsExcelInterface;
|
use app\common\lists\ListsExcelInterface;
|
||||||
use app\common\model\user\User;
|
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
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
$allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end'];
|
$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);
|
return array_intersect(array_keys($this->params), $allowSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,13 +56,15 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$field = "id,sn,nickname,sex,avatar,account,mobile,channel,user_money,user_points,create_time";
|
$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)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->field($field)
|
->field($field)
|
||||||
->order('id desc')
|
->order('id desc')
|
||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
|
|
||||||
foreach ($lists as &$item) {
|
foreach ($lists as &$item) {
|
||||||
|
$accountType = UserAccountTypeService::resolveType($item);
|
||||||
|
$item = array_merge($item, $accountType);
|
||||||
$item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
|
$item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +80,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
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' => '用户昵称',
|
'nickname' => '用户昵称',
|
||||||
'account' => '账号',
|
'account' => '账号',
|
||||||
'mobile' => '手机号码',
|
'mobile' => '手机号码',
|
||||||
|
'account_scope_desc' => '账号归属',
|
||||||
|
'account_type_desc' => '账号类型',
|
||||||
'channel' => '注册来源',
|
'channel' => '注册来源',
|
||||||
'create_time' => '注册时间',
|
'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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\service\user;
|
||||||
|
|
||||||
|
use app\common\enum\user\UserTerminalEnum;
|
||||||
|
|
||||||
|
class UserAccountTypeService
|
||||||
|
{
|
||||||
|
public const SCOPE_REGISTERED = 'registered';
|
||||||
|
public const SCOPE_SYSTEM = 'system';
|
||||||
|
|
||||||
|
public const TYPE_REGISTERED = 'registered';
|
||||||
|
public const TYPE_COMMENT = 'comment';
|
||||||
|
public const TYPE_TRUMP = 'trump';
|
||||||
|
public const TYPE_LOTTERY = 'lottery';
|
||||||
|
public const TYPE_SYSTEM = 'system';
|
||||||
|
|
||||||
|
public static function registeredChannels(): array
|
||||||
|
{
|
||||||
|
return UserTerminalEnum::ALL_TERMINAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isRegisteredAccount(array $user): bool
|
||||||
|
{
|
||||||
|
return in_array((int) ($user['channel'] ?? 0), self::registeredChannels(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isSystemAccount(array $user): bool
|
||||||
|
{
|
||||||
|
return !self::isRegisteredAccount($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function resolveType(array $user): array
|
||||||
|
{
|
||||||
|
$account = trim((string) ($user['account'] ?? ''));
|
||||||
|
$lowerAccount = strtolower($account);
|
||||||
|
|
||||||
|
if (self::isRegisteredAccount($user)) {
|
||||||
|
return [
|
||||||
|
'account_scope' => 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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user