feat(fulfillment): 统一中文内部 SKU 履约路由
This commit is contained in:
@@ -34,7 +34,7 @@ import { useEffect, useState } from 'react'
|
||||
import PercentTable from '@/components/common/PercentTable'
|
||||
import FinanceSubNav from '@/components/admin/FinanceSubNav'
|
||||
import {
|
||||
assignChannelBySku,
|
||||
assignChannelByInternalSku,
|
||||
deleteChannelRules,
|
||||
fetchChannelExceptions,
|
||||
fetchChannelRules,
|
||||
@@ -64,6 +64,14 @@ const CHANNEL_COLOR: Record<string, string> = {
|
||||
manual: 'orange',
|
||||
}
|
||||
|
||||
const CHANNEL_SOURCE_LABEL: Record<string, string> = {
|
||||
operator: '运营配置',
|
||||
manual_config: '人工 SKU 配置',
|
||||
voucher: '第三方卡券',
|
||||
capability: '商品能力迁移',
|
||||
backfill: '历史回填',
|
||||
}
|
||||
|
||||
const MATCH_KEY_OPTIONS = [{ value: 'internal_sku', label: '内部 SKU' }]
|
||||
|
||||
export default function AdminFulfillmentChannelPage() {
|
||||
@@ -97,9 +105,7 @@ function PendingPanel() {
|
||||
|
||||
const assignMutation = useMutation({
|
||||
mutationFn: (row: PendingChannelGroup) =>
|
||||
assignChannelBySku({
|
||||
provider: row.provider,
|
||||
shopId: row.shop_id,
|
||||
assignChannelByInternalSku({
|
||||
internalSku: row.internal_sku,
|
||||
channel: selections[rowKey(row)] || '',
|
||||
}),
|
||||
@@ -126,8 +132,19 @@ function PendingPanel() {
|
||||
})
|
||||
|
||||
const columns = [
|
||||
{ title: '来源', dataIndex: 'provider', width: 120 },
|
||||
{ title: '店铺', dataIndex: 'shop_id', width: 140 },
|
||||
{
|
||||
title: '来源',
|
||||
dataIndex: 'providers',
|
||||
width: 120,
|
||||
render: (value: string[] | undefined) => value?.join(' / ') || '-',
|
||||
},
|
||||
{
|
||||
title: '店铺',
|
||||
dataIndex: 'shop_ids',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
render: (value: string[] | undefined) => value?.join(' / ') || '-',
|
||||
},
|
||||
{ title: '内部SKU', dataIndex: 'internal_sku', width: 220 },
|
||||
{
|
||||
title: '平台SKU',
|
||||
@@ -284,7 +301,7 @@ function RulesPanel() {
|
||||
void queryClient.invalidateQueries({ queryKey: ['fulfillment-rules'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['fulfillment-pending'] })
|
||||
},
|
||||
onError: () => message.error('删除规则失败'),
|
||||
onError: (error) => message.error(error instanceof Error ? error.message : '删除规则失败'),
|
||||
})
|
||||
|
||||
function confirmDeleteRules(ids: number[]) {
|
||||
@@ -319,6 +336,19 @@ function RulesPanel() {
|
||||
),
|
||||
},
|
||||
{ title: '优先级', dataIndex: 'priority', width: 90 },
|
||||
{
|
||||
title: '载体参数',
|
||||
width: 220,
|
||||
ellipsis: true,
|
||||
render: (_: unknown, row: ChannelRule) => formatCarrierParams(row),
|
||||
},
|
||||
{
|
||||
title: '来源',
|
||||
dataIndex: 'source',
|
||||
width: 140,
|
||||
render: (value: string) =>
|
||||
CHANNEL_SOURCE_LABEL[value] || (value.startsWith('rule:') ? '规则迁移' : value || '-'),
|
||||
},
|
||||
{
|
||||
title: '启用',
|
||||
dataIndex: 'enabled',
|
||||
@@ -333,6 +363,7 @@ function RulesPanel() {
|
||||
danger
|
||||
size="small"
|
||||
loading={deleteMutation.isPending}
|
||||
disabled={!canDeleteChannelRule(row)}
|
||||
onClick={() => confirmDeleteRules([row.id])}
|
||||
>
|
||||
删除
|
||||
@@ -377,6 +408,7 @@ function RulesPanel() {
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedRuleIds,
|
||||
onChange: (keys) => setSelectedRuleIds(keys.map(Number)),
|
||||
getCheckboxProps: (row: ChannelRule) => ({ disabled: !canDeleteChannelRule(row) }),
|
||||
}}
|
||||
pagination={buildAdminTablePagination({
|
||||
current: query.data?.data?.page || page,
|
||||
@@ -441,11 +473,12 @@ function ExceptionsPanel() {
|
||||
|
||||
const REASON_OPTIONS = [
|
||||
{ value: '', label: '全部' },
|
||||
{ value: 'classification_missing', label: '待分类' },
|
||||
{ value: 'routing_conflict', label: '规则冲突' },
|
||||
{ value: 'routing_conflict', label: '渠道冲突' },
|
||||
{ value: 'product_mapping_missing', label: '未归一' },
|
||||
{ value: 'cost_missing', label: '成本缺失' },
|
||||
{ value: 'manual_config_missing', label: '人工 SKU 未配置' },
|
||||
{ value: 'manual_cost_missing', label: '人工未确认履约' },
|
||||
{ value: 'carrier_missing', label: '缺少履约载体' },
|
||||
]
|
||||
|
||||
const columns = [
|
||||
@@ -469,7 +502,7 @@ function ExceptionsPanel() {
|
||||
|
||||
return (
|
||||
<Card
|
||||
title="问题队列(按 SKU 聚合)"
|
||||
title="问题队列(按中文内部 SKU 聚合)"
|
||||
extra={
|
||||
<Space>
|
||||
<Select
|
||||
@@ -608,5 +641,21 @@ function PipelinesPanel() {
|
||||
}
|
||||
|
||||
function rowKey(row: PendingChannelGroup) {
|
||||
return `${row.provider}|${row.shop_id}|${row.internal_sku}`
|
||||
return row.internal_sku
|
||||
}
|
||||
|
||||
function formatCarrierParams(row: ChannelRule) {
|
||||
const key =
|
||||
row.channel === 'affiliate_dash'
|
||||
? row.config_json.affiliateSku
|
||||
: row.channel === 'work_order'
|
||||
? row.config_json.workRuleKey
|
||||
: row.channel === 'manual'
|
||||
? row.config_json.manualConfigId
|
||||
: row.config_json.voucherSku
|
||||
return key ? String(key) : '待补全'
|
||||
}
|
||||
|
||||
function canDeleteChannelRule(row: ChannelRule) {
|
||||
return row.source === 'operator' || row.source.startsWith('rule:')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user