中性化库存凭据类型

This commit is contained in:
yml
2026-05-25 22:11:30 +08:00
parent 8ce16d9a36
commit 2103416c7b
14 changed files with 42 additions and 28 deletions
@@ -16,7 +16,7 @@ export async function mapAdminInventoryListItem(item: InventoryItemRow): Promise
inventoryItemId: item.id,
skuCode: item.sku_code,
batchNo: item.batch_no,
credentialType: item.credential_type || 'tencent_code',
credentialType: item.credential_type || 'claim_code',
inventoryGroupCode: String(item.inventory_group_code || '').trim(),
displayValue: item.display_value,
status: item.status,
@@ -258,7 +258,7 @@ export async function getAdminTaskDetail(
inventoryItemId: inventoryItem.id,
skuCode: inventoryItem.sku_code,
batchNo: inventoryItem.batch_no,
credentialType: inventoryItem.credential_type || 'tencent_code',
credentialType: inventoryItem.credential_type || 'claim_code',
displayValue: viewerContext.canViewSensitiveTaskData ? inventoryItem.display_value : '',
status: inventoryItem.status,
}
@@ -367,7 +367,7 @@ export async function getAdminInventorySkuSuggestions(
return {
items: items.map((item) => ({
skuCode: String(item.sku_code || '').trim(),
credentialType: String(item.credential_type || '').trim() || 'tencent_code',
credentialType: String(item.credential_type || '').trim() || 'claim_code',
inventoryGroupCode: String(item.inventory_group_code || '').trim(),
totalCount: Number(item.total_count || 0),
availableCount: Number(item.available_count || 0),
@@ -221,7 +221,7 @@ export function mapAdminTaskInventoryBinding(
inventoryStatus: String(binding.inventory_item_status || '').trim(),
skuCode: String(binding.sku_code || '').trim(),
batchNo: String(binding.batch_no || '').trim(),
credentialType: String(binding.credential_type || 'tencent_code').trim() || 'tencent_code',
credentialType: String(binding.credential_type || 'claim_code').trim() || 'claim_code',
displayValue: viewerContext.canViewSensitiveTaskData ? String(binding.display_value || '').trim() : '',
invalidReason: String(binding.invalid_reason || '').trim(),
consumedAt: binding.consumed_at || null,
@@ -35,7 +35,7 @@ export async function createAdminInventoryItem(
const skuCode = String(payload.skuCode || '').trim()
const displayValue = String(payload.displayValue || '').trim()
const batchNo = String(payload.batchNo || '').trim()
const credentialType = String(payload.credentialType || 'tencent_code').trim() || 'tencent_code'
const credentialType = String(payload.credentialType || 'claim_code').trim() || 'claim_code'
const inventoryGroupCode = String(payload.inventoryGroupCode || '').trim()
if (!skuCode || !displayValue) {
@@ -160,7 +160,7 @@ function normalizeInventoryImportRows(payload: AdminInventoryImportInput): Norma
const skuCode = String(row?.skuCode || '').trim()
const displayValue = String(row?.displayValue || '').trim()
const batchNo = String(row?.batchNo || '').trim()
const credentialType = String(row?.credentialType || payload.credentialType || 'tencent_code').trim() || 'tencent_code'
const credentialType = String(row?.credentialType || payload.credentialType || 'claim_code').trim() || 'claim_code'
const inventoryGroupCode = String(row?.inventoryGroupCode || payload.inventoryGroupCode || '').trim()
if (!skuCode || !displayValue) {
@@ -174,7 +174,7 @@ function normalizeInventoryImportRows(payload: AdminInventoryImportInput): Norma
if (bulkCodes.length > 0) {
const skuCode = String(payload.skuCode || '').trim()
const batchNo = String(payload.batchNo || '').trim()
const credentialType = String(payload.credentialType || 'tencent_code').trim() || 'tencent_code'
const credentialType = String(payload.credentialType || 'claim_code').trim() || 'claim_code'
const inventoryGroupCode = String(payload.inventoryGroupCode || '').trim()
if (!skuCode) {
@@ -201,7 +201,7 @@ function dedupeRows(rows: NormalizedInventoryImportRow[]): NormalizedInventoryIm
const output: NormalizedInventoryImportRow[] = []
for (const row of rows) {
const key = `${row.skuCode}::${row.credentialType || 'tencent_code'}::${row.displayValue}`
const key = `${row.skuCode}::${row.credentialType || 'claim_code'}::${row.displayValue}`
if (seen.has(key)) {
continue
}
@@ -37,7 +37,7 @@ function createTaskFixture(patch = {}) {
inventorySkuCode: 'dnf-cdk-a',
primaryRequirement: {
roleKey: 'primary_code',
credentialType: 'tencent_code',
credentialType: 'claim_code',
},
}),
...patch,
@@ -65,7 +65,7 @@ test('syncDeliveryTasksForOrderWithDeps moves paid claim task to waiting invento
{
skuCode: 'dnf-cdk-a',
taskId: 30,
credentialType: 'tencent_code',
credentialType: 'claim_code',
roleKey: 'primary_code',
},
])
@@ -201,7 +201,7 @@ export async function syncDeliveryTasksForOrderWithDeps(
primaryRequirement: primaryRequirement
? {
roleKey: String(primaryRequirement.role_key || primaryRequirement.roleKey || 'primary_code'),
credentialType: String(primaryRequirement.credential_type || primaryRequirement.credentialType || 'tencent_code'),
credentialType: String(primaryRequirement.credential_type || primaryRequirement.credentialType || 'claim_code'),
}
: null,
kuaishouCloudFulfillment: isKuaishouCloudExecutor(profile.executor_key)
@@ -41,7 +41,7 @@ test('reserveInventoryForTaskWithDeps reserves first available inventory item wi
)
assert.deepEqual(calls, [
['find', 'dnf-cdk-a', 'tencent_code', null],
['find', 'dnf-cdk-a', 'claim_code', null],
['assign', 321, 88, '2026-04-14T12:00:00.000Z', 'primary_code'],
])
assert.equal(result?.id, 321)
@@ -64,7 +64,7 @@ test('reserveInventoryForTaskWithDeps forwards inventory group filters', async (
)
assert.deepEqual(calls, [
['find', 'dnf-cdk-a', 'tencent_code', ['A组', 'B组']],
['find', 'dnf-cdk-a', 'claim_code', ['A组', 'B组']],
])
})
@@ -42,7 +42,7 @@ type ReleaseReservedInventoryItemsDeps = {
export async function reserveInventoryForTask({
skuCode,
taskId,
credentialType = 'tencent_code',
credentialType = 'claim_code',
roleKey = 'primary_code',
inventoryGroupCodes = null,
}: ReserveInventoryForTaskInput): Promise<InventoryItemRow | null> {
@@ -60,7 +60,7 @@ export async function reserveInventoryForTaskWithDeps(
{
skuCode,
taskId,
credentialType = 'tencent_code',
credentialType = 'claim_code',
roleKey = 'primary_code',
inventoryGroupCodes = null,
}: ReserveInventoryForTaskInput,