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

87 lines
2.9 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 type { OverseasPageResult } from './lastMileOrders'
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
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
}
2026-08-21 11:20:09 +08:00
export async function listCustomerWarehouses() {
2026-08-20 18:04:38 +08:00
const response = await overseasHttp.get<ApiEnvelope<OverseasPageResult<CustomerWarehouseDto>>, ApiEnvelope<OverseasPageResult<CustomerWarehouseDto>>>(
'/platform/v1/warehouse-admin',
2026-08-21 11:20:09 +08:00
{ params: { page: 1, size: 200, status: 'ACTIVE' } },
2026-08-20 18:04:38 +08:00
)
return unwrapApiResponse(response)
}
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 }) {
2026-08-20 18:04:38 +08:00
const response = await overseasHttp.get<ApiEnvelope<OverseasPageResult<PalletDto>>, ApiEnvelope<OverseasPageResult<PalletDto>>>(
`/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 unwrapApiResponse(response)
}
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)
}
2026-08-21 11:20:09 +08:00
export async function updatePallet(warehouseId: string, palletId: string, payload: SavePalletPayload) {
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)
}
2026-08-21 11:20:09 +08:00
export async function deletePallet(warehouseId: string, palletId: string) {
2026-08-20 18:04:38 +08:00
const response = await overseasHttp.delete<ApiEnvelope<null>, ApiEnvelope<null>>(
`/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)
}