优化履约匹配:指定匹配(91中文名→sku映射)最高优先 + 映射键归一化
- 91 商品编码全部为中文名(幸运币90个等),运营按中文名→affiliate_dash sku 配置显式映射 - resolveFulfillmentRoute 新增 preferredExecutorKey:映射命中强制优先(规则之前),停用/不可用回退原逻辑 - matchAffiliateDashSku 归一化:NFKC 全角→半角、去空白、小写,先精确再遍历 - preferredMatchEnabled 配置(默认 true,可一键回退,不耽误现有 cloud/feifei 生产) - 测试 +9(221 全绿);行为验证:映射命中/全角/空格命中,未映射回退
This commit is contained in:
@@ -89,3 +89,71 @@ test('resolveFulfillmentRoute 商品规则可以强制转人工', () => {
|
||||
assert.equal(result.selectedExecutorKey, 'manual_dispatch')
|
||||
assert.equal(result.reason, '命中商品路由规则')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 指定匹配(显式映射)最高优先', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: 'affiliate_dash',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true, reason: 'cloud 名字命中' },
|
||||
{ executorKey: 'kuaishou_feifei', available: true, reason: 'feifei 名字命中' },
|
||||
{ executorKey: 'affiliate_dash', available: true },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'affiliate_dash')
|
||||
assert.equal(result.reason, '命中指定匹配(显式映射),优先选择')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 指定匹配命中但通道停用时回退全局优先级', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: 'affiliate_dash',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: true },
|
||||
{ executorKey: 'affiliate_dash', available: true },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({
|
||||
executors: {
|
||||
affiliate_dash: { enabled: false },
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.ok(result.skipped.some((item) => item.executorKey === 'affiliate_dash'))
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 指定匹配命中但商品不可用时回退全局优先级', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: 'affiliate_dash',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: false },
|
||||
{ executorKey: 'affiliate_dash', available: false, reason: '未命中 sku 映射' },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.ok(result.skipped.some((item) => item.executorKey === 'affiliate_dash'))
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 无指定匹配时按全局优先级选择', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: '',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: false },
|
||||
{ executorKey: 'affiliate_dash', available: true },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.equal(result.reason, '按全局优先级命中')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user