增加分组库存与客服
This commit is contained in:
@@ -64,6 +64,7 @@ export async function createAdminInventoryItem(payload = /** @type {AdminInvento
|
||||
const displayValue = String(payload.displayValue || '').trim()
|
||||
const batchNo = String(payload.batchNo || '').trim()
|
||||
const credentialType = String(payload.credentialType || 'tencent_code').trim() || 'tencent_code'
|
||||
const inventoryGroupCode = String(payload.inventoryGroupCode || '').trim()
|
||||
|
||||
if (!skuCode || !displayValue) {
|
||||
throw createHttpError('缺少 skuCode 或 displayValue', {
|
||||
@@ -79,6 +80,7 @@ export async function createAdminInventoryItem(payload = /** @type {AdminInvento
|
||||
displayValue,
|
||||
batchNo,
|
||||
credentialType,
|
||||
inventoryGroupCode,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
@@ -93,10 +95,11 @@ export async function createAdminInventoryItem(payload = /** @type {AdminInvento
|
||||
|
||||
const { items } = await listInventoryItems({
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
pageSize: 20,
|
||||
skuCode,
|
||||
inventoryGroupCode,
|
||||
})
|
||||
const createdItem = items.find((item) => item.display_value === displayValue) || null
|
||||
const createdItem = items.find((item) => item.display_value === displayValue && item.inventory_group_code === inventoryGroupCode) || null
|
||||
|
||||
return {
|
||||
inventoryItem: createdItem ? await mapAdminInventoryListItem(createdItem) : null,
|
||||
@@ -121,6 +124,7 @@ export async function importAdminInventoryItems(payload = /** @type {AdminInvent
|
||||
batchNo: row.batchNo,
|
||||
displayValue: row.displayValue,
|
||||
credentialType: row.credentialType,
|
||||
inventoryGroupCode: row.inventoryGroupCode,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
}))
|
||||
@@ -538,6 +542,7 @@ export async function retryAdminTask(taskId) {
|
||||
taskId: task.id,
|
||||
credentialType: primaryRequirement?.credentialType || 'tencent_code',
|
||||
roleKey: primaryRequirement?.roleKey || 'primary_code',
|
||||
inventoryGroupCodes: resolveTaskInventoryGroupCodes(task),
|
||||
})
|
||||
|
||||
if (!reserved) {
|
||||
@@ -672,7 +677,7 @@ export async function completeAdminTaskManualDispatch(taskId, payload = {}, sess
|
||||
|
||||
/**
|
||||
* @param {AdminInventoryImportInput} payload
|
||||
* @returns {Array<Required<Pick<AdminInventoryImportRowInput, 'skuCode' | 'displayValue' | 'batchNo' | 'credentialType'>>>}
|
||||
* @returns {Array<Required<Pick<AdminInventoryImportRowInput, 'skuCode' | 'displayValue' | 'batchNo' | 'credentialType' | 'inventoryGroupCode'>>>}
|
||||
*/
|
||||
function normalizeInventoryImportRows(payload) {
|
||||
const rows = []
|
||||
@@ -685,12 +690,13 @@ function normalizeInventoryImportRows(payload) {
|
||||
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 inventoryGroupCode = String(row?.inventoryGroupCode || payload.inventoryGroupCode || '').trim()
|
||||
|
||||
if (!skuCode || !displayValue) {
|
||||
continue
|
||||
}
|
||||
|
||||
rows.push({ skuCode, displayValue, batchNo, credentialType })
|
||||
rows.push({ skuCode, displayValue, batchNo, credentialType, inventoryGroupCode })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,6 +704,7 @@ function normalizeInventoryImportRows(payload) {
|
||||
const skuCode = String(payload.skuCode || '').trim()
|
||||
const batchNo = String(payload.batchNo || '').trim()
|
||||
const credentialType = String(payload.credentialType || 'tencent_code').trim() || 'tencent_code'
|
||||
const inventoryGroupCode = String(payload.inventoryGroupCode || '').trim()
|
||||
|
||||
if (!skuCode) {
|
||||
throw createHttpError('批量导入时缺少 skuCode', {
|
||||
@@ -711,7 +718,7 @@ function normalizeInventoryImportRows(payload) {
|
||||
if (!displayValue) {
|
||||
continue
|
||||
}
|
||||
rows.push({ skuCode, displayValue, batchNo, credentialType })
|
||||
rows.push({ skuCode, displayValue, batchNo, credentialType, inventoryGroupCode })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +726,7 @@ function normalizeInventoryImportRows(payload) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<Required<Pick<AdminInventoryImportRowInput, 'skuCode' | 'displayValue' | 'batchNo' | 'credentialType'>>>} rows
|
||||
* @param {Array<Required<Pick<AdminInventoryImportRowInput, 'skuCode' | 'displayValue' | 'batchNo' | 'credentialType' | 'inventoryGroupCode'>>>} rows
|
||||
*/
|
||||
function dedupeRows(rows) {
|
||||
const seen = new Set()
|
||||
@@ -737,6 +744,12 @@ function dedupeRows(rows) {
|
||||
return output
|
||||
}
|
||||
|
||||
function resolveTaskInventoryGroupCodes(task) {
|
||||
const taskContext = parseTaskContext(task)
|
||||
const inventoryGroupCode = String(taskContext?.inventoryGroupCode || '').trim()
|
||||
return inventoryGroupCode ? [inventoryGroupCode] : null
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Awaited<ReturnType<typeof getRequiredTask>>} task
|
||||
|
||||
Reference in New Issue
Block a user