From 70ad3153a17a6b19b84864188c449bbffce624e6 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 6 Jul 2026 17:16:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E5=8E=9F?= =?UTF-8?q?=E8=B4=A7=E4=B8=BB=E7=AD=96=E7=95=A5=E8=AF=BB=E5=8F=96=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E9=94=99=E8=AF=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/systems/delivery_order.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/service/systems/delivery_order.js b/app/service/systems/delivery_order.js index c16d86b..d35b0c6 100644 --- a/app/service/systems/delivery_order.js +++ b/app/service/systems/delivery_order.js @@ -317,15 +317,17 @@ class DeliveryOrderService extends Service { * * 优先级: * 1. 先匹配平台列表里的基础平台项; - * 2. 再匹配平台列表里的系统设置项。 + * 2. 再匹配平台列表里的系统设置项; + * 3. 兜底:签约策略 default_platform_code(货主-仓库级)→ 货主 subject_config.default_platform_code。 * * @param {string} sourcePlatformCode 外部平台编码。 * @param {Object} storeSubjectConfig 货主签约配置。 + * @param {Object} [policyConfig={}] 货主-仓库签约策略配置。 * @param {Object} [info={}] 上下文信息。 * @param {Array} [operationLogs=[]] 待写入的操作日志数组。 * @return {Promise} 平台快照。 */ - async resolvePlatformSnapshot(sourcePlatformCode, storeSubjectConfig, info = {}, operationLogs = []) { + async resolvePlatformSnapshot(sourcePlatformCode, storeSubjectConfig, policyConfig = {}, info = {}, operationLogs = []) { const platformList = await this.ctx.service.systems.platform.getPlatformList( false, false, @@ -348,24 +350,29 @@ class DeliveryOrderService extends Service { sourcePlatformCode: externalCode, }); - const defaultCode = String(storeSubjectConfig && storeSubjectConfig.default_platform_code || '').trim(); + // 兜底优先级:签约策略(货主-仓库级)→ 货主 subject_config + const policyDefaultCode = String(policyConfig && policyConfig.default_platform_code || '').trim(); + const ownerDefaultCode = String(storeSubjectConfig && storeSubjectConfig.default_platform_code || '').trim(); + const defaultCode = policyDefaultCode || ownerDefaultCode; const fallbackPlatform = defaultCode ? this.findPlatformOptionByCode(platformList, defaultCode) : null; const fallbackPlatformName = this.getPlatformSnapshotName(fallbackPlatform) || defaultCode; if (defaultCode) { + const fallbackSource = policyDefaultCode ? 'policy_config' : 'subject_config'; this.appendOrderOperationLog( operationLogs, ORDER_OPERATION_CODES.PLATFORM_FALLBACK, - `平台编码${externalCode}匹配不到平台,已转为默认平台:${fallbackPlatformName}` + `平台编码${externalCode}匹配不到平台,已转为默认平台:${fallbackPlatformName}(来源:${fallbackSource})` ); if (fallbackPlatform) { - this.ctx.logger.warn('[DeliveryOrderService.prepareOrderData] platform code fallback to store default', { + this.ctx.logger.warn('[DeliveryOrderService.prepareOrderData] platform code fallback to default', { deliveryOrderCode: info.deliveryOrderCode, warehouseId: info.warehouseId, storeId: info.storeId, sourcePlatformCode: externalCode, defaultPlatformCode: defaultCode, + fallbackSource, }); return { @@ -1020,7 +1027,7 @@ class DeliveryOrderService extends Service { const storeSubjectConfig = await this.getStoreSubjectConfig(info.storeId); const policyConfig = await this.getStoreWarehousePolicyConfig(info.storeId, info.warehouseId); const enableExternalExpressCode = this.resolveEnableExternalExpressCode(storeSubjectConfig, policyConfig); - const platformSnapshot = await this.resolvePlatformSnapshot(sourcePlatformCode, storeSubjectConfig, { + const platformSnapshot = await this.resolvePlatformSnapshot(sourcePlatformCode, storeSubjectConfig, policyConfig, { deliveryOrderCode, warehouseId: info.warehouseId, storeId: info.storeId,