89 lines
3.0 KiB
TypeScript
89 lines
3.0 KiB
TypeScript
import { overseasHttp } from '@/shared/api/overseasHttp'
|
|
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
|
import { listSharedReceivingOverseasWarehouseOptions } from '@/modules/iam'
|
|
import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders'
|
|
|
|
export interface ReceivingOverseasWarehouseDto {
|
|
id: string
|
|
customerId: string
|
|
warehouseCode: string
|
|
warehouseName: string
|
|
warehouseType: string
|
|
status: string
|
|
}
|
|
|
|
export interface PalletDto {
|
|
id: string
|
|
customerId: string
|
|
warehouseId: string
|
|
locationId?: string | null
|
|
palletCode: string
|
|
palletType: string
|
|
fbaWarehouseCode: string
|
|
capacityCbm: number
|
|
unitPrice: number
|
|
status: string
|
|
remark?: string | null
|
|
version: number
|
|
createdAt?: string | null
|
|
updatedAt?: string | null
|
|
}
|
|
|
|
export interface SavePalletPayload {
|
|
palletCode: string
|
|
palletType: string
|
|
fbaWarehouseCode: string
|
|
capacityCbm: number
|
|
unitPrice: number
|
|
status: string
|
|
locationId?: string | null
|
|
remark?: string | null
|
|
}
|
|
|
|
export interface UpdatePalletPayload extends SavePalletPayload {
|
|
version: number
|
|
}
|
|
|
|
export async function listReceivingOverseasWarehouses() {
|
|
const records: ReceivingOverseasWarehouseDto[] = (await listSharedReceivingOverseasWarehouseOptions()).map((warehouse) => ({
|
|
id: warehouse.id,
|
|
customerId: '0',
|
|
warehouseCode: warehouse.warehouseCode,
|
|
warehouseName: warehouse.warehouseName,
|
|
warehouseType: 'OVERSEAS',
|
|
status: 'ACTIVE',
|
|
}))
|
|
return { records, page: 1, size: 200, total: records.length, pages: records.length ? 1 : 0 }
|
|
}
|
|
|
|
export async function listPallets(warehouseId: string | undefined, query: { page: number; size: number; keyword?: string; palletType?: string; status?: string }) {
|
|
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<PalletDto>>, ApiEnvelope<OverseasPagePayload<PalletDto>>>(
|
|
warehouseId ? `/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets` : '/platform/v1/warehouse-admin/pallets',
|
|
{ params: { ...query } },
|
|
)
|
|
return normalizeOverseasPage(unwrapApiResponse(response))
|
|
}
|
|
|
|
export async function getPallet(warehouseId: string, palletId: string) {
|
|
const response = await overseasHttp.get<ApiEnvelope<PalletDto>, ApiEnvelope<PalletDto>>(
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
|
{},
|
|
)
|
|
return unwrapApiResponse(response)
|
|
}
|
|
|
|
export async function createPallet(warehouseId: string, payload: SavePalletPayload) {
|
|
const response = await overseasHttp.post<ApiEnvelope<string>, ApiEnvelope<string>>(
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`, payload,
|
|
)
|
|
return unwrapApiResponse(response)
|
|
}
|
|
|
|
export async function updatePallet(warehouseId: string, palletId: string, payload: UpdatePalletPayload) {
|
|
const response = await overseasHttp.put<ApiEnvelope<null>, ApiEnvelope<null>>(
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
|
payload,
|
|
)
|
|
return unwrapApiResponse(response)
|
|
}
|