优化履约匹配:指定匹配(91中文名→sku映射)最高优先 + 映射键归一化

- 91 商品编码全部为中文名(幸运币90个等),运营按中文名→affiliate_dash sku 配置显式映射
- resolveFulfillmentRoute 新增 preferredExecutorKey:映射命中强制优先(规则之前),停用/不可用回退原逻辑
- matchAffiliateDashSku 归一化:NFKC 全角→半角、去空白、小写,先精确再遍历
- preferredMatchEnabled 配置(默认 true,可一键回退,不耽误现有 cloud/feifei 生产)
- 测试 +9(221 全绿);行为验证:映射命中/全角/空格命中,未映射回退
This commit is contained in:
yml2213
2026-08-05 16:44:37 +08:00
parent 5f5506bb19
commit 769d41655a
9 changed files with 249 additions and 3 deletions
@@ -137,10 +137,12 @@ export function resolveFulfillmentRoute({
productName,
candidates,
config = getFulfillmentRoutingConfig(),
preferredExecutorKey = '',
}: {
productName: unknown
candidates: FulfillmentRoutingCandidate[]
config?: FulfillmentRoutingConfig
preferredExecutorKey?: string
}): FulfillmentRouteResult {
const normalizedConfig = normalizeFulfillmentRoutingConfig(config)
const normalizedCandidates = normalizeRoutingCandidates(candidates)
@@ -156,6 +158,22 @@ export function resolveFulfillmentRoute({
})
}
// 指定匹配(显式映射)最高优先:命中且通道可用时直接选择,不受全局优先级影响。
const preferred = normalizeExecutorKey(preferredExecutorKey)
if (preferred) {
const selected = resolveExecutorSelection({
executorKey: preferred,
candidates: normalizedCandidates,
config: normalizedConfig,
skipped,
reason: '命中指定匹配(显式映射),优先选择',
matchedRule: null,
})
if (selected.selectedExecutorKey) {
return selected
}
}
const matchedRule = findMatchedRoutingRule(productName, normalizedConfig.rules)
if (matchedRule) {
const selected = resolveExecutorSelection({