feat(fulfillment): 增加未命中渠道兜底核销

This commit is contained in:
yml2213
2026-11-06 19:21:41 +08:00
parent e85bbee7e0
commit 0a595acfa9
9 changed files with 200 additions and 13 deletions
@@ -30,6 +30,11 @@ test('默认核销策略:自动发货 5 秒,工单发布或指派后 10 秒
mode: 'after_order_received',
delaySeconds: 5,
})
assert.deepEqual(policy.platforms.kuaishou_industry.channels.unmatched, {
enabled: false,
mode: 'after_order_received',
delaySeconds: 5,
})
})
test('工单默认策略同时匹配发布和指派,且不匹配链接生成', () => {
@@ -163,3 +168,24 @@ test('新版明确关闭第三方卡券时继续尊重用户配置', () => {
delaySeconds: 0,
})
})
test('旧配置自动补齐未命中渠道兜底,并支持手动开启', () => {
const legacy = normalizeVoucherConsumePolicy({ version: 2, enabled: true })
assert.equal(legacy.platforms.douyin_mashida.channels.unmatched.enabled, false)
const enabled = structuredClone(legacy)
enabled.platforms.douyin_mashida.channels.unmatched = {
enabled: true,
mode: 'after_order_received',
delaySeconds: 12,
}
assert.deepEqual(
resolveVoucherConsumePolicy({
provider: 'douyin_mashida',
channel: 'unmatched',
event: 'order_received',
policy: enabled,
}),
{ enabled: true, delaySeconds: 12, mode: 'after_order_received' },
)
})