This commit is contained in:
2026-09-11 18:44:01 +08:00
parent b9330a9674
commit 497530d6a9
3 changed files with 33 additions and 140 deletions
@@ -1,6 +1,6 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
export type PriceBookStatus = 'PENDING_CONFIRMATION' | 'ACTIVE' | 'SUPERSEDED' | 'FAILED'
export type PriceBookStatus = 'PENDING_CONFIRMATION' | 'ACTIVE' | 'SUPERSEDED' | 'VOIDED' | 'FAILED'
export type PriceModel = 'FBA_WAREHOUSE_RATE' | 'REGION_WEIGHT_TIER'
export type PricingTaxMode = 'TAX_INCLUDED' | 'TAX_EXCLUDED'
export type PricingDestinationType = 'FBA' | 'OVERSEAS'
@@ -27,6 +27,9 @@ export interface PlatformPriceBookVersion {
publishedBy: string | null
publishedAt: string | null
supersededAt: string | null
voidedBy: string | null
voidedAt: string | null
voidReason: string | null
}
/** Read-only channel data parsed from the uploaded workbook. */
@@ -102,7 +105,7 @@ export interface PlatformPriceBookQuery {
}
interface PriceBookVersionPayload extends Omit<PlatformPriceBookVersion,
'id' | 'customerId' | 'versionNo' | 'sourceFileId' | 'channelCount' | 'rateCount' | 'blockingErrorCount' | 'warningCount' | 'createdBy' | 'publishedBy'> {
'id' | 'customerId' | 'versionNo' | 'sourceFileId' | 'channelCount' | 'rateCount' | 'blockingErrorCount' | 'warningCount' | 'createdBy' | 'publishedBy' | 'voidedBy'> {
id: ApiId
customerId: ApiId
versionNo: ApiNumber
@@ -113,6 +116,7 @@ interface PriceBookVersionPayload extends Omit<PlatformPriceBookVersion,
warningCount?: ApiNumber | null
createdBy?: ApiId | null
publishedBy?: ApiId | null
voidedBy?: ApiId | null
}
interface PriceBookParsedChannelPayload extends Omit<PlatformPriceBookParsedChannel,
@@ -181,6 +185,9 @@ function normalizeVersion(value: PriceBookVersionPayload): PlatformPriceBookVers
publishedBy: nullableId(value.publishedBy),
publishedAt: nullableText(value.publishedAt),
supersededAt: nullableText(value.supersededAt),
voidedBy: nullableId(value.voidedBy),
voidedAt: nullableText(value.voidedAt),
voidReason: nullableText(value.voidReason),
}
}
@@ -271,6 +278,14 @@ export async function publishPlatformPriceBook(
return normalizeDetail(unwrapApiResponse(response))
}
export async function voidPlatformPriceBook(versionId: string, reason: string): Promise<PlatformPriceBookDetail> {
const response = await http.post<ApiEnvelope<PriceBookDetailPayload>, ApiEnvelope<PriceBookDetailPayload>>(
`${basePath}/${encodeURIComponent(versionId)}/void`,
{ reason },
)
return normalizeDetail(unwrapApiResponse(response))
}
export function downloadPlatformPriceBookSource(versionId: string) {
return http.get<Blob, Blob>(`${basePath}/${encodeURIComponent(versionId)}/source`, { responseType: 'blob' })
}