Files
admin-web/src/modules/overseas-warehouse/api/pallets.ts
T

84 lines
2.8 KiB
TypeScript
Raw Normal View History

2026-08-20 18:04:38 +08:00
import { overseasHttp } from '@/shared/api/overseasHttp'
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders'
2026-08-20 18:04:38 +08:00
export interface CustomerWarehouseDto {
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
2026-08-21 11:20:09 +08:00
fbaWarehouseCode: string
2026-08-20 18:04:38 +08:00
capacityCbm: number
unitPrice: number
status: string
remark?: string | null
version: number
2026-08-20 18:04:38 +08:00
createdAt?: string | null
updatedAt?: string | null
}
export interface SavePalletPayload {
palletCode: string
palletType: string
2026-08-21 11:20:09 +08:00
fbaWarehouseCode: string
2026-08-20 18:04:38 +08:00
capacityCbm: number
unitPrice: number
status: string
locationId?: string | null
remark?: string | null
}
export interface UpdatePalletPayload extends SavePalletPayload {
version: number
}
2026-08-21 11:20:09 +08:00
export async function listCustomerWarehouses() {
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<CustomerWarehouseDto>>, ApiEnvelope<OverseasPagePayload<CustomerWarehouseDto>>>(
2026-08-20 18:04:38 +08:00
'/platform/v1/warehouse-admin',
2026-08-21 17:20:40 +08:00
{ params: { page: 1, size: 200 } },
2026-08-20 18:04:38 +08:00
)
return normalizeOverseasPage(unwrapApiResponse(response))
2026-08-20 18:04:38 +08:00
}
2026-08-21 11:20:09 +08:00
export async function listPallets(warehouseId: string, query: { page: number; size: number; keyword?: string; palletType?: string; status?: string }) {
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<PalletDto>>, ApiEnvelope<OverseasPagePayload<PalletDto>>>(
2026-08-20 18:04:38 +08:00
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`,
2026-08-21 11:20:09 +08:00
{ params: { ...query } },
2026-08-20 18:04:38 +08:00
)
return normalizeOverseasPage(unwrapApiResponse(response))
2026-08-20 18:04:38 +08:00
}
2026-08-21 11:20:09 +08:00
export async function getPallet(warehouseId: string, palletId: string) {
2026-08-20 18:04:38 +08:00
const response = await overseasHttp.get<ApiEnvelope<PalletDto>, ApiEnvelope<PalletDto>>(
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
2026-08-21 11:20:09 +08:00
{},
2026-08-20 18:04:38 +08:00
)
return unwrapApiResponse(response)
}
2026-08-21 11:20:09 +08:00
export async function createPallet(warehouseId: string, payload: SavePalletPayload) {
2026-08-20 18:04:38 +08:00
const response = await overseasHttp.post<ApiEnvelope<string>, ApiEnvelope<string>>(
2026-08-21 11:20:09 +08:00
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`, payload,
2026-08-20 18:04:38 +08:00
)
return unwrapApiResponse(response)
}
export async function updatePallet(warehouseId: string, palletId: string, payload: UpdatePalletPayload) {
2026-08-20 18:04:38 +08:00
const response = await overseasHttp.put<ApiEnvelope<null>, ApiEnvelope<null>>(
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
2026-08-21 11:20:09 +08:00
payload,
2026-08-20 18:04:38 +08:00
)
return unwrapApiResponse(response)
}