优化
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
|
||||
export type InboundFeeDirection = 'RECEIVABLE' | 'PAYABLE'
|
||||
export type InboundFeeReviewStatus = 'PENDING' | 'APPROVED' | 'REJECTED'
|
||||
|
||||
export interface InboundFeeDetail {
|
||||
id: string | number
|
||||
inboundId: string | number
|
||||
feeItemId: string | number
|
||||
sourceType: string
|
||||
sourceFeeVersion: number
|
||||
inboundCode: string | null
|
||||
direction: InboundFeeDirection
|
||||
partnerId: string | number | null
|
||||
partnerName: string | null
|
||||
businessDate: string
|
||||
customerName: string | null
|
||||
feeTypeNameSnapshot: string
|
||||
unitPrice: number
|
||||
currency: string
|
||||
amount: number
|
||||
remark: string | null
|
||||
reviewStatus: InboundFeeReviewStatus
|
||||
reviewReason: string | null
|
||||
reviewerName: string | null
|
||||
reviewedAt: string | null
|
||||
publicationStatus: string
|
||||
settlementIncluded: boolean
|
||||
}
|
||||
|
||||
export interface SaveInboundFeeDetailRequest {
|
||||
feeItemId: string | number
|
||||
direction: InboundFeeDirection
|
||||
businessDate: string
|
||||
unitPrice: number
|
||||
currency: string
|
||||
amount: number
|
||||
settlementIncluded: boolean
|
||||
partnerId: string | number | null
|
||||
partnerName: string | null
|
||||
remark: string | null
|
||||
}
|
||||
|
||||
export interface InboundFeeItemOption {
|
||||
id: string | number
|
||||
feeTypeName: string
|
||||
warehousePayable: boolean
|
||||
warehouseReceivable: boolean
|
||||
}
|
||||
|
||||
export interface InboundFeePartnerOption { id: string | number; partnerName: string }
|
||||
|
||||
function basePath(inboundId: string) { return `/platform/v1/inbounds/${encodeURIComponent(inboundId)}/fee-details` }
|
||||
const config = (accountId: string) => ({ params: { accountId } })
|
||||
|
||||
export async function listInboundFeeDetails(accountId: string, inboundId: string) {
|
||||
const response = await http.get<unknown, ApiEnvelope<InboundFeeDetail[]>>(basePath(inboundId), config(accountId))
|
||||
return unwrapApiResponse(response) || []
|
||||
}
|
||||
|
||||
export async function createInboundFeeDetail(accountId: string, inboundId: string, payload: SaveInboundFeeDetailRequest) {
|
||||
return unwrapApiResponse(await http.post<unknown, ApiEnvelope<InboundFeeDetail>>(basePath(inboundId), payload, config(accountId)))
|
||||
}
|
||||
|
||||
export async function updateInboundFeeDetail(accountId: string, inboundId: string, detailId: string, payload: SaveInboundFeeDetailRequest) {
|
||||
return unwrapApiResponse(await http.put<unknown, ApiEnvelope<InboundFeeDetail>>(`${basePath(inboundId)}/${encodeURIComponent(detailId)}`, payload, config(accountId)))
|
||||
}
|
||||
|
||||
export async function deleteInboundFeeDetail(accountId: string, inboundId: string, detailId: string) {
|
||||
return unwrapApiResponse(await http.delete<unknown, ApiEnvelope<null>>(`${basePath(inboundId)}/${encodeURIComponent(detailId)}`, config(accountId)))
|
||||
}
|
||||
|
||||
export async function reviewInboundFeeDetail(accountId: string, inboundId: string, detailId: string, action: 'approve' | 'reject', reason?: string) {
|
||||
return unwrapApiResponse(await http.post<unknown, ApiEnvelope<null>>(
|
||||
`${basePath(inboundId)}/${encodeURIComponent(detailId)}/${action}`,
|
||||
action === 'reject' ? { reason } : undefined, config(accountId),
|
||||
))
|
||||
}
|
||||
|
||||
export async function adjustInboundFeeDetail(accountId: string, inboundId: string, detailId: string, expectedSourceVersion: number, payload: SaveInboundFeeDetailRequest) {
|
||||
return unwrapApiResponse(await http.post<unknown, ApiEnvelope<InboundFeeDetail>>(
|
||||
`${basePath(inboundId)}/${encodeURIComponent(detailId)}/adjust`, payload,
|
||||
{ params: { accountId, expectedSourceVersion } },
|
||||
))
|
||||
}
|
||||
|
||||
export async function voidInboundFeeDetail(accountId: string, inboundId: string, detailId: string, expectedSourceVersion: number) {
|
||||
return unwrapApiResponse(await http.post<unknown, ApiEnvelope<null>>(
|
||||
`${basePath(inboundId)}/${encodeURIComponent(detailId)}/void`, { expectedSourceVersion }, config(accountId),
|
||||
))
|
||||
}
|
||||
|
||||
export async function listInboundFeeItemOptions() {
|
||||
const response = await http.get<unknown, ApiEnvelope<{ records: InboundFeeItemOption[] }>>(
|
||||
'/platform/v1/fee-items', { params: { status: 'ACTIVE', page: 1, size: 200 } },
|
||||
)
|
||||
return unwrapApiResponse(response).records || []
|
||||
}
|
||||
|
||||
export async function listInboundFeePartnerOptions() {
|
||||
const response = await http.get<unknown, ApiEnvelope<{ records: InboundFeePartnerOption[] }>>(
|
||||
'/platform/v1/partners', { params: { status: 'ACTIVE', page: 1, size: 200 } },
|
||||
)
|
||||
return unwrapApiResponse(response).records || []
|
||||
}
|
||||
Reference in New Issue
Block a user