2026-08-20 18:04:38 +08:00
|
|
|
import { overseasHttp } from '@/shared/api/overseasHttp'
|
|
|
|
|
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
|
|
|
|
import type { OverseasPageResult } from './lastMileOrders'
|
|
|
|
|
|
|
|
|
|
export interface InventoryBalanceDto {
|
|
|
|
|
id: string
|
|
|
|
|
customerId: string
|
|
|
|
|
customerName?: string | null
|
|
|
|
|
overseasWarehouseId: string
|
|
|
|
|
overseasWarehouseCode?: string | null
|
|
|
|
|
overseasWarehouseName?: string | null
|
|
|
|
|
destinationWarehouseId?: string | null
|
|
|
|
|
destinationWarehouseCode?: string | null
|
|
|
|
|
destinationWarehouseName?: string | null
|
|
|
|
|
inboundOrderId: string
|
|
|
|
|
inboundOrderNo?: string | null
|
|
|
|
|
inboundCode: string
|
|
|
|
|
skuCodes: string[]
|
|
|
|
|
productNames: string[]
|
|
|
|
|
warehouseLocationIds: string[]
|
|
|
|
|
warehouseLocationCodes: string[]
|
|
|
|
|
totalPackages: number
|
|
|
|
|
availablePackages: number
|
|
|
|
|
holdPackages: number
|
|
|
|
|
allocatedPackages: number
|
|
|
|
|
pickedPackages: number
|
|
|
|
|
inTransitPackages: number
|
|
|
|
|
receivingPackages: number
|
|
|
|
|
procurementPackages: number
|
|
|
|
|
updatedAt?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface InventoryDashboardDto {
|
|
|
|
|
inboundOrderCount: number
|
|
|
|
|
palletCount: number
|
|
|
|
|
totalPackages: number
|
|
|
|
|
availablePackages: number
|
|
|
|
|
holdPackages: number
|
|
|
|
|
allocatedPackages: number
|
|
|
|
|
pickedPackages: number
|
|
|
|
|
inTransitPackages: number
|
|
|
|
|
receivingPackages: number
|
|
|
|
|
procurementPackages: number
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-20 18:27:30 +08:00
|
|
|
export interface InventoryPositionDto {
|
|
|
|
|
id: string
|
|
|
|
|
balanceId: string
|
|
|
|
|
customerId: string
|
|
|
|
|
overseasWarehouseId?: string | null
|
|
|
|
|
destinationWarehouseCode?: string | null
|
|
|
|
|
inboundOrderId?: string | null
|
|
|
|
|
inboundOrderNo?: string | null
|
|
|
|
|
inboundCode?: string | null
|
|
|
|
|
palletId?: string | null
|
|
|
|
|
palletNo?: string | null
|
|
|
|
|
batchNo?: string | null
|
|
|
|
|
warehouseLocationId?: string | null
|
|
|
|
|
warehouseLocationCode?: string | null
|
|
|
|
|
totalPackages: number
|
|
|
|
|
availablePackages: number
|
|
|
|
|
holdPackages: number
|
|
|
|
|
allocatedPackages: number
|
|
|
|
|
pickedPackages: number
|
|
|
|
|
receivingPackages: number
|
|
|
|
|
status?: string | null
|
|
|
|
|
updatedAt?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface InventoryLedgerDto {
|
|
|
|
|
id: string
|
|
|
|
|
customerId: string
|
|
|
|
|
overseasWarehouseId?: string | null
|
|
|
|
|
destinationWarehouseCode?: string | null
|
|
|
|
|
inboundOrderId?: string | null
|
|
|
|
|
inboundOrderNo?: string | null
|
|
|
|
|
inboundCode?: string | null
|
|
|
|
|
palletNo?: string | null
|
|
|
|
|
batchNo?: string | null
|
|
|
|
|
warehouseLocationCode?: string | null
|
|
|
|
|
skuCode?: string | null
|
|
|
|
|
businessType?: string | null
|
|
|
|
|
businessOrderNo?: string | null
|
|
|
|
|
outboundOrderNo?: string | null
|
|
|
|
|
statusFrom?: string | null
|
|
|
|
|
statusTo?: string | null
|
|
|
|
|
beforePackages: number
|
|
|
|
|
deltaPackages: number
|
|
|
|
|
afterPackages: number
|
|
|
|
|
operatorId?: string | null
|
|
|
|
|
remark?: string | null
|
|
|
|
|
occurredAt?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-20 18:04:38 +08:00
|
|
|
export interface InventoryBalanceQuery {
|
|
|
|
|
customerId: string
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
customerName?: string
|
|
|
|
|
overseasWarehouseId?: string
|
2026-08-20 18:02:52 +08:00
|
|
|
overseasWarehouseCode?: string
|
|
|
|
|
destinationWarehouseCode?: string
|
|
|
|
|
inboundOrderNo?: string
|
|
|
|
|
inboundCode?: string
|
|
|
|
|
businessOrderNo?: string
|
2026-08-20 18:04:38 +08:00
|
|
|
skuCode?: string
|
|
|
|
|
productName?: string
|
|
|
|
|
batchNo?: string
|
|
|
|
|
warehouseLocationCode?: string
|
|
|
|
|
inventoryStatus?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function params(query: InventoryBalanceQuery) { return { ...query } }
|
|
|
|
|
|
|
|
|
|
export async function listInventoryBalances(query: InventoryBalanceQuery) {
|
|
|
|
|
const response = await overseasHttp.get<ApiEnvelope<OverseasPageResult<InventoryBalanceDto>>, ApiEnvelope<OverseasPageResult<InventoryBalanceDto>>>(
|
|
|
|
|
'/platform/v1/last-leg/inventory/balances', { params: params(query) },
|
|
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getInventorySummary(query: InventoryBalanceQuery) {
|
|
|
|
|
const { page: _page, size: _size, ...summaryParams } = params(query)
|
|
|
|
|
const response = await overseasHttp.get<ApiEnvelope<InventoryDashboardDto>, ApiEnvelope<InventoryDashboardDto>>(
|
|
|
|
|
'/platform/v1/last-leg/inventory/summary', { params: summaryParams },
|
|
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
2026-08-20 18:27:30 +08:00
|
|
|
|
|
|
|
|
export async function listInventoryPositions(
|
|
|
|
|
balanceId: string,
|
|
|
|
|
customerId: string,
|
|
|
|
|
query: { palletNo?: string; batchNo?: string; inventoryStatus?: string } = {},
|
|
|
|
|
) {
|
|
|
|
|
const response = await overseasHttp.get<ApiEnvelope<InventoryPositionDto[]>, ApiEnvelope<InventoryPositionDto[]>>(
|
|
|
|
|
`/platform/v1/last-leg/inventory/balances/${encodeURIComponent(balanceId)}/positions`,
|
|
|
|
|
{ params: { customerId, ...query } },
|
|
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface InventoryLedgerQuery {
|
|
|
|
|
customerId: string
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
overseasWarehouseId?: string
|
|
|
|
|
destinationWarehouseCode?: string
|
|
|
|
|
businessType?: string
|
|
|
|
|
businessOrderNo?: string
|
|
|
|
|
inboundOrderNo?: string
|
|
|
|
|
inboundCode?: string
|
|
|
|
|
outboundOrderNo?: string
|
|
|
|
|
palletNo?: string
|
|
|
|
|
batchNo?: string
|
|
|
|
|
skuCode?: string
|
|
|
|
|
warehouseLocationCode?: string
|
|
|
|
|
occurredFrom?: string
|
|
|
|
|
occurredTo?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function listInventoryLedger(query: InventoryLedgerQuery) {
|
|
|
|
|
const response = await overseasHttp.get<ApiEnvelope<OverseasPageResult<InventoryLedgerDto>>, ApiEnvelope<OverseasPageResult<InventoryLedgerDto>>>(
|
|
|
|
|
'/platform/v1/last-leg/inventory/ledger',
|
|
|
|
|
{ params: { ...query } },
|
|
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|