修复履约路由总开关关闭后仍回退默认配置自动发货:总开关关闭即停止自动履约

This commit is contained in:
yml2213
2026-08-08 14:56:28 +08:00
parent 23b3711e64
commit 2b3954d0e3
2 changed files with 21 additions and 7 deletions
@@ -6,6 +6,22 @@ import {
resolveFulfillmentRoute,
} from './routing-config-service.js'
test('resolveFulfillmentRoute 总开关关闭后不再回退默认配置,返回未选中', () => {
const result = resolveFulfillmentRoute({
productName: '测试商品',
candidates: [
{ executorKey: 'kuaishou_ct_assisted', available: true },
{ executorKey: 'kuaishou_feifei', available: true },
],
config: normalizeFulfillmentRoutingConfig({
enabled: false,
}),
})
assert.equal(result.selectedExecutorKey, '')
assert.equal(result.reason, '履约路由未启用,自动发货已停止')
})
test('resolveFulfillmentRoute 默认保持 kuaishou-lewan 优先', () => {
const result = resolveFulfillmentRoute({
productName: '测试商品',
@@ -149,12 +149,9 @@ export function resolveFulfillmentRoute({
const skipped: FulfillmentRouteResult['skipped'] = []
if (normalizedConfig.enabled === false) {
return resolveByExecutorPriority({
priority: DEFAULT_EXECUTOR_PRIORITY,
candidates: normalizedCandidates,
config: createDefaultFulfillmentRoutingConfig(),
skipped,
reasonPrefix: '履约路由未启用,使用历史顺序',
// 总开关关闭 = 停止自动履约:不再回退默认配置,订单进入待补全队列(isConfigured=false
return createEmptyRouteResult(normalizedCandidates, skipped, {
reason: '履约路由未启用,自动发货已停止',
})
}
@@ -355,11 +352,12 @@ function createSelectedRouteResult({
function createEmptyRouteResult(
candidates: FulfillmentRoutingCandidate[],
skipped: FulfillmentRouteResult['skipped'],
options: { reason?: string } = {},
): FulfillmentRouteResult {
return {
selectedExecutorKey: '',
selectedRuleId: '',
reason: '',
reason: options.reason || '',
matchedRule: null,
candidates,
skipped,