增加分组库存与客服
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
|
||||
import { buildClaimUrl } from '../claim/claim-service.js'
|
||||
import { getClaimTokenById } from '../../repositories/claim-token-repo.js'
|
||||
import { getInventoryItemById, listInventoryItems, listInventorySkuSuggestions } from '../../repositories/inventory-repo.js'
|
||||
import {
|
||||
getInventoryItemById,
|
||||
listInventoryItems,
|
||||
listInventorySkuSuggestions,
|
||||
} from '../../repositories/inventory-repo.js'
|
||||
import { listOrderItemsByOrderId } from '../../repositories/order-item-repo.js'
|
||||
import { getOrderById, listOrders } from '../../repositories/order-repo.js'
|
||||
import { getTaskById, listTasks, listTasksByOrderId } from '../../repositories/task-repo.js'
|
||||
@@ -313,9 +317,11 @@ export async function getAdminTaskScreenshotPath(taskId, session = null) {
|
||||
|
||||
/** @returns {Promise<AdminInventoryListResponse>} */
|
||||
/** @param {AdminInventoryListQueryInput} [query] */
|
||||
export async function getAdminInventoryItems(query = /** @type {AdminInventoryListQueryInput} */ ({})) {
|
||||
/** @param {AdminViewerSessionInput | null} [session] */
|
||||
export async function getAdminInventoryItems(query = /** @type {AdminInventoryListQueryInput} */ ({}), session = null) {
|
||||
const page = normalizePage(query.page)
|
||||
const pageSize = normalizePageSize(query.pageSize)
|
||||
const viewerContext = createAdminViewerContext(session)
|
||||
const { items, total } = await listInventoryItems({
|
||||
page,
|
||||
pageSize,
|
||||
@@ -323,6 +329,8 @@ export async function getAdminInventoryItems(query = /** @type {AdminInventoryLi
|
||||
credentialType: String(query.credentialType || '').trim(),
|
||||
status: String(query.status || '').trim(),
|
||||
batchNo: String(query.batchNo || '').trim(),
|
||||
inventoryGroupCode: String(query.inventoryGroupCode || '').trim(),
|
||||
allowedInventoryGroupCodes: viewerContext.allowedInventoryGroupCodes,
|
||||
})
|
||||
|
||||
return {
|
||||
@@ -335,9 +343,12 @@ export async function getAdminInventoryItems(query = /** @type {AdminInventoryLi
|
||||
/** @param {AdminInventorySkuSuggestionQueryInput} [query] */
|
||||
export async function getAdminInventorySkuSuggestions(
|
||||
query = /** @type {AdminInventorySkuSuggestionQueryInput} */ ({}),
|
||||
session = null,
|
||||
) {
|
||||
const viewerContext = createAdminViewerContext(session)
|
||||
const credentialType = String(query.credentialType || '').trim()
|
||||
const keyword = String(query.keyword || '').trim()
|
||||
const inventoryGroupCode = String(query.inventoryGroupCode || '').trim()
|
||||
const requestedLimit = Number(query.limit)
|
||||
const limit = Number.isFinite(requestedLimit) && requestedLimit > 0
|
||||
? Math.min(100, Math.floor(requestedLimit))
|
||||
@@ -346,12 +357,15 @@ export async function getAdminInventorySkuSuggestions(
|
||||
credentialType,
|
||||
keyword,
|
||||
limit,
|
||||
inventoryGroupCode,
|
||||
allowedInventoryGroupCodes: viewerContext.allowedInventoryGroupCodes,
|
||||
})
|
||||
|
||||
return {
|
||||
items: items.map((item) => ({
|
||||
skuCode: String(item.sku_code || '').trim(),
|
||||
credentialType: String(item.credential_type || '').trim() || 'tencent_code',
|
||||
inventoryGroupCode: String(item.inventory_group_code || '').trim(),
|
||||
totalCount: Number(item.total_count || 0),
|
||||
availableCount: Number(item.available_count || 0),
|
||||
latestUpdatedAt: item.latest_updated_at || null,
|
||||
|
||||
Reference in New Issue
Block a user