feat(cost-center): 支持删除第三方卡券商品
This commit is contained in:
@@ -291,6 +291,25 @@ test('成本模型与商品来源必须覆盖第三方卡券渠道', () => {
|
||||
assert.ok(productSourceFilterSql(1).includes("'tpv:%'"))
|
||||
})
|
||||
|
||||
test('第三方卡券删除:无历史引用硬删除,有历史引用自动归档并停用规则', async () => {
|
||||
const { readFile } = await import('node:fs/promises')
|
||||
const [serviceSource, routeSource] = await Promise.all([
|
||||
readFile(new URL('./product-catalog-service.ts', import.meta.url), 'utf8'),
|
||||
readFile(new URL('../../routes/admin/cost-center-catalog.ts', import.meta.url), 'utf8'),
|
||||
])
|
||||
const start = serviceSource.indexOf('export async function deleteAdminVoucherProduct')
|
||||
const end = serviceSource.indexOf('/**\n * 批量归档旧人工归一商品', start)
|
||||
const body = serviceSource.slice(start, end)
|
||||
|
||||
assert.ok(body.includes('withTransaction'), '卡券删除必须在事务内完成')
|
||||
assert.ok(body.includes("action: 'archived'"), '有历史引用时必须自动归档')
|
||||
assert.ok(body.includes("status = 'archived'"), '归档必须保留商品和历史成本')
|
||||
assert.ok(body.includes('UPDATE channel_product_mappings'), '归档后必须停用旧映射,避免继续命中')
|
||||
assert.ok(body.includes('DELETE FROM cost_versions'), '无历史引用时应清理采购价版本')
|
||||
assert.ok(body.includes("channel = 'third_party_voucher'"), '必须停用对应卡券渠道规则')
|
||||
assert.ok(routeSource.includes("'/cost-center/voucher-products/:productId'"))
|
||||
})
|
||||
|
||||
test('人工客服筛选排除已有其他主渠道的旧 man 商品', () => {
|
||||
const sql = productSourceFilterSql(1)
|
||||
assert.ok(sql.includes(`$1 = 'manual'`))
|
||||
|
||||
Reference in New Issue
Block a user