68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
|||
|
|
|
||
|
|
export type MojiaSkuSyncStatus = 'PENDING' | 'SYNCING' | 'SUCCESS' | 'FAILED'
|
||
|
|
|
||
|
|
export interface MojiaSkuSyncRecord {
|
||
|
|
id: string
|
||
|
|
skuCode: string
|
||
|
|
lengthCm: number
|
||
|
|
widthCm: number
|
||
|
|
heightCm: number
|
||
|
|
weightKg: number
|
||
|
|
imageFileId?: string | null
|
||
|
|
imageUrl?: string | null
|
||
|
|
measuredAt?: string | null
|
||
|
|
receivedAt?: string | null
|
||
|
|
syncStatus: MojiaSkuSyncStatus
|
||
|
|
syncFailureCode?: string | null
|
||
|
|
syncFailureReason?: string | null
|
||
|
|
lingxingSkuId?: string | null
|
||
|
|
revision: number
|
||
|
|
updatedAt?: string | null
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface MojiaSkuSyncPage {
|
||
|
|
records: MojiaSkuSyncRecord[]
|
||
|
|
page: number
|
||
|
|
size: number
|
||
|
|
total: number
|
||
|
|
pages: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface MojiaSkuSyncQuery {
|
||
|
|
page: number
|
||
|
|
size: number
|
||
|
|
skuCode?: string
|
||
|
|
syncStatus?: MojiaSkuSyncStatus
|
||
|
|
}
|
||
|
|
|
||
|
|
const basePath = '/platform/v1/firstleg/mojia-sku-sync'
|
||
|
|
|
||
|
|
export async function listMojiaSkuSync(query: MojiaSkuSyncQuery) {
|
||
|
|
const response = await http.get<ApiEnvelope<MojiaSkuSyncPage>, ApiEnvelope<MojiaSkuSyncPage>>(
|
||
|
|
basePath, { params: query },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function updateMojiaSkuSync(id: string, data: {
|
||
|
|
skuCode: string
|
||
|
|
lengthCm: number
|
||
|
|
widthCm: number
|
||
|
|
heightCm: number
|
||
|
|
weightKg: number
|
||
|
|
revision: number
|
||
|
|
}) {
|
||
|
|
const response = await http.put<ApiEnvelope<MojiaSkuSyncRecord>, ApiEnvelope<MojiaSkuSyncRecord>>(
|
||
|
|
`${basePath}/${encodeURIComponent(id)}`, data,
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function retryMojiaSkuSync(id: string, revision: number) {
|
||
|
|
const response = await http.post<ApiEnvelope<MojiaSkuSyncRecord>, ApiEnvelope<MojiaSkuSyncRecord>>(
|
||
|
|
`${basePath}/${encodeURIComponent(id)}/retry`, { revision },
|
||
|
|
)
|
||
|
|
return unwrapApiResponse(response)
|
||
|
|
}
|