From 9ad0b9f4c3f139f6b24c284023de5da49524bc83 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Wed, 23 Sep 2026 21:58:01 +0800 Subject: [PATCH] dedupe FBA destinations before route selection --- scripts/admin-test-env-modules/orders.mjs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/admin-test-env-modules/orders.mjs b/scripts/admin-test-env-modules/orders.mjs index b91b70c02..0594cbb1f 100644 --- a/scripts/admin-test-env-modules/orders.mjs +++ b/scripts/admin-test-env-modules/orders.mjs @@ -278,6 +278,12 @@ async function loadMasterData(context, merchantToken) { if (receivings.length === 0 || (destinationType !== 'PRIVATE' && destinations.length === 0)) { throw new Error('缺少创建测试订单所需的收货仓或目的仓') } + // The warehouse page can contain repeated rows for the same business code. + // Collapse those rows before applying a deterministic route offset; otherwise + // a producer intended for the second FBA destination can silently reuse ABE4. + if (destinationType !== 'PRIVATE') { + destinations = [...new Map(destinations.map(value => [String(value.warehouseCode).trim().toUpperCase(), value])).values()] + } let pricingResult if (fixedRoute.originWarehouseName && (fixedRoute.channelCode || fixedRoute.channelName)) { @@ -308,7 +314,8 @@ async function loadMasterData(context, merchantToken) { .map((rate) => String(rate.destinationCode || '').trim()).filter(Boolean)) const eligible = destinations.filter((destination) => pricedCodes.has(String(destination.warehouseCode))) if (eligible.length < 1) throw new Error(`固定渠道没有可计价目的仓: ${destinationType}`) - const destination = eligible[Number(fixedRoute.destinationIndex || 0) % eligible.length] + const distinctEligible = [...new Map(eligible.map(value => [String(value.warehouseCode).trim().toUpperCase(), value])).values()] + const destination = distinctEligible[Number(fixedRoute.destinationIndex || 0) % distinctEligible.length] const result = await findPricedOrderRoute({ receiving, destinations: [destination], channels: [selectedChannel], estimate: (body) => request(context, 'POST', '/api/merchant/v1/first-leg/pricing/estimate', body, merchantToken), @@ -336,7 +343,9 @@ async function loadMasterData(context, merchantToken) { response: channelsResponse, attempts: 0, failures: [], originFailures: [] } } else { const result = await findPricedOrderRoute({ - receiving, destinations: rotate(destinations, Math.floor(Number(fixedRoute.randomIndex) / 17)), + receiving, + destinations: rotate(destinations, Number.isFinite(Number(fixedRoute.destinationIndex)) + ? Number(fixedRoute.destinationIndex) : Math.floor(Number(fixedRoute.randomIndex) / 17)), channels, estimate: (body) => request(context, 'POST', '/api/merchant/v1/first-leg/pricing/estimate', body, merchantToken), destinationType,