优化(账号分配): 增加换绑与CK分类及测试操作
This commit is contained in:
@@ -34,6 +34,8 @@ export const accountApi = {
|
||||
include_sensitive?: boolean;
|
||||
status?: string;
|
||||
ck_status?: string;
|
||||
ck_expiry_status?: string;
|
||||
bind_change_status?: string;
|
||||
failure_kind?: string;
|
||||
bind_status?: string;
|
||||
high_value_filter?: string;
|
||||
@@ -63,6 +65,8 @@ export const accountApi = {
|
||||
has_cookie?: boolean;
|
||||
status?: string;
|
||||
ck_status?: string;
|
||||
ck_expiry_status?: string;
|
||||
bind_change_status?: string;
|
||||
failure_kind?: string;
|
||||
bind_status?: string;
|
||||
high_value_filter?: string;
|
||||
|
||||
@@ -43,6 +43,8 @@ export interface AccountBulkSelection {
|
||||
has_cookie?: boolean;
|
||||
status?: string;
|
||||
ck_status?: string;
|
||||
ck_expiry_status?: string;
|
||||
bind_change_status?: string;
|
||||
failure_kind?: string;
|
||||
bind_status?: string;
|
||||
high_value_filter?: string;
|
||||
@@ -448,12 +450,20 @@ export interface AccountItem {
|
||||
has_cookie: boolean;
|
||||
ck_check_status: string;
|
||||
ck_checked_at: string | null;
|
||||
ck_expires_at: string | null;
|
||||
ck_expiry_status: string;
|
||||
ck_expiry_label: string;
|
||||
ck_remaining_hours?: number | null;
|
||||
points: number | null;
|
||||
gold_balance: number | null;
|
||||
elite_opened: boolean | null;
|
||||
esports_opened: boolean | null;
|
||||
role_bind_status: BindStatus;
|
||||
role_bind_label: string;
|
||||
can_change_bind: boolean;
|
||||
bind_change_status: string;
|
||||
bind_change_label: string;
|
||||
bind_change_available_at: string | null;
|
||||
esports_bind_status: BindStatus;
|
||||
esports_bind_label: string;
|
||||
xpd_bind_status: BindStatus;
|
||||
@@ -469,7 +479,6 @@ export interface AccountItem {
|
||||
supply_role?: string;
|
||||
quality_score?: number | null;
|
||||
redundancy_class?: string;
|
||||
ck_remaining_hours?: number | null;
|
||||
active_lease_purpose: string;
|
||||
active_lease_expires_at: string | null;
|
||||
in_active_collab: boolean;
|
||||
|
||||
@@ -21,7 +21,9 @@ import {
|
||||
import {
|
||||
CheckCircleOutlined,
|
||||
ClearOutlined,
|
||||
FieldTimeOutlined,
|
||||
ReloadOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
SearchOutlined,
|
||||
SendOutlined,
|
||||
SwapOutlined,
|
||||
@@ -32,6 +34,7 @@ import {
|
||||
|
||||
import {
|
||||
accountApi,
|
||||
douyuApi,
|
||||
type AccountItem,
|
||||
type AssignmentOptions,
|
||||
type AssignmentsSummary,
|
||||
@@ -39,15 +42,23 @@ import {
|
||||
} from '../api/modules';
|
||||
import { getErrorMessage } from '../utils/error';
|
||||
import { message } from '../utils/antdMessage';
|
||||
import { formatTime } from '../utils/time';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const STORAGE_KEY_SELECTED_USER = 'assignments_selected_user_id';
|
||||
|
||||
type PoolPreset = 'free' | 'zero_points' | 'elite_points' | 'high_value' | 'custom';
|
||||
type PoolPreset =
|
||||
| 'rebind_ready'
|
||||
| 'free'
|
||||
| 'zero_points'
|
||||
| 'elite_points'
|
||||
| 'high_value'
|
||||
| 'custom';
|
||||
type AssignmentTab = 'candidate' | 'assigned';
|
||||
|
||||
const POOL_PRESETS: Array<{ value: PoolPreset; label: string }> = [
|
||||
{ value: 'rebind_ready', label: '可换绑 + 有效CK' },
|
||||
{ value: 'free', label: '空闲号' },
|
||||
{ value: 'zero_points', label: '无积分' },
|
||||
{ value: 'elite_points', label: '精英令 + 积分' },
|
||||
@@ -84,6 +95,20 @@ function occupancyLabel(record: AccountItem): string {
|
||||
return '空闲';
|
||||
}
|
||||
|
||||
function bindChangeTone(status: string) {
|
||||
if (status === 'available') return 'green';
|
||||
if (status === 'cooldown') return 'orange';
|
||||
if (status === 'pending') return 'gold';
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function ckExpiryTone(status: string) {
|
||||
if (status === 'valid') return 'green';
|
||||
if (status === 'expiring') return 'gold';
|
||||
if (status === 'expired' || status === 'invalid' || status === 'error') return 'red';
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function highValueTags(record: AccountItem) {
|
||||
const items = [
|
||||
record.high_value?.bairimeng === 'available' ? '白日梦可换' : '',
|
||||
@@ -112,7 +137,7 @@ export default function AssignmentsPage() {
|
||||
const [allTags, setAllTags] = useState<string[]>([]);
|
||||
|
||||
const [activeTab, setActiveTab] = useState<AssignmentTab>('candidate');
|
||||
const [poolPreset, setPoolPreset] = useState<PoolPreset>('free');
|
||||
const [poolPreset, setPoolPreset] = useState<PoolPreset>('rebind_ready');
|
||||
const [occupancy, setOccupancy] = useState('free');
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const [filterTag, setFilterTag] = useState<string | undefined>();
|
||||
@@ -121,6 +146,8 @@ export default function AssignmentsPage() {
|
||||
const [eliteOpened, setEliteOpened] = useState<boolean | undefined>();
|
||||
const [minPoints, setMinPoints] = useState<number | null>(null);
|
||||
const [maxPoints, setMaxPoints] = useState<number | null>(null);
|
||||
const [ckExpiryStatus, setCkExpiryStatus] = useState<string | undefined>('not_expired');
|
||||
const [bindChangeStatus, setBindChangeStatus] = useState<string | undefined>('available');
|
||||
const [dispatchQuantity, setDispatchQuantity] = useState(10);
|
||||
|
||||
const [pagedAccounts, setPagedAccounts] = useState<AccountItem[]>([]);
|
||||
@@ -130,6 +157,8 @@ export default function AssignmentsPage() {
|
||||
const [assigning, setAssigning] = useState(false);
|
||||
const [dispatching, setDispatching] = useState(false);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const [checkingCk, setCheckingCk] = useState(false);
|
||||
const [checkingRebind, setCheckingRebind] = useState(false);
|
||||
const summaryRequestRef = useRef(0);
|
||||
const pagedRequestRef = useRef(0);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
@@ -151,8 +180,12 @@ export default function AssignmentsPage() {
|
||||
elite_opened: eliteOpened,
|
||||
min_points: minPoints ?? undefined,
|
||||
max_points: maxPoints ?? undefined,
|
||||
ck_expiry_status: ckExpiryStatus,
|
||||
bind_change_status: bindChangeStatus,
|
||||
}),
|
||||
[
|
||||
bindChangeStatus,
|
||||
ckExpiryStatus,
|
||||
commodityId,
|
||||
eliteOpened,
|
||||
filterTag,
|
||||
@@ -278,13 +311,24 @@ export default function AssignmentsPage() {
|
||||
const applyPreset = (preset: PoolPreset) => {
|
||||
setPoolPreset(preset);
|
||||
resetPaging();
|
||||
if (preset === 'free') {
|
||||
if (preset === 'rebind_ready') {
|
||||
setOccupancy('free');
|
||||
setCommodityId(undefined);
|
||||
setHighValueFilter(undefined);
|
||||
setEliteOpened(undefined);
|
||||
setMinPoints(null);
|
||||
setMaxPoints(null);
|
||||
setCkExpiryStatus('not_expired');
|
||||
setBindChangeStatus('available');
|
||||
} else if (preset === 'free') {
|
||||
setOccupancy('free');
|
||||
setCommodityId(undefined);
|
||||
setHighValueFilter(undefined);
|
||||
setEliteOpened(undefined);
|
||||
setMinPoints(null);
|
||||
setMaxPoints(null);
|
||||
setCkExpiryStatus(undefined);
|
||||
setBindChangeStatus(undefined);
|
||||
} else if (preset === 'zero_points') {
|
||||
setOccupancy('free');
|
||||
setCommodityId(undefined);
|
||||
@@ -292,6 +336,8 @@ export default function AssignmentsPage() {
|
||||
setEliteOpened(undefined);
|
||||
setMinPoints(0);
|
||||
setMaxPoints(0);
|
||||
setCkExpiryStatus(undefined);
|
||||
setBindChangeStatus(undefined);
|
||||
} else if (preset === 'elite_points') {
|
||||
setOccupancy('free');
|
||||
setCommodityId(undefined);
|
||||
@@ -299,6 +345,8 @@ export default function AssignmentsPage() {
|
||||
setEliteOpened(true);
|
||||
setMinPoints(1);
|
||||
setMaxPoints(null);
|
||||
setCkExpiryStatus(undefined);
|
||||
setBindChangeStatus(undefined);
|
||||
} else if (preset === 'high_value') {
|
||||
setOccupancy('free');
|
||||
setCommodityId(undefined);
|
||||
@@ -306,6 +354,8 @@ export default function AssignmentsPage() {
|
||||
setEliteOpened(undefined);
|
||||
setMinPoints(null);
|
||||
setMaxPoints(null);
|
||||
setCkExpiryStatus(undefined);
|
||||
setBindChangeStatus(undefined);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -402,6 +452,51 @@ export default function AssignmentsPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const testSelectedCk = async () => {
|
||||
if (selectedRowKeys.length === 0) {
|
||||
message.warning('请先勾选账号');
|
||||
return;
|
||||
}
|
||||
setCheckingCk(true);
|
||||
try {
|
||||
const result = await douyuApi.checkAccountsCk(selectedRowKeys);
|
||||
const invalid = result.results.filter((item) => !item.valid).length;
|
||||
if (invalid > 0) {
|
||||
message.warning(`CK 检测完成:${invalid} 个账号失效`);
|
||||
} else {
|
||||
message.success(`CK 检测完成:${result.results.length} 个账号全部有效`);
|
||||
}
|
||||
await loadPagedAccounts(true);
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setCheckingCk(false);
|
||||
}
|
||||
};
|
||||
|
||||
const testSelectedRebind = async () => {
|
||||
if (selectedRowKeys.length === 0) {
|
||||
message.warning('请先勾选账号');
|
||||
return;
|
||||
}
|
||||
setCheckingRebind(true);
|
||||
try {
|
||||
const result = await douyuApi.createTasks({
|
||||
account_ids: selectedRowKeys,
|
||||
task_type: 'query_change_bind_time',
|
||||
handbook_scope: 'elite',
|
||||
concurrency: 3,
|
||||
payload: {},
|
||||
});
|
||||
message.success(`换绑时间查询已提交:${result.count} 个账号`);
|
||||
window.setTimeout(() => void loadPagedAccounts(true), 1800);
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setCheckingRebind(false);
|
||||
}
|
||||
};
|
||||
|
||||
const selectedUserAssignedCount =
|
||||
supportUsers.find((user) => user.id === selectedUser?.id)?.assigned_count
|
||||
?? selectedUser?.assigned_count
|
||||
@@ -435,6 +530,42 @@ export default function AssignmentsPage() {
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '能否换绑',
|
||||
width: 145,
|
||||
render: (_: unknown, record: AccountItem) => (
|
||||
<Space direction="vertical" size={1}>
|
||||
<Tag color={bindChangeTone(record.bind_change_status)}>
|
||||
{record.bind_change_label || '未知'}
|
||||
</Tag>
|
||||
{record.bind_change_status === 'cooldown' && record.bind_change_available_at ? (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{formatTime(record.bind_change_available_at)} 后可换
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'CK 分类',
|
||||
width: 150,
|
||||
render: (_: unknown, record: AccountItem) => (
|
||||
<Space direction="vertical" size={1}>
|
||||
<Tag color={ckExpiryTone(record.ck_expiry_status)}>
|
||||
{record.ck_expiry_label || '未知'}
|
||||
</Tag>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{record.ck_remaining_hours != null
|
||||
? `剩余 ${record.ck_remaining_hours}h`
|
||||
: record.ck_expires_at
|
||||
? `预计 ${formatTime(record.ck_expires_at)}`
|
||||
: record.ck_check_status
|
||||
? `检测 ${record.ck_check_status}`
|
||||
: '尚未检测'}
|
||||
</Text>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '积分 / 鱼翅',
|
||||
width: 150,
|
||||
@@ -735,6 +866,43 @@ export default function AssignmentsPage() {
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="换绑分类"
|
||||
value={bindChangeStatus}
|
||||
onChange={(value) => {
|
||||
setBindChangeStatus(value);
|
||||
markCustom();
|
||||
}}
|
||||
style={{ width: 135 }}
|
||||
options={[
|
||||
{ value: 'available', label: '可换绑' },
|
||||
{ value: 'cooldown', label: '换绑冷却' },
|
||||
{ value: 'unbound', label: '未绑定' },
|
||||
{ value: 'pending', label: '待确认' },
|
||||
]}
|
||||
/>
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="CK 分类"
|
||||
value={ckExpiryStatus}
|
||||
onChange={(value) => {
|
||||
setCkExpiryStatus(value);
|
||||
markCustom();
|
||||
}}
|
||||
style={{ width: 150 }}
|
||||
options={[
|
||||
{ value: 'not_expired', label: 'CK 有效(含临期)' },
|
||||
{ value: 'valid', label: 'CK 有效' },
|
||||
{ value: 'expiring', label: '24 小时内到期' },
|
||||
{ value: 'expired', label: 'CK 已过期' },
|
||||
{ value: 'invalid', label: 'CK 已失效' },
|
||||
{ value: 'error', label: 'CK 检测异常' },
|
||||
{ value: 'untested', label: 'CK 未检测' },
|
||||
{ value: 'missing', label: '无 CK' },
|
||||
{ value: 'unknown', label: '未预测到期' },
|
||||
]}
|
||||
/>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
@@ -851,6 +1019,22 @@ export default function AssignmentsPage() {
|
||||
取消分配选中 {selectedRowKeys.length}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
icon={<SafetyCertificateOutlined />}
|
||||
loading={checkingCk}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
onClick={() => void testSelectedCk()}
|
||||
>
|
||||
检测 CK{selectedRowKeys.length > 0 ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<FieldTimeOutlined />}
|
||||
loading={checkingRebind}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
onClick={() => void testSelectedRebind()}
|
||||
>
|
||||
查询换绑{selectedRowKeys.length > 0 ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
<Text type="secondary">
|
||||
当前筛选共 {totalCount} 个 · 已选 {selectedRowKeys.length} 个
|
||||
</Text>
|
||||
@@ -883,7 +1067,7 @@ export default function AssignmentsPage() {
|
||||
}
|
||||
},
|
||||
}}
|
||||
scroll={{ x: 1180, y: 'calc(100vh - 475px)' }}
|
||||
scroll={{ x: 1490, y: 'calc(100vh - 475px)' }}
|
||||
locale={{ emptyText: '当前候选池没有账号' }}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user