From 2b3954d0e35dba47ffa8b84e0f8369e6c19e7b5a Mon Sep 17 00:00:00 2001 From: yml2213 Date: Sat, 8 Aug 2026 14:56:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B1=A5=E7=BA=A6=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E6=80=BB=E5=BC=80=E5=85=B3=E5=85=B3=E9=97=AD=E5=90=8E?= =?UTF-8?q?=E4=BB=8D=E5=9B=9E=E9=80=80=E9=BB=98=E8=AE=A4=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8F=91=E8=B4=A7=EF=BC=9A=E6=80=BB=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E5=85=B3=E9=97=AD=E5=8D=B3=E5=81=9C=E6=AD=A2=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=B1=A5=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fulfillment/routing-config-service.test.ts | 16 ++++++++++++++++ .../fulfillment/routing-config-service.ts | 12 +++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/apps/backend/src/services/fulfillment/routing-config-service.test.ts b/apps/backend/src/services/fulfillment/routing-config-service.test.ts index 1cc2a4f1..c83c1a4b 100644 --- a/apps/backend/src/services/fulfillment/routing-config-service.test.ts +++ b/apps/backend/src/services/fulfillment/routing-config-service.test.ts @@ -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: '测试商品', diff --git a/apps/backend/src/services/fulfillment/routing-config-service.ts b/apps/backend/src/services/fulfillment/routing-config-service.ts index 8bd220a0..c6cedde2 100644 --- a/apps/backend/src/services/fulfillment/routing-config-service.ts +++ b/apps/backend/src/services/fulfillment/routing-config-service.ts @@ -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,