1010 lines
32 KiB
TypeScript
1010 lines
32 KiB
TypeScript
import { useCallback, useEffect, useState } from 'react';
|
||
import {
|
||
Alert,
|
||
Button,
|
||
Descriptions,
|
||
Drawer,
|
||
Form,
|
||
Input,
|
||
InputNumber,
|
||
Modal,
|
||
Popconfirm,
|
||
QRCode,
|
||
Select,
|
||
Space,
|
||
Spin,
|
||
Table,
|
||
Tabs,
|
||
Tag,
|
||
Tooltip,
|
||
Typography,
|
||
theme,
|
||
} from 'antd';
|
||
import type { TableProps } from 'antd';
|
||
import {
|
||
DeleteOutlined,
|
||
AppstoreOutlined,
|
||
ImportOutlined,
|
||
QrcodeOutlined,
|
||
ReloadOutlined,
|
||
SearchOutlined,
|
||
} from '@ant-design/icons';
|
||
import {
|
||
weiboApi,
|
||
type PaginatedResponse,
|
||
type WeiboAccountItem,
|
||
type WeiboBindQrResult,
|
||
type WeiboExchangeRecordsResult,
|
||
type WeiboImportError,
|
||
type WeiboMallListResult,
|
||
type WeiboPaymentStatusResult,
|
||
type WeiboPointHistoryResult,
|
||
type WeiboRechargeOrderResult,
|
||
} from '../api/modules';
|
||
import { usePermissions } from '../hooks/usePermissions';
|
||
import { formatTime } from '../utils/time';
|
||
import { getErrorMessage } from '../utils/error';
|
||
import { message } from '../utils/antdMessage';
|
||
|
||
const { Text, Title } = Typography;
|
||
const { TextArea } = Input;
|
||
|
||
const CK_STATUS: Record<string, { label: string; color: string }> = {
|
||
valid: { label: '有效', color: 'success' },
|
||
invalid: { label: '失效', color: 'error' },
|
||
error: { label: '查询失败', color: 'warning' },
|
||
};
|
||
|
||
const PAYMENT_STATUS_LABELS: Record<string, string> = {
|
||
PAY_STATUS_PENDING: '等待支付',
|
||
PAY_STATUS_SUCCESS: '支付成功',
|
||
PAY_STATUS_FAILED: '支付失败',
|
||
PAY_STATUS_CLOSED: '订单关闭',
|
||
};
|
||
|
||
function bindStatus(account: WeiboAccountItem) {
|
||
if (account.is_bound === true && account.can_rebind === true) {
|
||
return <Tag color="processing">可换绑</Tag>;
|
||
}
|
||
if (account.is_bound === true) {
|
||
const days = account.rebind_remain_days ?? 0;
|
||
return <Tag color="success">{days > 0 ? `${days} 天后可换绑` : '已绑定'}</Tag>;
|
||
}
|
||
if (account.is_bound === false) return <Tag color="warning">未绑定</Tag>;
|
||
return <Tag>未查询</Tag>;
|
||
}
|
||
|
||
export default function WeiboAccountsPage() {
|
||
const { token } = theme.useToken();
|
||
const { can } = usePermissions();
|
||
const canImport = can('weibo:import');
|
||
const canBind = can('weibo:bind');
|
||
const canRecharge = can('weibo:recharge');
|
||
const canExchange = can('weibo:exchange');
|
||
const canDelete = can('weibo:delete');
|
||
|
||
const [items, setItems] = useState<WeiboAccountItem[]>([]);
|
||
const [total, setTotal] = useState(0);
|
||
const [page, setPage] = useState(1);
|
||
const [pageSize, setPageSize] = useState(20);
|
||
const [search, setSearch] = useState('');
|
||
const [bindFilter, setBindFilter] = useState('');
|
||
const [loading, setLoading] = useState(false);
|
||
const [refreshingId, setRefreshingId] = useState<number | null>(null);
|
||
|
||
const [importOpen, setImportOpen] = useState(false);
|
||
const [importing, setImporting] = useState(false);
|
||
const [importErrors, setImportErrors] = useState<WeiboImportError[]>([]);
|
||
const [form] = Form.useForm<{ text: string; tag?: string }>();
|
||
|
||
const [qrOpen, setQrOpen] = useState(false);
|
||
const [qrAccount, setQrAccount] = useState<WeiboAccountItem | null>(null);
|
||
const [qrLoading, setQrLoading] = useState(false);
|
||
const [qrResult, setQrResult] = useState<WeiboBindQrResult | null>(null);
|
||
|
||
const [featureOpen, setFeatureOpen] = useState(false);
|
||
const [featureAccount, setFeatureAccount] = useState<WeiboAccountItem | null>(null);
|
||
const [featureTab, setFeatureTab] = useState('goods');
|
||
const [mallLoading, setMallLoading] = useState(false);
|
||
const [mallResult, setMallResult] = useState<WeiboMallListResult | null>(null);
|
||
const [exchangeLoading, setExchangeLoading] = useState(false);
|
||
const [exchangeResult, setExchangeResult] =
|
||
useState<WeiboExchangeRecordsResult | null>(null);
|
||
const [pointLoading, setPointLoading] = useState(false);
|
||
const [pointResult, setPointResult] = useState<WeiboPointHistoryResult | null>(null);
|
||
const [exchangingGoodsId, setExchangingGoodsId] = useState<number | null>(null);
|
||
const [rechargeAmount, setRechargeAmount] = useState(1);
|
||
const [rechargeCreating, setRechargeCreating] = useState(false);
|
||
const [rechargeOrder, setRechargeOrder] =
|
||
useState<WeiboRechargeOrderResult | null>(null);
|
||
const [paymentStatusLoading, setPaymentStatusLoading] = useState(false);
|
||
const [paymentStatus, setPaymentStatus] =
|
||
useState<WeiboPaymentStatusResult | null>(null);
|
||
|
||
const loadAccounts = useCallback(async () => {
|
||
setLoading(true);
|
||
try {
|
||
const data: PaginatedResponse<WeiboAccountItem> = await weiboApi.listAccounts({
|
||
search: search.trim() || undefined,
|
||
bind_status: bindFilter || undefined,
|
||
page,
|
||
page_size: pageSize,
|
||
});
|
||
setItems(data.items);
|
||
setTotal(data.total);
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
}, [bindFilter, page, pageSize, search]);
|
||
|
||
useEffect(() => {
|
||
void loadAccounts();
|
||
}, [loadAccounts]);
|
||
|
||
const handleImport = async () => {
|
||
const values = await form.validateFields();
|
||
setImporting(true);
|
||
try {
|
||
const result = await weiboApi.importCookies(values.text, values.tag || '');
|
||
setImportErrors(result.errors);
|
||
if (result.count > 0) {
|
||
message.success(result.message);
|
||
await loadAccounts();
|
||
}
|
||
if (result.errors.length === 0 && result.count > 0) {
|
||
setImportOpen(false);
|
||
form.resetFields();
|
||
} else if (result.count === 0) {
|
||
message.error(result.message);
|
||
}
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setImporting(false);
|
||
}
|
||
};
|
||
|
||
const handleRefresh = async (account: WeiboAccountItem) => {
|
||
setRefreshingId(account.id);
|
||
try {
|
||
const updated = await weiboApi.refreshAccount(account.id);
|
||
setItems((current) =>
|
||
current.map((item) => (item.id === updated.id ? updated : item)),
|
||
);
|
||
setFeatureAccount((current) =>
|
||
current?.id === updated.id ? updated : current,
|
||
);
|
||
message.success('账号资料已刷新');
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
void loadAccounts();
|
||
} finally {
|
||
setRefreshingId(null);
|
||
}
|
||
};
|
||
|
||
const openQr = async (account: WeiboAccountItem) => {
|
||
setQrAccount(account);
|
||
setQrResult(null);
|
||
setQrOpen(true);
|
||
setQrLoading(true);
|
||
try {
|
||
const result = await weiboApi.bindQrcodes(account.id);
|
||
setQrResult(result);
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
setQrOpen(false);
|
||
void loadAccounts();
|
||
} finally {
|
||
setQrLoading(false);
|
||
}
|
||
};
|
||
|
||
const handleDelete = async (account: WeiboAccountItem) => {
|
||
try {
|
||
await weiboApi.deleteAccount(account.id);
|
||
message.success('微博账号已删除');
|
||
if (items.length === 1 && page > 1) setPage(page - 1);
|
||
else await loadAccounts();
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
}
|
||
};
|
||
|
||
const loadMall = async (account: WeiboAccountItem) => {
|
||
setMallLoading(true);
|
||
try {
|
||
setMallResult(await weiboApi.mallList(account.id));
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setMallLoading(false);
|
||
}
|
||
};
|
||
|
||
const handleExchange = async (goods: WeiboMallListResult['goods'][number]) => {
|
||
if (!featureAccount) return;
|
||
setExchangingGoodsId(goods.id);
|
||
try {
|
||
const result = await weiboApi.exchangeGoods(
|
||
featureAccount.id,
|
||
goods.id,
|
||
goods.price,
|
||
);
|
||
if (result.verified) {
|
||
message.success(
|
||
`兑换成功:${result.goods_name},余额 ${result.balance_after?.toLocaleString() ?? '-'}`,
|
||
);
|
||
} else {
|
||
message.warning(result.verify_error || '兑换已提交,请查兑换记录复核');
|
||
}
|
||
await loadMall(featureAccount);
|
||
await loadExchangeRecords(featureAccount);
|
||
await handleRefresh(featureAccount);
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setExchangingGoodsId(null);
|
||
}
|
||
};
|
||
|
||
const loadExchangeRecords = async (account: WeiboAccountItem) => {
|
||
setExchangeLoading(true);
|
||
try {
|
||
setExchangeResult(await weiboApi.exchangeRecords(account.id));
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setExchangeLoading(false);
|
||
}
|
||
};
|
||
|
||
const loadPointHistory = async (account: WeiboAccountItem) => {
|
||
setPointLoading(true);
|
||
try {
|
||
setPointResult(await weiboApi.pointHistory(account.id));
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setPointLoading(false);
|
||
}
|
||
};
|
||
|
||
const openFeatures = (account: WeiboAccountItem) => {
|
||
setFeatureAccount(account);
|
||
setFeatureOpen(true);
|
||
setFeatureTab('goods');
|
||
setMallResult(null);
|
||
setExchangeResult(null);
|
||
setPointResult(null);
|
||
setRechargeOrder(null);
|
||
setPaymentStatus(null);
|
||
setRechargeAmount(1);
|
||
void loadMall(account);
|
||
};
|
||
|
||
const switchFeatureTab = (key: string) => {
|
||
setFeatureTab(key);
|
||
if (!featureAccount) return;
|
||
if (key === 'goods' && !mallResult) void loadMall(featureAccount);
|
||
if (key === 'exchange' && !exchangeResult) {
|
||
void loadExchangeRecords(featureAccount);
|
||
}
|
||
if (key === 'points' && !pointResult) void loadPointHistory(featureAccount);
|
||
};
|
||
|
||
const createRecharge = async () => {
|
||
if (!featureAccount) return;
|
||
setRechargeCreating(true);
|
||
setPaymentStatus(null);
|
||
try {
|
||
const order = await weiboApi.createRechargeOrder(
|
||
featureAccount.id,
|
||
rechargeAmount,
|
||
);
|
||
setRechargeOrder(order);
|
||
message.success(`已创建 ${order.amount_yuan} 元充值订单`);
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setRechargeCreating(false);
|
||
}
|
||
};
|
||
|
||
const refreshPaymentStatus = async () => {
|
||
if (!featureAccount || !rechargeOrder) return;
|
||
setPaymentStatusLoading(true);
|
||
try {
|
||
const status = await weiboApi.rechargeStatus(
|
||
featureAccount.id,
|
||
rechargeOrder.pay_id,
|
||
);
|
||
setPaymentStatus(status);
|
||
} catch (error) {
|
||
message.error(getErrorMessage(error));
|
||
} finally {
|
||
setPaymentStatusLoading(false);
|
||
}
|
||
};
|
||
|
||
const refreshAfterRecharge = async () => {
|
||
if (!featureAccount) return;
|
||
await handleRefresh(featureAccount);
|
||
await loadPointHistory(featureAccount);
|
||
};
|
||
|
||
const columns: TableProps<WeiboAccountItem>['columns'] = [
|
||
{
|
||
title: '微博账号',
|
||
key: 'account',
|
||
width: 220,
|
||
render: (_, account) => (
|
||
<Space orientation="vertical" size={0}>
|
||
<Text strong>{account.nickname || account.uid}</Text>
|
||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||
UID {account.uid}
|
||
</Text>
|
||
</Space>
|
||
),
|
||
},
|
||
{
|
||
title: '标签',
|
||
dataIndex: 'tag',
|
||
width: 120,
|
||
render: (value: string) => value || <Text type="secondary">-</Text>,
|
||
},
|
||
{
|
||
title: 'CK',
|
||
key: 'ck',
|
||
width: 120,
|
||
render: (_, account) => {
|
||
const state = CK_STATUS[account.ck_check_status] || {
|
||
label: '未检测',
|
||
color: 'default',
|
||
};
|
||
return (
|
||
<Tooltip title={account.ck_check_message || account.ck_checked_at || ''}>
|
||
<Tag color={state.color}>{state.label}</Tag>
|
||
</Tooltip>
|
||
);
|
||
},
|
||
},
|
||
{
|
||
title: '角色绑定',
|
||
key: 'bind',
|
||
width: 150,
|
||
render: (_, account) => (
|
||
<Space orientation="vertical" size={0}>
|
||
{bindStatus(account)}
|
||
{account.game_role_name && (
|
||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||
{account.game_role_name}
|
||
</Text>
|
||
)}
|
||
</Space>
|
||
),
|
||
},
|
||
{
|
||
title: '微豆',
|
||
dataIndex: 'weidou_balance',
|
||
width: 100,
|
||
align: 'right',
|
||
render: (value: number | null) =>
|
||
value == null ? <Text type="secondary">-</Text> : value.toLocaleString(),
|
||
},
|
||
{
|
||
title: '最近检查',
|
||
dataIndex: 'ck_checked_at',
|
||
width: 170,
|
||
render: (value: string | null) =>
|
||
value ? formatTime(value) : <Text type="secondary">-</Text>,
|
||
},
|
||
{
|
||
title: '操作',
|
||
key: 'actions',
|
||
width: 390,
|
||
fixed: 'right',
|
||
render: (_, account) => {
|
||
const cannotBind =
|
||
account.is_bound === true && account.can_rebind !== true;
|
||
return (
|
||
<Space>
|
||
<Button
|
||
size="small"
|
||
icon={<ReloadOutlined />}
|
||
loading={refreshingId === account.id}
|
||
onClick={() => void handleRefresh(account)}
|
||
>
|
||
刷新
|
||
</Button>
|
||
<Tooltip
|
||
title={
|
||
cannotBind
|
||
? `已绑定,${account.rebind_remain_days || 0} 天后可换绑`
|
||
: '生成微信和 QQ 绑定二维码'
|
||
}
|
||
>
|
||
<Button
|
||
size="small"
|
||
type="primary"
|
||
ghost
|
||
icon={<QrcodeOutlined />}
|
||
disabled={!canBind || cannotBind}
|
||
onClick={() => void openQr(account)}
|
||
>
|
||
绑定码
|
||
</Button>
|
||
</Tooltip>
|
||
<Button
|
||
size="small"
|
||
icon={<AppstoreOutlined />}
|
||
onClick={() => openFeatures(account)}
|
||
>
|
||
功能
|
||
</Button>
|
||
{canDelete && (
|
||
<Popconfirm
|
||
title="删除微博账号?"
|
||
description="只删除本地 CK 和账号资料。"
|
||
okText="删除"
|
||
cancelText="取消"
|
||
okButtonProps={{ danger: true }}
|
||
onConfirm={() => void handleDelete(account)}
|
||
>
|
||
<Button size="small" danger icon={<DeleteOutlined />} />
|
||
</Popconfirm>
|
||
)}
|
||
</Space>
|
||
);
|
||
},
|
||
},
|
||
];
|
||
|
||
const mallColumns: TableProps<WeiboMallListResult['goods'][number]>['columns'] = [
|
||
{
|
||
title: '商品',
|
||
key: 'goods',
|
||
render: (_, goods) => (
|
||
<Space align="start">
|
||
{goods.goods_image && (
|
||
<img
|
||
src={goods.goods_image}
|
||
alt=""
|
||
style={{ width: 42, height: 42, objectFit: 'cover', borderRadius: 4 }}
|
||
/>
|
||
)}
|
||
<Space orientation="vertical" size={0}>
|
||
<Text strong>{goods.goods_name}</Text>
|
||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||
{goods.goods_desc}
|
||
</Text>
|
||
</Space>
|
||
</Space>
|
||
),
|
||
},
|
||
{
|
||
title: '微豆',
|
||
dataIndex: 'price',
|
||
width: 100,
|
||
align: 'right',
|
||
render: (value: number) => value.toLocaleString(),
|
||
},
|
||
{
|
||
title: '库存',
|
||
dataIndex: 'remain_count',
|
||
width: 100,
|
||
align: 'right',
|
||
render: (value: number | null, goods) =>
|
||
goods.is_sold_out ? (
|
||
<Tag color="error">售罄</Tag>
|
||
) : value == null ? (
|
||
'-'
|
||
) : (
|
||
value.toLocaleString()
|
||
),
|
||
},
|
||
{
|
||
title: '操作',
|
||
key: 'exchange',
|
||
width: 90,
|
||
align: 'center',
|
||
render: (_, goods) => {
|
||
const balance = mallResult?.weidou_balance ?? featureAccount?.weidou_balance ?? 0;
|
||
const disabled =
|
||
!canExchange ||
|
||
goods.is_sold_out ||
|
||
goods.remain_count === 0 ||
|
||
goods.price > balance;
|
||
return (
|
||
<Popconfirm
|
||
title={`确认兑换 ${goods.goods_name}?`}
|
||
description={
|
||
<Space orientation="vertical" size={2}>
|
||
<Text>消耗 {goods.price.toLocaleString()} 微豆</Text>
|
||
<Text type="secondary">兑换成功后将立即发放,不能自动撤销。</Text>
|
||
</Space>
|
||
}
|
||
okText="确认兑换"
|
||
cancelText="取消"
|
||
okButtonProps={{ danger: true }}
|
||
disabled={disabled}
|
||
onConfirm={() => void handleExchange(goods)}
|
||
>
|
||
<Button
|
||
size="small"
|
||
danger
|
||
disabled={disabled}
|
||
loading={exchangingGoodsId === goods.id}
|
||
>
|
||
兑换
|
||
</Button>
|
||
</Popconfirm>
|
||
);
|
||
},
|
||
},
|
||
];
|
||
|
||
const exchangeColumns: TableProps<
|
||
WeiboExchangeRecordsResult['items'][number]
|
||
>['columns'] = [
|
||
{ title: '商品', dataIndex: 'goods_name' },
|
||
{ title: '游戏角色', dataIndex: 'game_account', width: 180 },
|
||
{
|
||
title: '微豆',
|
||
dataIndex: 'cost_weidou',
|
||
width: 100,
|
||
align: 'right',
|
||
render: (value: number | null) => value ?? '-',
|
||
},
|
||
{ title: '兑换时间', dataIndex: 'exchange_time', width: 170 },
|
||
{
|
||
title: '状态',
|
||
dataIndex: 'reward_status',
|
||
width: 100,
|
||
render: (value: number | null) => value ?? '-',
|
||
},
|
||
];
|
||
|
||
const pointColumns: TableProps<
|
||
WeiboPointHistoryResult['items'][number]
|
||
>['columns'] = [
|
||
{ title: '来源', dataIndex: 'source_name', width: 150 },
|
||
{
|
||
title: '微豆',
|
||
dataIndex: 'point_num',
|
||
width: 100,
|
||
align: 'right',
|
||
render: (value: number) => (
|
||
<Text type={value >= 0 ? 'success' : 'danger'}>
|
||
{value > 0 ? `+${value}` : value}
|
||
</Text>
|
||
),
|
||
},
|
||
{ title: '到账时间', dataIndex: 'create_time', width: 170 },
|
||
{ title: '过期时间', dataIndex: 'expire_time', width: 170 },
|
||
{ title: '订单号', dataIndex: 'source_id' },
|
||
];
|
||
|
||
return (
|
||
<Space orientation="vertical" size={16} style={{ width: '100%' }}>
|
||
<div
|
||
style={{
|
||
display: 'flex',
|
||
alignItems: 'center',
|
||
justifyContent: 'space-between',
|
||
gap: 16,
|
||
flexWrap: 'wrap',
|
||
}}
|
||
>
|
||
<div>
|
||
<Title level={4} style={{ margin: 0 }}>
|
||
微博账号
|
||
</Title>
|
||
<Text type="secondary">CK 导入、微豆资料刷新和角色绑定二维码</Text>
|
||
</div>
|
||
<Space wrap>
|
||
<Input
|
||
allowClear
|
||
prefix={<SearchOutlined />}
|
||
placeholder="UID、昵称、角色、标签"
|
||
value={search}
|
||
onChange={(event) => {
|
||
setSearch(event.target.value);
|
||
setPage(1);
|
||
}}
|
||
style={{ width: 240 }}
|
||
/>
|
||
<Select
|
||
value={bindFilter}
|
||
onChange={(value) => {
|
||
setBindFilter(value);
|
||
setPage(1);
|
||
}}
|
||
style={{ width: 130 }}
|
||
options={[
|
||
{ value: '', label: '全部绑定状态' },
|
||
{ value: 'unbound', label: '未绑定' },
|
||
{ value: 'bound', label: '已绑定' },
|
||
{ value: 'rebindable', label: '可换绑' },
|
||
]}
|
||
/>
|
||
<Button icon={<ReloadOutlined />} onClick={() => void loadAccounts()}>
|
||
刷新列表
|
||
</Button>
|
||
<Button
|
||
type="primary"
|
||
icon={<ImportOutlined />}
|
||
disabled={!canImport}
|
||
onClick={() => {
|
||
setImportErrors([]);
|
||
setImportOpen(true);
|
||
}}
|
||
>
|
||
导入 CK
|
||
</Button>
|
||
</Space>
|
||
</div>
|
||
|
||
<div
|
||
style={{
|
||
background: token.colorBgContainer,
|
||
border: `1px solid ${token.colorBorderSecondary}`,
|
||
borderRadius: token.borderRadius,
|
||
overflow: 'hidden',
|
||
}}
|
||
>
|
||
<Table<WeiboAccountItem>
|
||
rowKey="id"
|
||
loading={loading}
|
||
columns={columns}
|
||
dataSource={items}
|
||
scroll={{ x: 1180 }}
|
||
pagination={{
|
||
current: page,
|
||
pageSize,
|
||
total,
|
||
showSizeChanger: true,
|
||
showTotal: (value) => `共 ${value} 个账号`,
|
||
onChange: (nextPage, nextSize) => {
|
||
setPage(nextPage);
|
||
setPageSize(nextSize);
|
||
},
|
||
}}
|
||
/>
|
||
</div>
|
||
|
||
<Modal
|
||
title="导入微博 CK"
|
||
open={importOpen}
|
||
confirmLoading={importing}
|
||
okText="验证并导入"
|
||
cancelText="取消"
|
||
onOk={() => void handleImport()}
|
||
onCancel={() => setImportOpen(false)}
|
||
destroyOnHidden
|
||
>
|
||
<Form form={form} layout="vertical" preserve={false}>
|
||
<Form.Item
|
||
name="text"
|
||
label="Cookie"
|
||
rules={[{ required: true, message: '请粘贴微博 CK' }]}
|
||
>
|
||
<TextArea
|
||
rows={8}
|
||
placeholder={'SCF=...; SUB=...; SUBP=...\n每行一个完整 Cookie'}
|
||
/>
|
||
</Form.Item>
|
||
<Form.Item name="tag" label="标签">
|
||
<Input placeholder="可选" maxLength={64} />
|
||
</Form.Item>
|
||
</Form>
|
||
{importErrors.length > 0 && (
|
||
<Alert
|
||
type="warning"
|
||
showIcon
|
||
title={`${importErrors.length} 条导入失败`}
|
||
description={
|
||
<Space orientation="vertical" size={2}>
|
||
{importErrors.slice(0, 8).map((item) => (
|
||
<Text key={`${item.line}-${item.message}`} style={{ fontSize: 12 }}>
|
||
第 {item.line} 行:{item.message}
|
||
</Text>
|
||
))}
|
||
</Space>
|
||
}
|
||
/>
|
||
)}
|
||
</Modal>
|
||
|
||
<Modal
|
||
title={qrAccount ? `绑定二维码 · ${qrAccount.nickname || qrAccount.uid}` : '绑定二维码'}
|
||
open={qrOpen}
|
||
footer={null}
|
||
width={620}
|
||
onCancel={() => setQrOpen(false)}
|
||
destroyOnHidden
|
||
>
|
||
{qrLoading ? (
|
||
<div style={{ minHeight: 300, display: 'grid', placeItems: 'center' }}>
|
||
<Spin />
|
||
</div>
|
||
) : qrResult ? (
|
||
<Space size={28} align="start" wrap style={{ width: '100%', justifyContent: 'center' }}>
|
||
{qrResult.schemes.map((scheme) => (
|
||
<div key={scheme.channel} style={{ width: 240, textAlign: 'center' }}>
|
||
<Text strong>{scheme.label}</Text>
|
||
<div
|
||
style={{
|
||
height: 240,
|
||
marginTop: 12,
|
||
display: 'grid',
|
||
placeItems: 'center',
|
||
background: '#fff',
|
||
border: '1px solid #f0f0f0',
|
||
borderRadius: 6,
|
||
}}
|
||
>
|
||
{scheme.scheme ? (
|
||
<QRCode
|
||
value={scheme.scheme}
|
||
size={210}
|
||
bordered={false}
|
||
color="#000"
|
||
bgColor="#fff"
|
||
/>
|
||
) : (
|
||
<Alert
|
||
type="error"
|
||
showIcon
|
||
title="生成失败"
|
||
description={scheme.error}
|
||
/>
|
||
)}
|
||
</div>
|
||
</div>
|
||
))}
|
||
</Space>
|
||
) : null}
|
||
</Modal>
|
||
|
||
<Drawer
|
||
title={
|
||
featureAccount
|
||
? `账户功能 · ${featureAccount.nickname || featureAccount.uid}`
|
||
: '账户功能'
|
||
}
|
||
open={featureOpen}
|
||
onClose={() => setFeatureOpen(false)}
|
||
size={900}
|
||
destroyOnHidden
|
||
>
|
||
{featureAccount && (
|
||
<Space orientation="vertical" size={16} style={{ width: '100%' }}>
|
||
<Descriptions
|
||
size="small"
|
||
column={3}
|
||
items={[
|
||
{ key: 'uid', label: 'UID', children: featureAccount.uid },
|
||
{
|
||
key: 'balance',
|
||
label: '微豆余额',
|
||
children: featureAccount.weidou_balance?.toLocaleString() ?? '-',
|
||
},
|
||
{ key: 'bind', label: '角色绑定', children: bindStatus(featureAccount) },
|
||
]}
|
||
/>
|
||
<Tabs
|
||
activeKey={featureTab}
|
||
onChange={switchFeatureTab}
|
||
items={[
|
||
{
|
||
key: 'goods',
|
||
label: '商品列表',
|
||
children: (
|
||
<Space orientation="vertical" size={12} style={{ width: '100%' }}>
|
||
<Space style={{ justifyContent: 'space-between', width: '100%' }}>
|
||
<Text type="secondary">
|
||
当前余额 {mallResult?.weidou_balance?.toLocaleString() ?? '-'}
|
||
</Text>
|
||
<Button
|
||
size="small"
|
||
icon={<ReloadOutlined />}
|
||
loading={mallLoading}
|
||
onClick={() => void loadMall(featureAccount)}
|
||
>
|
||
刷新商品
|
||
</Button>
|
||
</Space>
|
||
<Table
|
||
rowKey="id"
|
||
size="small"
|
||
loading={mallLoading}
|
||
columns={mallColumns}
|
||
dataSource={mallResult?.goods || []}
|
||
pagination={false}
|
||
/>
|
||
</Space>
|
||
),
|
||
},
|
||
{
|
||
key: 'exchange',
|
||
label: '兑换记录',
|
||
children: (
|
||
<Space orientation="vertical" size={12} style={{ width: '100%' }}>
|
||
<Button
|
||
size="small"
|
||
icon={<ReloadOutlined />}
|
||
loading={exchangeLoading}
|
||
onClick={() => void loadExchangeRecords(featureAccount)}
|
||
>
|
||
刷新记录
|
||
</Button>
|
||
<Table
|
||
rowKey={(record, index) =>
|
||
`${record.goods_name}-${record.exchange_time}-${index}`
|
||
}
|
||
size="small"
|
||
loading={exchangeLoading}
|
||
columns={exchangeColumns}
|
||
dataSource={exchangeResult?.items || []}
|
||
pagination={false}
|
||
/>
|
||
</Space>
|
||
),
|
||
},
|
||
{
|
||
key: 'points',
|
||
label: '微豆明细',
|
||
children: (
|
||
<Space orientation="vertical" size={12} style={{ width: '100%' }}>
|
||
<Button
|
||
size="small"
|
||
icon={<ReloadOutlined />}
|
||
loading={pointLoading}
|
||
onClick={() => void loadPointHistory(featureAccount)}
|
||
>
|
||
刷新明细
|
||
</Button>
|
||
<Table
|
||
rowKey={(record) => record.id || record.source_id}
|
||
size="small"
|
||
loading={pointLoading}
|
||
columns={pointColumns}
|
||
dataSource={pointResult?.items || []}
|
||
pagination={false}
|
||
/>
|
||
</Space>
|
||
),
|
||
},
|
||
{
|
||
key: 'recharge',
|
||
label: '助威充值',
|
||
children: (
|
||
<Space orientation="vertical" size={16} style={{ width: '100%' }}>
|
||
{!canRecharge ? (
|
||
<Alert type="warning" showIcon title="没有充值权限" />
|
||
) : (
|
||
<Space wrap>
|
||
<Space.Compact>
|
||
<InputNumber
|
||
min={1}
|
||
max={1000}
|
||
precision={0}
|
||
value={rechargeAmount}
|
||
onChange={(value) => setRechargeAmount(Number(value) || 1)}
|
||
style={{ width: 110 }}
|
||
/>
|
||
<Button disabled>元</Button>
|
||
</Space.Compact>
|
||
<Button
|
||
type="primary"
|
||
loading={rechargeCreating}
|
||
onClick={() => void createRecharge()}
|
||
>
|
||
创建充值订单
|
||
</Button>
|
||
</Space>
|
||
)}
|
||
{rechargeOrder && (
|
||
<Space
|
||
align="start"
|
||
size={24}
|
||
wrap
|
||
style={{ alignItems: 'flex-start' }}
|
||
>
|
||
<div
|
||
style={{
|
||
width: 240,
|
||
padding: 12,
|
||
background: '#fff',
|
||
borderRadius: 6,
|
||
textAlign: 'center',
|
||
}}
|
||
>
|
||
<QRCode
|
||
value={rechargeOrder.alipay_qr_code}
|
||
size={216}
|
||
bordered={false}
|
||
color="#000"
|
||
bgColor="#fff"
|
||
/>
|
||
</div>
|
||
<Space orientation="vertical" size={10}>
|
||
<Descriptions
|
||
size="small"
|
||
column={1}
|
||
items={[
|
||
{
|
||
key: 'amount',
|
||
label: '支付金额',
|
||
children: `${rechargeOrder.amount_yuan} 元`,
|
||
},
|
||
{
|
||
key: 'reward',
|
||
label: '预计微豆',
|
||
children: rechargeOrder.single_reward.toLocaleString(),
|
||
},
|
||
{
|
||
key: 'order',
|
||
label: '订单号',
|
||
children: (
|
||
<Text copyable style={{ fontSize: 12 }}>
|
||
{rechargeOrder.order_id}
|
||
</Text>
|
||
),
|
||
},
|
||
]}
|
||
/>
|
||
<Space wrap>
|
||
<Button
|
||
icon={<ReloadOutlined />}
|
||
loading={paymentStatusLoading}
|
||
onClick={() => void refreshPaymentStatus()}
|
||
>
|
||
刷新支付状态
|
||
</Button>
|
||
{rechargeOrder.desktop_pay_url && (
|
||
<Button
|
||
href={rechargeOrder.desktop_pay_url}
|
||
target="_blank"
|
||
rel="noreferrer"
|
||
>
|
||
电脑端支付
|
||
</Button>
|
||
)}
|
||
<Button onClick={() => void refreshAfterRecharge()}>
|
||
刷新到账
|
||
</Button>
|
||
</Space>
|
||
{paymentStatus && (
|
||
<Alert
|
||
type={
|
||
paymentStatus.status === 'PAY_STATUS_SUCCESS'
|
||
? 'success'
|
||
: 'info'
|
||
}
|
||
showIcon
|
||
title={
|
||
PAYMENT_STATUS_LABELS[paymentStatus.status] ||
|
||
paymentStatus.status
|
||
}
|
||
description={paymentStatus.sub_status}
|
||
/>
|
||
)}
|
||
</Space>
|
||
</Space>
|
||
)}
|
||
</Space>
|
||
),
|
||
},
|
||
]}
|
||
/>
|
||
</Space>
|
||
)}
|
||
</Drawer>
|
||
</Space>
|
||
);
|
||
}
|