fix(fulfillment): 收口渠道商品与统一结算边界
This commit is contained in:
@@ -434,7 +434,10 @@ export async function assignPendingOrderItemChannels(
|
||||
.filter((id) => id > 0)
|
||||
.slice(0, 2000)
|
||||
result.assigned += assignedItemIds.length
|
||||
result.assignedItemIds = assignedItemIds
|
||||
result.assignedItemIds = [...new Set([...result.assignedItemIds, ...assignedItemIds])].slice(
|
||||
0,
|
||||
2000,
|
||||
)
|
||||
await scheduleVoucherConsumeForOrderItems(assignedItemIds, 'order_received').catch(
|
||||
(error) => {
|
||||
logWarn('[channel-assign]', '订单收到后安排自动核销失败', {
|
||||
|
||||
@@ -16,6 +16,10 @@ const currentAttemptMigration = readFileSync(
|
||||
new URL('../../db/migrations/138_fulfillment_current_attempt.sql', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const currentLatestMigration = readFileSync(
|
||||
new URL('../../db/migrations/145_fulfillment_current_attempt_latest.sql', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
test('自动发货历史非活跃任务默认阻止后台自动重开', () => {
|
||||
assert.ok(carrierCreation.includes('INACTIVE_CARRIER_TASK_STATUSES.includes'))
|
||||
@@ -55,3 +59,9 @@ test('创建新履约尝试时自动退休旧当前尝试', () => {
|
||||
assert.ok(taskRepo.includes('$26, TRUE'))
|
||||
assert.ok(taskRepo.includes('SELECT id FROM order_items WHERE id = $1 FOR UPDATE'))
|
||||
})
|
||||
|
||||
test('当前尝试必须是同单元最新任务,统一视图不能读到已退休尝试', () => {
|
||||
assert.ok(currentLatestMigration.includes('assert_fulfillment_current_is_latest'))
|
||||
assert.ok(currentLatestMigration.includes('newer.id > COALESCE(NEW.id, 0)'))
|
||||
assert.ok(currentLatestMigration.includes("ERRCODE = '23514'"))
|
||||
})
|
||||
|
||||
@@ -10,6 +10,10 @@ const auditScript = readFileSync(
|
||||
new URL('../../../scripts/audit-fulfillment-state.ts', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const configSyncMigration = readFileSync(
|
||||
new URL('../../db/migrations/144_fulfillment_shadow_configuration_sync.sql', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
test('正式履约影子模型包含履约、尝试和异常三张表', () => {
|
||||
assert.ok(migration.includes('CREATE TABLE IF NOT EXISTS fulfillments'))
|
||||
@@ -27,6 +31,18 @@ test('影子模型从现有真源回填并持续双写', () => {
|
||||
assert.ok(migration.includes('assign_fulfillment_event_shadow'))
|
||||
})
|
||||
|
||||
test('人工配置和统一渠道规则变化会刷新履约影子', () => {
|
||||
assert.ok(configSyncMigration.includes('trg_manual_fulfillment_config_shadow'))
|
||||
assert.ok(configSyncMigration.includes('trg_internal_sku_channel_shadow'))
|
||||
assert.ok(configSyncMigration.includes('sync_fulfillment_shadow(item.id)'))
|
||||
})
|
||||
|
||||
test('人工履约配置不能关联其他来源商品', () => {
|
||||
assert.ok(configSyncMigration.includes('trg_manual_config_product_source'))
|
||||
assert.ok(configSyncMigration.includes("product.canonical_sku LIKE 'man:%'"))
|
||||
assert.ok(configSyncMigration.includes("ERRCODE = '23514'"))
|
||||
})
|
||||
|
||||
test('明确渠道即视为已路由,不用渠道配置缺失覆盖已选渠道', () => {
|
||||
assert.ok(migration.includes('v_fulfillment_item_state_raw'))
|
||||
assert.ok(migration.includes("WHEN raw.intended_channel IS NOT NULL THEN 'configured'"))
|
||||
|
||||
@@ -43,6 +43,10 @@ test('待分类查询使用统一读模型并返回异常数量', () => {
|
||||
assert.ok(channelAssign.includes('issueCategoryInput'))
|
||||
})
|
||||
|
||||
test('批量判渠保留所有批次的即时成本同步订单项', () => {
|
||||
assert.ok(channelAssign.includes('...new Set([...result.assignedItemIds, ...assignedItemIds])'))
|
||||
})
|
||||
|
||||
test('重试必须按可重试 issueCode 限定,不能按整个 SKU 处理售后和复核项', () => {
|
||||
assert.ok(channelAssign.includes('RETRYABLE_CARRIER_ISSUES'))
|
||||
assert.ok(channelAssign.includes('issueCodes?: string[]'))
|
||||
|
||||
Reference in New Issue
Block a user