fix(fulfillment): 持久化订单项已配置快照
This commit is contained in:
@@ -55,6 +55,7 @@ test('下单决策:自动发货只从统一 SKU 配置生成任务路由', ()
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert.equal(item.isConfigured, true)
|
assert.equal(item.isConfigured, true)
|
||||||
|
assert.equal(item.snapshot.isConfigured, true)
|
||||||
assert.equal(item.skuCode, 'lucky_coin_x2')
|
assert.equal(item.skuCode, 'lucky_coin_x2')
|
||||||
assert.equal(item.snapshot.internalSkuChannel, 'affiliate_dash')
|
assert.equal(item.snapshot.internalSkuChannel, 'affiliate_dash')
|
||||||
assert.deepEqual(item.snapshot.fulfillmentRoute, {
|
assert.deepEqual(item.snapshot.fulfillmentRoute, {
|
||||||
@@ -84,6 +85,7 @@ test('下单决策:自动发货缺载体参数时不建任何任务', () => {
|
|||||||
plan(channel({ internal_sku: '不存在商品' })),
|
plan(channel({ internal_sku: '不存在商品' })),
|
||||||
)
|
)
|
||||||
assert.equal(item.isConfigured, false)
|
assert.equal(item.isConfigured, false)
|
||||||
|
assert.equal(item.snapshot.isConfigured, false)
|
||||||
assert.equal(item.snapshot.internalSkuChannelReason, 'missing_affiliate_dash_mapping')
|
assert.equal(item.snapshot.internalSkuChannelReason, 'missing_affiliate_dash_mapping')
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -93,6 +95,7 @@ test('下单决策:人工渠道只有配置存在时才建人工任务', () =>
|
|||||||
plan(channel({ channel: 'manual', config_json: { manualConfigId: 9 } })),
|
plan(channel({ channel: 'manual', config_json: { manualConfigId: 9 } })),
|
||||||
)
|
)
|
||||||
assert.equal(ready.isConfigured, true)
|
assert.equal(ready.isConfigured, true)
|
||||||
|
assert.equal(ready.snapshot.isConfigured, true)
|
||||||
assert.equal(
|
assert.equal(
|
||||||
(ready.snapshot.fulfillmentRoute as Record<string, unknown>).selectedExecutorKey,
|
(ready.snapshot.fulfillmentRoute as Record<string, unknown>).selectedExecutorKey,
|
||||||
'manual_dispatch',
|
'manual_dispatch',
|
||||||
@@ -103,6 +106,7 @@ test('下单决策:人工渠道只有配置存在时才建人工任务', () =>
|
|||||||
plan(channel({ channel: 'manual', config_json: {} })),
|
plan(channel({ channel: 'manual', config_json: {} })),
|
||||||
)
|
)
|
||||||
assert.equal(missing.isConfigured, false)
|
assert.equal(missing.isConfigured, false)
|
||||||
|
assert.equal(missing.snapshot.isConfigured, false)
|
||||||
assert.equal(missing.snapshot.internalSkuChannelReason, 'manual_config_missing')
|
assert.equal(missing.snapshot.internalSkuChannelReason, 'manual_config_missing')
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -113,6 +117,7 @@ test('下单决策:接单平台和卡券不提前建任务', () => {
|
|||||||
plan(channel({ channel: targetChannel, config_json: {} })),
|
plan(channel({ channel: targetChannel, config_json: {} })),
|
||||||
)
|
)
|
||||||
assert.equal(item.isConfigured, false)
|
assert.equal(item.isConfigured, false)
|
||||||
|
assert.equal(item.snapshot.isConfigured, false)
|
||||||
assert.equal(item.snapshot.internalSkuChannel, targetChannel)
|
assert.equal(item.snapshot.internalSkuChannel, targetChannel)
|
||||||
assert.equal(
|
assert.equal(
|
||||||
(item.snapshot.fulfillmentRoute as Record<string, unknown>).selectedExecutorKey,
|
(item.snapshot.fulfillmentRoute as Record<string, unknown>).selectedExecutorKey,
|
||||||
@@ -139,6 +144,7 @@ test('下单决策:冲突或无配置时清空旧路由,不能由旧逻辑
|
|||||||
conflicts: [channel()],
|
conflicts: [channel()],
|
||||||
})
|
})
|
||||||
assert.equal(conflict.isConfigured, false)
|
assert.equal(conflict.isConfigured, false)
|
||||||
|
assert.equal(conflict.snapshot.isConfigured, false)
|
||||||
assert.equal(conflict.snapshot.internalSkuChannelReason, 'routing_conflict')
|
assert.equal(conflict.snapshot.internalSkuChannelReason, 'routing_conflict')
|
||||||
assert.equal(
|
assert.equal(
|
||||||
(conflict.snapshot.fulfillmentRoute as Record<string, unknown>).selectedExecutorKey,
|
(conflict.snapshot.fulfillmentRoute as Record<string, unknown>).selectedExecutorKey,
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ function withChannelSnapshot(input: {
|
|||||||
isConfigured: input.configured,
|
isConfigured: input.configured,
|
||||||
snapshot: {
|
snapshot: {
|
||||||
...snapshot,
|
...snapshot,
|
||||||
|
isConfigured: input.configured,
|
||||||
internalSku: input.internalSku,
|
internalSku: input.internalSku,
|
||||||
...(input.source ? { internalSkuChannelSource: input.source } : {}),
|
...(input.source ? { internalSkuChannelSource: input.source } : {}),
|
||||||
...(input.channel !== 'unmatched' ? { internalSkuChannel: input.channel } : {}),
|
...(input.channel !== 'unmatched' ? { internalSkuChannel: input.channel } : {}),
|
||||||
|
|||||||
Reference in New Issue
Block a user