fix(deliveryOrder): resolveExpressSnapshot 兜底读取 policy_config.default_express_code
- 修复前只读 store.subject_config.default_express_code,导致 subject_config 为 NULL 时始终命中默认 STO - 修复后货主 subject_config 优先,未配置时兜底读仓库 policy_config.default_express_code - 解决广州趣电贸易等 subject_config 为空的货主无法使用仓库级 ZTO 配置的问题 - 新增 resolveExpressSnapshot 单测 14 个用例全覆盖两大分支
This commit is contained in:
parent
da56253d4a
commit
fbb12cf205
@ -484,21 +484,35 @@ class DeliveryOrderService extends Service {
|
||||
/**
|
||||
* 解析订单快递快照。
|
||||
*
|
||||
* 优先级:
|
||||
* 1. 先读取是否启用外部快递编码开关;
|
||||
* 2. 开关关闭时,直接使用货主默认快递回填四个快递字段;
|
||||
* 3. 开关开启时,先匹配 wms_express_setting,再匹配 wms_express,最后回退货主默认快递。
|
||||
* 默认快递编码优先级:
|
||||
* 1. storeSubjectConfig.default_express_code(货主级,个性化配置)
|
||||
* 2. policyConfig.default_express_code(仓库级,通用配置)
|
||||
*
|
||||
* 分支路由:
|
||||
* 1. 先读取是否启用外部快递编码开关;
|
||||
* 2. 开关关闭时,直接使用上述优先级的默认快递回填四个快递字段;
|
||||
* 3. 开关开启时,先匹配 wms_express_setting,再匹配 wms_express,最后回退默认快递。
|
||||
*
|
||||
* @param {string} logisticsCode 外部快递编码。
|
||||
* @param {Object} storeSubjectConfig 货主签约配置。
|
||||
* @param {Object} [info={}] 上下文信息。
|
||||
* @param {Object} [info={}] 上下文信息,可含 policyConfig / enableExternalExpressCode / warehouseId。
|
||||
* @param {Array<Object>} [operationLogs=[]] 待写入的操作日志数组。
|
||||
* @return {Promise<Object>} 快递快照。
|
||||
*/
|
||||
async resolveExpressSnapshot(logisticsCode, storeSubjectConfig, info = {}, operationLogs = []) {
|
||||
const expressList = await this.ctx.service.systems.express.getExpressList();
|
||||
const externalCode = String(logisticsCode || '').trim();
|
||||
const defaultCode = String(storeSubjectConfig && storeSubjectConfig.default_express_code || '').trim();
|
||||
|
||||
// 货主 subject_config 优先于仓库 policy_config(货主个性配置高于仓库通用配置)
|
||||
const policyConfig = info && info.policyConfig && typeof info.policyConfig === 'object'
|
||||
? info.policyConfig
|
||||
: {};
|
||||
const defaultCode = String(
|
||||
(storeSubjectConfig && storeSubjectConfig.default_express_code)
|
||||
|| policyConfig.default_express_code
|
||||
|| ''
|
||||
).trim();
|
||||
|
||||
const fallbackExpress = this.findCodeOption(expressList, defaultCode);
|
||||
const fallbackLogisticsCode = String(
|
||||
fallbackExpress && (fallbackExpress.code || fallbackExpress.value || fallbackExpress.express_code || defaultCode)
|
||||
@ -509,9 +523,6 @@ class DeliveryOrderService extends Service {
|
||||
const explicitEnableExternalExpressCode = info && Object.prototype.hasOwnProperty.call(info, 'enableExternalExpressCode')
|
||||
? info.enableExternalExpressCode
|
||||
: undefined;
|
||||
const policyConfig = info && info.policyConfig && typeof info.policyConfig === 'object'
|
||||
? info.policyConfig
|
||||
: {};
|
||||
const isEnableExternalExpressCode = this.resolveEnableExternalExpressCode(
|
||||
storeSubjectConfig,
|
||||
policyConfig,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user