feat: 支持第三方卡券收到订单后自动核销
This commit is contained in:
@@ -25,6 +25,11 @@ test('默认核销策略:自动发货 5 秒,工单发布或指派后 10 秒
|
||||
mode: 'after_task_created',
|
||||
delaySeconds: 10,
|
||||
})
|
||||
assert.deepEqual(policy.platforms.kuaishou_industry.channels.third_party_voucher, {
|
||||
enabled: true,
|
||||
mode: 'after_order_received',
|
||||
delaySeconds: 5,
|
||||
})
|
||||
})
|
||||
|
||||
test('工单默认策略同时匹配发布和指派,且不匹配链接生成', () => {
|
||||
@@ -59,6 +64,31 @@ test('工单默认策略同时匹配发布和指派,且不匹配链接生成',
|
||||
)
|
||||
})
|
||||
|
||||
test('收到订单后事件可匹配四个渠道,第三方卡券默认延迟 5 秒', () => {
|
||||
const policy = createDefaultVoucherConsumePolicy()
|
||||
for (const channel of [
|
||||
'affiliate_dash',
|
||||
'work_order',
|
||||
'manual',
|
||||
'third_party_voucher',
|
||||
] as const) {
|
||||
const configured = structuredClone(policy)
|
||||
configured.platforms.kuaishou_industry.channels[channel] = {
|
||||
enabled: true,
|
||||
mode: 'after_order_received',
|
||||
delaySeconds: channel === 'third_party_voucher' ? 5 : 15,
|
||||
}
|
||||
const resolved = resolveVoucherConsumePolicy({
|
||||
provider: 'kuaishou_industry',
|
||||
channel,
|
||||
event: 'order_received',
|
||||
policy: configured,
|
||||
})
|
||||
assert.equal(resolved.enabled, true)
|
||||
assert.equal(resolved.delaySeconds, channel === 'third_party_voucher' ? 5 : 15)
|
||||
}
|
||||
})
|
||||
|
||||
test('策略归一化会丢弃非法模式并限制延迟范围', () => {
|
||||
const policy = normalizeVoucherConsumePolicy({
|
||||
enabled: true,
|
||||
@@ -83,3 +113,53 @@ test('策略归一化会丢弃非法模式并限制延迟范围', () => {
|
||||
})
|
||||
assert.equal(policy.platforms.douyin_mashida.enabled, true)
|
||||
})
|
||||
|
||||
test('旧版第三方卡券停用配置自动升级为收到订单后 5 秒', () => {
|
||||
const policy = normalizeVoucherConsumePolicy({
|
||||
enabled: true,
|
||||
platforms: {
|
||||
kuaishou_industry: {
|
||||
enabled: true,
|
||||
channels: {
|
||||
third_party_voucher: {
|
||||
enabled: false,
|
||||
mode: 'manual',
|
||||
delaySeconds: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
assert.equal(policy.version, 2)
|
||||
assert.deepEqual(policy.platforms.kuaishou_industry.channels.third_party_voucher, {
|
||||
enabled: true,
|
||||
mode: 'after_order_received',
|
||||
delaySeconds: 5,
|
||||
})
|
||||
})
|
||||
|
||||
test('新版明确关闭第三方卡券时继续尊重用户配置', () => {
|
||||
const policy = normalizeVoucherConsumePolicy({
|
||||
version: 2,
|
||||
enabled: true,
|
||||
platforms: {
|
||||
kuaishou_industry: {
|
||||
enabled: true,
|
||||
channels: {
|
||||
third_party_voucher: {
|
||||
enabled: false,
|
||||
mode: 'manual',
|
||||
delaySeconds: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
assert.deepEqual(policy.platforms.kuaishou_industry.channels.third_party_voucher, {
|
||||
enabled: false,
|
||||
mode: 'manual',
|
||||
delaySeconds: 0,
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user