refactor(fulfillment): 固化 91 中文名→英文 SKU 权威映射表

91 继续用中文编码;解析优先查内置常量表,配置仅作临时覆盖,Admin 改为展示权威表。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-09-14 20:33:42 +08:00
co-authored by Cursor
parent 745eeaee35
commit 4a3b4ec14d
7 changed files with 159 additions and 40 deletions
@@ -1573,6 +1573,7 @@ function AffiliateDashPlatformPanel() {
const [notifyUrl, setNotifyUrl] = useState('')
const [timestampToleranceSeconds, setTimestampToleranceSeconds] = useState(300)
const [skuRows, setSkuRows] = useState<SkuMappingRow[]>([])
const [builtinSkuRows, setBuiltinSkuRows] = useState<SkuMappingRow[]>([])
const [matchInput, setMatchInput] = useState('')
const [matchResult, setMatchResult] = useState<AdminAffiliateDashMatchResult | null>(null)
const [wallet, setWallet] = useState<AdminAffiliateDashWallet | null>(null)
@@ -1625,6 +1626,12 @@ function AffiliateDashPlatformPanel() {
sku: String(sku || ''),
})),
)
setBuiltinSkuRows(
Object.entries(response.builtinSkuMapping || {}).map(([productNo, sku]) => ({
productNo,
sku: String(sku || ''),
})),
)
}
async function saveConfig() {
@@ -1832,7 +1839,33 @@ function AffiliateDashPlatformPanel() {
</Space>
</Card>
<Card size="small" title="91 商品编码 → affiliate_dash sku 映射">
<Card
size="small"
title={`权威中英映射表(内置 ${builtinSkuRows.length} 条)`}
>
<Typography.Paragraph type="secondary" style={{ marginBottom: 12 }}>
91 店商品编码使用中文名;正式商品请改后端常量表
<Typography.Text code>
apps/backend/.../affiliate-dash/sku-mapping.ts
</Typography.Text>
,与平台商品目录对齐。
</Typography.Paragraph>
<Table<SkuMappingRow>
rowKey={(row) => row.productNo}
size="small"
pagination={{ pageSize: 10, showSizeChanger: false }}
dataSource={builtinSkuRows}
columns={[
{ title: '91 中文编码', dataIndex: 'productNo', key: 'productNo' },
{ title: 'affiliate_dash sku', dataIndex: 'sku', key: 'sku', width: 220 },
]}
/>
</Card>
<Card size="small" title="临时增量覆盖(可选)">
<Typography.Paragraph type="secondary" style={{ marginBottom: 12 }}>
仅用于尚未发版的新商品临时加一行;会覆盖同名权威键。日常运营无需维护。
</Typography.Paragraph>
<Space direction="vertical" style={{ width: '100%' }} size="middle">
{skuRows.map((row, index) => (
<Space key={`${index}_${row.productNo}`} wrap>
@@ -1858,7 +1891,7 @@ function AffiliateDashPlatformPanel() {
icon={<PlusOutlined />}
onClick={() => setSkuRows((rows) => [...rows, { productNo: '', sku: '' }])}
>
新增映射
新增临时覆盖
</Button>
</Space>
</Card>
@@ -8,6 +8,7 @@ export interface AdminAffiliateDashConfig {
notifyUrl: string
timestampToleranceSeconds: number
preferredMatchEnabled: boolean
/** 临时增量覆盖;正式商品请改后端权威常量表 */
skuMapping: Record<string, string>
}
@@ -22,11 +23,15 @@ export interface AdminAffiliateDashEffectiveConfig {
hasAppSecret: boolean
hasCallbackSecret: boolean
skuMappingCount: number
builtinSkuMappingCount?: number
overlaySkuMappingCount?: number
}
export interface AdminAffiliateDashConfigResponse {
source: AdminAffiliateDashConfig
effective: AdminAffiliateDashEffectiveConfig
/** 代码内置权威表(91 中文名 → 英文 sku) */
builtinSkuMapping?: Record<string, string>
}
export interface AdminAffiliateDashMatchResult {