85 lines
3.1 KiB
TypeScript
85 lines
3.1 KiB
TypeScript
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
|
||
|
|
capacityCbm: number
|
||
|
|
unitPrice: number
|
||
|
|
status: string
|
||
|
|
remark?: string | null
|
||
|
|
createdAt?: string | null
|
||
|
|
updatedAt?: string | null
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface SavePalletPayload {
|
||
|
|
palletCode: string
|
||
|
|
palletType: string
|
||
|
|
capacityCbm: number
|
||
|
|
unitPrice: number
|
||
|
|
status: string
|
||
|
|
locationId?: string | null
|
||
|
|
remark?: string | null
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function listCustomerWarehouses(customerId: string) {
|
||
|
|
const response = await overseasHttp.get<ApiEnvelope<OverseasPageResult<CustomerWarehouseDto>>, ApiEnvelope<OverseasPageResult<CustomerWarehouseDto>>>(
|
||
|
|
'/platform/v1/warehouse-admin',
|
||
|
|
{ params: { customerId, page: 1, size: 200, status: 'ACTIVE' } },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function listPallets(customerId: string, warehouseId: string, query: { page: number; size: number; keyword?: string; palletType?: string; status?: string }) {
|
||
|
|
const response = await overseasHttp.get<ApiEnvelope<OverseasPageResult<PalletDto>>, ApiEnvelope<OverseasPageResult<PalletDto>>>(
|
||
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`,
|
||
|
|
{ params: { customerId, ...query } },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function getPallet(customerId: string, warehouseId: string, palletId: string) {
|
||
|
|
const response = await overseasHttp.get<ApiEnvelope<PalletDto>, ApiEnvelope<PalletDto>>(
|
||
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
||
|
|
{ params: { customerId } },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function createPallet(customerId: string, warehouseId: string, payload: SavePalletPayload) {
|
||
|
|
const response = await overseasHttp.post<ApiEnvelope<string>, ApiEnvelope<string>>(
|
||
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`, payload, { params: { customerId } },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function updatePallet(customerId: string, warehouseId: string, palletId: string, payload: SavePalletPayload) {
|
||
|
|
const response = await overseasHttp.put<ApiEnvelope<null>, ApiEnvelope<null>>(
|
||
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
||
|
|
payload, { params: { customerId } },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function deletePallet(customerId: string, warehouseId: string, palletId: string) {
|
||
|
|
const response = await overseasHttp.delete<ApiEnvelope<null>, ApiEnvelope<null>>(
|
||
|
|
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
||
|
|
{ params: { customerId } },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|