feat(platform): 增加履约分类映射管理并锁定迁移
This commit is contained in:
@@ -7,6 +7,20 @@ import type {
|
||||
PlatformFulfillmentSettings,
|
||||
} from './types';
|
||||
|
||||
export interface PlatformFulfillmentMappingWrite {
|
||||
internal_sku_key: string;
|
||||
campaign_key: string;
|
||||
campaign_name: string;
|
||||
commodity_id: string;
|
||||
goods_name?: string;
|
||||
required_points?: number | null;
|
||||
sale_mode: 'presale' | 'direct' | 'manual' | 'unknown';
|
||||
available_from?: string | null;
|
||||
available_until?: string | null;
|
||||
released_at?: string | null;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export const platformFulfillmentApi = {
|
||||
getSettings: () =>
|
||||
api.get<PlatformFulfillmentSettings, PlatformFulfillmentSettings>(
|
||||
@@ -25,6 +39,8 @@ export const platformFulfillmentApi = {
|
||||
),
|
||||
listTasks: (params: {
|
||||
status?: string;
|
||||
queue_bucket?: string;
|
||||
sale_mode?: string;
|
||||
keyword?: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
@@ -48,22 +64,46 @@ export const platformFulfillmentApi = {
|
||||
api.get<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||
`/platform-fulfillment/tasks/${taskId}`,
|
||||
),
|
||||
listMappings: (keyword = '') =>
|
||||
listMappings: (params: {
|
||||
keyword?: string;
|
||||
sale_mode?: string;
|
||||
enabled?: boolean;
|
||||
include_archived?: boolean;
|
||||
} = {}) =>
|
||||
api.get<PlatformFulfillmentMapping[], PlatformFulfillmentMapping[]>(
|
||||
'/platform-fulfillment/mappings',
|
||||
{ params: { keyword } },
|
||||
{ params },
|
||||
),
|
||||
upsertMapping: (data: {
|
||||
internal_sku_key: string;
|
||||
commodity_id: string;
|
||||
goods_name?: string;
|
||||
required_points?: number | null;
|
||||
enabled: boolean;
|
||||
}) =>
|
||||
api.put<PlatformFulfillmentMapping, PlatformFulfillmentMapping>(
|
||||
createMapping: (data: PlatformFulfillmentMappingWrite) =>
|
||||
api.post<PlatformFulfillmentMapping, PlatformFulfillmentMapping>(
|
||||
'/platform-fulfillment/mappings',
|
||||
data,
|
||||
),
|
||||
updateMapping: (mappingId: number, data: PlatformFulfillmentMappingWrite) =>
|
||||
api.patch<PlatformFulfillmentMapping, PlatformFulfillmentMapping>(
|
||||
`/platform-fulfillment/mappings/${mappingId}`,
|
||||
data,
|
||||
),
|
||||
deleteMapping: (mappingId: number) =>
|
||||
api.delete<{ success: boolean }, { success: boolean }>(
|
||||
`/platform-fulfillment/mappings/${mappingId}`,
|
||||
),
|
||||
mappingAction: (mappingId: number, action: 'enable' | 'disable' | 'archive' | 'restore') =>
|
||||
api.post<PlatformFulfillmentMapping, PlatformFulfillmentMapping>(
|
||||
`/platform-fulfillment/mappings/${mappingId}/${action}`,
|
||||
),
|
||||
mappingImpact: (mappingId: number) =>
|
||||
api.get<{
|
||||
mappingId: number;
|
||||
internalSkuKey: string;
|
||||
affectedTasks: number;
|
||||
groups: Array<{ executionStatus: string; saleMode: string; count: number }>;
|
||||
}, {
|
||||
mappingId: number;
|
||||
internalSkuKey: string;
|
||||
affectedTasks: number;
|
||||
groups: Array<{ executionStatus: string; saleMode: string; count: number }>;
|
||||
}>(`/platform-fulfillment/mappings/${mappingId}/impact`),
|
||||
allocate: (taskId: number) =>
|
||||
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||
`/platform-fulfillment/tasks/${taskId}/allocate`,
|
||||
|
||||
@@ -2225,6 +2225,15 @@ export interface PlatformFulfillmentTask {
|
||||
commodityMappingId: number | null;
|
||||
commodityId: string;
|
||||
requiredPoints: number | null;
|
||||
saleMode: 'presale' | 'direct' | 'manual' | 'unknown';
|
||||
campaignKey: string;
|
||||
campaignName: string;
|
||||
offerAvailableFrom: string | null;
|
||||
offerAvailableUntil: string | null;
|
||||
availabilityState: 'waiting_release' | 'available' | 'sold_out' | 'ended' | 'unknown';
|
||||
queueBucket: 'pending_mapping' | 'presale_waiting' | 'ready_for_fulfillment' | 'needs_action' | 'completed' | 'cancelled';
|
||||
manualReason: string;
|
||||
classificationSource: string;
|
||||
bindingStatus: string;
|
||||
executionStatus: string;
|
||||
exchangeStatus: string;
|
||||
@@ -2273,11 +2282,22 @@ export interface PlatformFulfillmentMapping {
|
||||
id: number;
|
||||
targetPlatform: string;
|
||||
internalSkuKey: string;
|
||||
campaignKey: string;
|
||||
campaignName: string;
|
||||
commodityId: string;
|
||||
goodsName: string;
|
||||
requiredPoints: number | null;
|
||||
scope: string;
|
||||
saleMode: 'presale' | 'direct' | 'manual' | 'unknown';
|
||||
availableFrom: string | null;
|
||||
availableUntil: string | null;
|
||||
releasedAt: string | null;
|
||||
goodsStatus: string;
|
||||
availabilityState: 'waiting_release' | 'available' | 'sold_out' | 'ended' | 'unknown';
|
||||
enabled: boolean;
|
||||
version: number;
|
||||
archivedAt: string | null;
|
||||
affectedTasks: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,39 @@ const EXCHANGE_STATUS_LABELS: Record<string, string> = {
|
||||
manual_done: '人工兑换完成',
|
||||
};
|
||||
|
||||
const SALE_MODE_LABELS: Record<string, string> = {
|
||||
presale: '预售',
|
||||
direct: '直接兑换',
|
||||
manual: '人工',
|
||||
unknown: '未分类',
|
||||
};
|
||||
|
||||
const AVAILABILITY_LABELS: Record<string, string> = {
|
||||
waiting_release: '待开放',
|
||||
available: '可兑换',
|
||||
sold_out: '已售罄',
|
||||
ended: '已结束',
|
||||
unknown: '未知',
|
||||
};
|
||||
|
||||
const MANUAL_REASON_LABELS: Record<string, string> = {
|
||||
points_short: '积分不足',
|
||||
elite_not_opened: '宝典未开通',
|
||||
limit_reached: '已达限兑',
|
||||
binding_failed: '绑定异常',
|
||||
account_cooldown: '账号冷却',
|
||||
other_manual: '其他人工',
|
||||
};
|
||||
|
||||
const QUEUE_BUCKET_OPTIONS = [
|
||||
{ value: 'current', label: '当前待办' },
|
||||
{ value: 'presale_waiting', label: '预售待开放' },
|
||||
{ value: 'ready_for_fulfillment', label: '可履约' },
|
||||
{ value: 'needs_action', label: '需要人工' },
|
||||
{ value: 'completed', label: '已完成' },
|
||||
{ value: 'cancelled', label: '已取消' },
|
||||
];
|
||||
|
||||
const ACTOR_TYPE_LABELS: Record<string, string> = {
|
||||
system: '系统',
|
||||
user: '操作人',
|
||||
@@ -304,7 +337,8 @@ export default function PlatformFulfillmentPage() {
|
||||
const user = getUser();
|
||||
const navigate = useNavigate();
|
||||
const { can } = usePermissions(user);
|
||||
const [status, setStatus] = useState('');
|
||||
const [queueBucket, setQueueBucket] = useState('current');
|
||||
const [saleModeFilter, setSaleModeFilter] = useState('');
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
@@ -327,9 +361,18 @@ export default function PlatformFulfillmentPage() {
|
||||
const [qrOpen, setQrOpen] = useState(false);
|
||||
const [mappingOpen, setMappingOpen] = useState(false);
|
||||
const [mappingSku, setMappingSku] = useState('');
|
||||
const [mappingEditingId, setMappingEditingId] = useState<number | null>(null);
|
||||
const [mappingCampaignKey, setMappingCampaignKey] = useState('douyu-current');
|
||||
const [mappingCampaignName, setMappingCampaignName] = useState('');
|
||||
const [mappingGoodsId, setMappingGoodsId] = useState('');
|
||||
const [mappingGoodsName, setMappingGoodsName] = useState('');
|
||||
const [mappingPoints, setMappingPoints] = useState<number | null>(null);
|
||||
const [mappingEnabled, setMappingEnabled] = useState(true);
|
||||
const [mappingSaleMode, setMappingSaleMode] = useState<'presale' | 'direct' | 'manual' | 'unknown'>('unknown');
|
||||
const [mappingAvailableFrom, setMappingAvailableFrom] = useState<Dayjs | null>(null);
|
||||
const [mappingAvailableUntil, setMappingAvailableUntil] = useState<Dayjs | null>(null);
|
||||
const [mappingFilterMode, setMappingFilterMode] = useState('');
|
||||
const [mappingIncludeArchived, setMappingIncludeArchived] = useState(false);
|
||||
const [goods, setGoods] = useState<DouyuGoodsItem[]>([]);
|
||||
const [mappingGoodsLoading, setMappingGoodsLoading] = useState(false);
|
||||
const [mappings, setMappings] = useState<PlatformFulfillmentMapping[]>([]);
|
||||
@@ -354,8 +397,16 @@ export default function PlatformFulfillmentPage() {
|
||||
const loadTasks = useCallback(async (silent = false) => {
|
||||
if (!silent) setLoading(true);
|
||||
try {
|
||||
const queueBackedStatus = queueBucket === 'current'
|
||||
? 'unfinished'
|
||||
: (['completed', 'cancelled'].includes(queueBucket) ? queueBucket : undefined);
|
||||
const backendBucket = ['presale_waiting', 'ready_for_fulfillment', 'needs_action'].includes(queueBucket)
|
||||
? queueBucket
|
||||
: undefined;
|
||||
const result = await platformFulfillmentApi.listTasks({
|
||||
status: status || undefined,
|
||||
status: queueBackedStatus,
|
||||
queue_bucket: backendBucket,
|
||||
sale_mode: saleModeFilter || undefined,
|
||||
keyword: keyword.trim() || undefined,
|
||||
page,
|
||||
page_size: pageSize,
|
||||
@@ -367,7 +418,7 @@ export default function PlatformFulfillmentPage() {
|
||||
} finally {
|
||||
if (!silent) setLoading(false);
|
||||
}
|
||||
}, [keyword, page, pageSize, status]);
|
||||
}, [keyword, page, pageSize, queueBucket, saleModeFilter]);
|
||||
|
||||
const loadDetail = useCallback(async (taskId: number, silent = false) => {
|
||||
if (!silent) setDetailLoading(true);
|
||||
@@ -707,15 +758,46 @@ export default function PlatformFulfillmentPage() {
|
||||
link.click();
|
||||
};
|
||||
|
||||
const openMapping = async (task?: PlatformFulfillmentTask) => {
|
||||
const resetMappingForm = (task?: PlatformFulfillmentTask) => {
|
||||
setMappingEditingId(null);
|
||||
setMappingSku(task?.internalSkuKey || '');
|
||||
setMappingCampaignKey(task?.campaignKey || 'douyu-current');
|
||||
setMappingCampaignName(task?.campaignName || '');
|
||||
setMappingGoodsId(task?.commodityId || '');
|
||||
setMappingGoodsName('');
|
||||
setMappingPoints(task?.requiredPoints ?? null);
|
||||
setMappingEnabled(true);
|
||||
setMappingSaleMode(task?.saleMode || 'unknown');
|
||||
setMappingAvailableFrom(task?.offerAvailableFrom ? dayjs(task.offerAvailableFrom) : null);
|
||||
setMappingAvailableUntil(task?.offerAvailableUntil ? dayjs(task.offerAvailableUntil) : null);
|
||||
};
|
||||
|
||||
const loadMappingRows = async (
|
||||
keyword = mappingSku.trim(),
|
||||
mode = mappingFilterMode,
|
||||
includeArchived = mappingIncludeArchived,
|
||||
) => {
|
||||
const rows = await platformFulfillmentApi.listMappings({
|
||||
keyword,
|
||||
sale_mode: mode || undefined,
|
||||
include_archived: includeArchived,
|
||||
});
|
||||
setMappings(rows);
|
||||
};
|
||||
|
||||
const openMapping = async (task?: PlatformFulfillmentTask) => {
|
||||
resetMappingForm(task);
|
||||
setMappingOpen(true);
|
||||
setMappingGoodsLoading(true);
|
||||
try {
|
||||
const [goodsRows, mappingRows] = await Promise.all([douyuApi.listLiveGoods(), platformFulfillmentApi.listMappings(task?.internalSkuKey || '')]);
|
||||
const [goodsRows, mappingRows] = await Promise.all([
|
||||
douyuApi.listLiveGoods(),
|
||||
platformFulfillmentApi.listMappings({
|
||||
keyword: task?.internalSkuKey || '',
|
||||
sale_mode: mappingFilterMode || undefined,
|
||||
include_archived: mappingIncludeArchived,
|
||||
}),
|
||||
]);
|
||||
setGoods(goodsRows);
|
||||
setMappings(mappingRows);
|
||||
if (goodsRows.length === 0) {
|
||||
@@ -728,6 +810,65 @@ export default function PlatformFulfillmentPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const editMapping = (row: PlatformFulfillmentMapping) => {
|
||||
setMappingEditingId(row.id);
|
||||
setMappingSku(row.internalSkuKey);
|
||||
setMappingCampaignKey(row.campaignKey || 'douyu-current');
|
||||
setMappingCampaignName(row.campaignName || '');
|
||||
setMappingGoodsId(row.commodityId);
|
||||
setMappingGoodsName(row.goodsName);
|
||||
setMappingPoints(row.requiredPoints);
|
||||
setMappingEnabled(row.enabled);
|
||||
setMappingSaleMode(row.saleMode);
|
||||
setMappingAvailableFrom(row.availableFrom ? dayjs(row.availableFrom) : null);
|
||||
setMappingAvailableUntil(row.availableUntil ? dayjs(row.availableUntil) : null);
|
||||
};
|
||||
|
||||
const runMappingAction = (
|
||||
row: PlatformFulfillmentMapping,
|
||||
action: 'enable' | 'disable' | 'archive' | 'restore',
|
||||
) => {
|
||||
const label = {
|
||||
enable: '启用',
|
||||
disable: '停用',
|
||||
archive: '归档',
|
||||
restore: '恢复',
|
||||
}[action];
|
||||
Modal.confirm({
|
||||
title: `${label}映射`,
|
||||
content: `${row.internalSkuKey} / ${row.campaignKey}`,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await platformFulfillmentApi.mappingAction(row.id, action);
|
||||
message.success(`映射已${label}`);
|
||||
await loadMappingRows();
|
||||
await loadTasks();
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const removeMapping = (row: PlatformFulfillmentMapping) => {
|
||||
Modal.confirm({
|
||||
title: '删除映射',
|
||||
content: row.affectedTasks > 0
|
||||
? `该映射还有 ${row.affectedTasks} 个关联任务,只能归档。`
|
||||
: '映射删除后不可恢复。',
|
||||
okButtonProps: { danger: true },
|
||||
onOk: async () => {
|
||||
try {
|
||||
await platformFulfillmentApi.deleteMapping(row.id);
|
||||
message.success('映射已删除');
|
||||
await loadMappingRows();
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const reloadMappingGoods = async () => {
|
||||
setMappingGoodsLoading(true);
|
||||
try {
|
||||
@@ -748,25 +889,41 @@ export default function PlatformFulfillmentPage() {
|
||||
const selectGoods = (commodityId: string) => {
|
||||
const item = goods.find((row) => row.commodity_id === commodityId);
|
||||
setMappingGoodsId(commodityId);
|
||||
setMappingGoodsName(item?.name || '');
|
||||
if (item?.score != null) setMappingPoints(Number(item.score));
|
||||
};
|
||||
|
||||
const saveMapping = async () => {
|
||||
if (!mappingSku.trim() || !mappingGoodsId) {
|
||||
message.warning('请填写内部 SKU 并选择斗鱼商品');
|
||||
if (!mappingSku.trim() || !mappingCampaignKey.trim() || !mappingGoodsId || !mappingSaleMode) {
|
||||
message.warning('请填写内部 SKU、活动批次、销售模式并选择斗鱼商品');
|
||||
return;
|
||||
}
|
||||
if (mappingSaleMode === 'unknown') {
|
||||
message.warning('请选择预售、直接兑换或人工销售模式');
|
||||
return;
|
||||
}
|
||||
const item = goods.find((row) => row.commodity_id === mappingGoodsId);
|
||||
try {
|
||||
await platformFulfillmentApi.upsertMapping({
|
||||
const payload = {
|
||||
internal_sku_key: mappingSku.trim(),
|
||||
campaign_key: mappingCampaignKey.trim(),
|
||||
campaign_name: mappingCampaignName.trim(),
|
||||
commodity_id: mappingGoodsId,
|
||||
goods_name: item?.name || '',
|
||||
goods_name: item?.name || mappingGoodsName,
|
||||
required_points: mappingPoints,
|
||||
sale_mode: mappingSaleMode,
|
||||
available_from: mappingAvailableFrom?.toISOString() || null,
|
||||
available_until: mappingAvailableUntil?.toISOString() || null,
|
||||
enabled: mappingEnabled,
|
||||
});
|
||||
};
|
||||
if (mappingEditingId) {
|
||||
await platformFulfillmentApi.updateMapping(mappingEditingId, payload);
|
||||
} else {
|
||||
await platformFulfillmentApi.createMapping(payload);
|
||||
}
|
||||
message.success('商品映射已保存');
|
||||
setMappings(await platformFulfillmentApi.listMappings(mappingSku.trim()));
|
||||
resetMappingForm();
|
||||
await loadMappingRows();
|
||||
await loadTasks();
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
@@ -861,6 +1018,27 @@ export default function PlatformFulfillmentPage() {
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '分类',
|
||||
key: 'classification',
|
||||
width: 190,
|
||||
render: (_, task) => (
|
||||
<Space direction="vertical" size={3}>
|
||||
<Space size={4}>
|
||||
<Tag color={task.saleMode === 'presale' ? 'gold' : task.saleMode === 'direct' ? 'green' : 'default'}>
|
||||
{SALE_MODE_LABELS[task.saleMode] || task.saleMode}
|
||||
</Tag>
|
||||
<Tag>{AVAILABILITY_LABELS[task.availabilityState] || task.availabilityState}</Tag>
|
||||
</Space>
|
||||
<Text type="secondary" ellipsis title={task.campaignName || task.campaignKey || '-'}>
|
||||
{task.campaignName || task.campaignKey || '未设置活动批次'}
|
||||
</Text>
|
||||
{task.offerAvailableFrom ? (
|
||||
<Text type="secondary">开放:{formatTime(task.offerAvailableFrom)}</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '订单金额',
|
||||
dataIndex: 'orderAmountFen',
|
||||
@@ -900,11 +1078,16 @@ export default function PlatformFulfillmentPage() {
|
||||
{
|
||||
title: '状态',
|
||||
key: 'status',
|
||||
width: 150,
|
||||
width: 180,
|
||||
render: (_, task) => (
|
||||
<Space direction="vertical" size={4}>
|
||||
<Tag color={STATUS_COLORS[task.executionStatus] || 'default'}>{statusLabel(task.executionStatus)}</Tag>
|
||||
<Text type="secondary">兑换:{exchangeStatusLabel(task.exchangeStatus)}</Text>
|
||||
{task.manualReason ? (
|
||||
<Text type="danger">
|
||||
{MANUAL_REASON_LABELS[task.manualReason] || task.manualReason}
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -1129,11 +1312,22 @@ export default function PlatformFulfillmentPage() {
|
||||
}}
|
||||
style={{ width: 300 }}
|
||||
/>
|
||||
<Select
|
||||
value={status}
|
||||
options={STATUS_OPTIONS}
|
||||
<Segmented
|
||||
value={queueBucket}
|
||||
options={QUEUE_BUCKET_OPTIONS}
|
||||
onChange={(value) => {
|
||||
setStatus(value);
|
||||
setQueueBucket(String(value));
|
||||
setPage(1);
|
||||
}}
|
||||
/>
|
||||
<Select
|
||||
value={saleModeFilter}
|
||||
options={[
|
||||
{ value: '', label: '全部销售模式' },
|
||||
...Object.entries(SALE_MODE_LABELS).map(([value, label]) => ({ value, label })),
|
||||
]}
|
||||
onChange={(value) => {
|
||||
setSaleModeFilter(value);
|
||||
setPage(1);
|
||||
}}
|
||||
style={{ width: 150 }}
|
||||
@@ -1151,7 +1345,7 @@ export default function PlatformFulfillmentPage() {
|
||||
selectedRowKeys,
|
||||
onChange: setSelectedRowKeys,
|
||||
}}
|
||||
scroll={{ x: 1900 }}
|
||||
scroll={{ x: 2100 }}
|
||||
pagination={{
|
||||
current: page,
|
||||
pageSize,
|
||||
@@ -1272,6 +1466,15 @@ export default function PlatformFulfillmentPage() {
|
||||
<Descriptions.Item label="斗鱼商品" span={2}>
|
||||
{selected.commodityId || '未映射'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="销售模式">
|
||||
{SALE_MODE_LABELS[selected.saleMode] || selected.saleMode}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="开放状态">
|
||||
{AVAILABILITY_LABELS[selected.availabilityState] || selected.availabilityState}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="活动批次" span={2}>
|
||||
{selected.campaignName || selected.campaignKey || '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="订单金额">{money(selected.orderAmountFen)}</Descriptions.Item>
|
||||
<Descriptions.Item label="所需积分">{selected.requiredPoints ?? '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="执行状态">{statusLabel(selected.executionStatus)}</Descriptions.Item>
|
||||
@@ -1631,9 +1834,51 @@ export default function PlatformFulfillmentPage() {
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
<Modal open={mappingOpen} title="斗鱼商品映射" width={760} okText="保存映射" onOk={() => void saveMapping()} onCancel={() => setMappingOpen(false)}>
|
||||
<Modal
|
||||
open={mappingOpen}
|
||||
title="斗鱼商品映射管理"
|
||||
width={1120}
|
||||
okText="保存映射"
|
||||
onOk={() => void saveMapping()}
|
||||
onCancel={() => setMappingOpen(false)}
|
||||
>
|
||||
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
||||
<Input placeholder="内部 SKU,例如 套装-兔兔白日梦" value={mappingSku} onChange={(event) => setMappingSku(event.target.value)} />
|
||||
<Space wrap>
|
||||
<Select
|
||||
value={mappingFilterMode}
|
||||
options={[
|
||||
{ value: '', label: '全部销售模式' },
|
||||
...Object.entries(SALE_MODE_LABELS).map(([value, label]) => ({ value, label })),
|
||||
]}
|
||||
onChange={(value) => {
|
||||
setMappingFilterMode(value);
|
||||
void loadMappingRows(mappingSku.trim(), value).catch((error) => message.error(getErrorMessage(error)));
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
<Space>
|
||||
<Text>显示已归档</Text>
|
||||
<Switch
|
||||
checked={mappingIncludeArchived}
|
||||
onChange={(checked) => {
|
||||
setMappingIncludeArchived(checked);
|
||||
void platformFulfillmentApi.listMappings({
|
||||
keyword: mappingSku.trim(),
|
||||
sale_mode: mappingFilterMode || undefined,
|
||||
include_archived: checked,
|
||||
}).then(setMappings).catch((error) => message.error(getErrorMessage(error)));
|
||||
}}
|
||||
/>
|
||||
</Space>
|
||||
<Button onClick={() => resetMappingForm()}>
|
||||
新建映射
|
||||
</Button>
|
||||
</Space>
|
||||
<Space wrap style={{ width: '100%' }}>
|
||||
<Input placeholder="内部 SKU,例如 套装-兔兔白日梦" value={mappingSku} onChange={(event) => setMappingSku(event.target.value)} style={{ width: 260 }} />
|
||||
<Input placeholder="活动批次,例如 douyu-2026-11-return" value={mappingCampaignKey} onChange={(event) => setMappingCampaignKey(event.target.value)} style={{ width: 260 }} />
|
||||
<Input placeholder="活动名称,例如 11 月返场" value={mappingCampaignName} onChange={(event) => setMappingCampaignName(event.target.value)} style={{ width: 220 }} />
|
||||
</Space>
|
||||
<Space.Compact style={{ width: '100%' }}>
|
||||
<Select
|
||||
showSearch
|
||||
@@ -1642,10 +1887,18 @@ export default function PlatformFulfillmentPage() {
|
||||
placeholder={mappingGoodsLoading ? '正在加载斗鱼活动商品…' : '选择斗鱼精英宝典商品'}
|
||||
value={mappingGoodsId || undefined}
|
||||
onChange={selectGoods}
|
||||
options={goods.map((item) => ({
|
||||
value: item.commodity_id,
|
||||
label: `${item.name || item.commodity_id} · ${item.score ?? '-'} 积分`,
|
||||
}))}
|
||||
options={[
|
||||
...goods.map((item) => ({
|
||||
value: item.commodity_id,
|
||||
label: `${item.name || item.commodity_id} · ${item.score ?? '-'} 积分`,
|
||||
})),
|
||||
...(mappingGoodsId && !goods.some((item) => item.commodity_id === mappingGoodsId)
|
||||
? [{
|
||||
value: mappingGoodsId,
|
||||
label: `${mappingGoodsName || mappingGoodsId} · 当前已缓存`,
|
||||
}]
|
||||
: []),
|
||||
]}
|
||||
notFoundContent={mappingGoodsLoading ? null : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无活动商品" />}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
@@ -1653,12 +1906,35 @@ export default function PlatformFulfillmentPage() {
|
||||
刷新商品
|
||||
</Button>
|
||||
</Space.Compact>
|
||||
<Space>
|
||||
<Space wrap>
|
||||
<Text>销售模式</Text>
|
||||
<Select
|
||||
value={mappingSaleMode}
|
||||
options={Object.entries(SALE_MODE_LABELS).map(([value, label]) => ({ value, label }))}
|
||||
onChange={setMappingSaleMode}
|
||||
style={{ width: 140 }}
|
||||
/>
|
||||
<Text>所需积分</Text>
|
||||
<InputNumber min={0} value={mappingPoints} onChange={(value) => setMappingPoints(value)} />
|
||||
<Text>启用</Text>
|
||||
<Switch checked={mappingEnabled} onChange={setMappingEnabled} />
|
||||
</Space>
|
||||
<Space wrap>
|
||||
<Text>商品开放时间</Text>
|
||||
<DatePicker
|
||||
showTime
|
||||
value={mappingAvailableFrom}
|
||||
onChange={setMappingAvailableFrom}
|
||||
placeholder="开始时间"
|
||||
/>
|
||||
<Text>至</Text>
|
||||
<DatePicker
|
||||
showTime
|
||||
value={mappingAvailableUntil}
|
||||
onChange={setMappingAvailableUntil}
|
||||
placeholder="结束时间"
|
||||
/>
|
||||
</Space>
|
||||
<Tabs
|
||||
items={[
|
||||
{
|
||||
@@ -1671,16 +1947,79 @@ export default function PlatformFulfillmentPage() {
|
||||
pagination={false}
|
||||
dataSource={mappings}
|
||||
columns={[
|
||||
{ title: '内部 SKU', dataIndex: 'internalSkuKey' },
|
||||
{ title: '商品', dataIndex: 'goodsName' },
|
||||
{ title: '商品 ID', dataIndex: 'commodityId' },
|
||||
{ title: '积分', dataIndex: 'requiredPoints' },
|
||||
{ title: '内部 SKU', dataIndex: 'internalSkuKey', width: 150 },
|
||||
{
|
||||
title: '活动批次',
|
||||
key: 'campaign',
|
||||
width: 170,
|
||||
render: (_: unknown, row) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text>{row.campaignName || row.campaignKey}</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>{row.campaignKey}</Text>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{ title: '商品', dataIndex: 'goodsName', width: 150 },
|
||||
{ title: '商品 ID', dataIndex: 'commodityId', width: 180 },
|
||||
{
|
||||
title: '分类',
|
||||
key: 'saleMode',
|
||||
width: 130,
|
||||
render: (_: unknown, row) => (
|
||||
<Space direction="vertical" size={2}>
|
||||
<Tag color={row.saleMode === 'presale' ? 'gold' : row.saleMode === 'direct' ? 'green' : 'default'}>
|
||||
{SALE_MODE_LABELS[row.saleMode] || row.saleMode}
|
||||
</Tag>
|
||||
<Tag>{AVAILABILITY_LABELS[row.availabilityState] || row.availabilityState}</Tag>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{ title: '积分', dataIndex: 'requiredPoints', width: 80 },
|
||||
{ title: '影响任务', dataIndex: 'affectedTasks', width: 90 },
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'enabled',
|
||||
render: (value: boolean) => <Tag color={value ? 'green' : 'default'}>{value ? '启用' : '停用'}</Tag>,
|
||||
width: 100,
|
||||
render: (value: boolean, row) => (
|
||||
<Tag color={row.archivedAt ? 'default' : value ? 'green' : 'orange'}>
|
||||
{row.archivedAt ? '已归档' : value ? '启用' : '停用'}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'actions',
|
||||
width: 310,
|
||||
render: (_: unknown, row) => (
|
||||
<Space wrap size={4}>
|
||||
<Button size="small" disabled={Boolean(row.archivedAt)} onClick={() => editMapping(row)}>
|
||||
编辑
|
||||
</Button>
|
||||
{row.archivedAt ? (
|
||||
<Button size="small" onClick={() => runMappingAction(row, 'restore')}>
|
||||
恢复
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
size="small"
|
||||
onClick={() => runMappingAction(row, row.enabled ? 'disable' : 'enable')}
|
||||
>
|
||||
{row.enabled ? '停用' : '启用'}
|
||||
</Button>
|
||||
<Button size="small" onClick={() => runMappingAction(row, 'archive')}>
|
||||
归档
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button size="small" danger onClick={() => removeMapping(row)}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
scroll={{ x: 1300 }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user