优化
This commit is contained in:
@@ -3,9 +3,9 @@ import { http } from '@/shared/api/http'
|
||||
import {
|
||||
approvePlatformUnifiedOrder,
|
||||
addPlatformUnifiedOrderNote,
|
||||
assignPlatformUnifiedOrderCarrier,
|
||||
getPlatformUnifiedOrder,
|
||||
listPlatformUnifiedOrders,
|
||||
listPlatformUnifiedOrderFeeDetails,
|
||||
} from './unifiedOrders'
|
||||
|
||||
vi.mock('@/shared/api/http', () => ({
|
||||
@@ -52,11 +52,11 @@ describe('unified orders API contract', () => {
|
||||
|
||||
it('normalizes C02 row IDs and keeps inboundId for measurement routing', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ data: {
|
||||
records: [{ orderId: '90001', tenantId: '208', inboundId: '77', inboundVersion: 3, mainStatus: 'WAIT_MEASURE', measurement: null, preload: null, loading: null, delivery: null, transport: null }],
|
||||
records: [{ orderId: '90001', tenantId: '208', inboundId: '77', inboundVersion: 3, mainStatus: 'WAIT_MEASURE', customerRemark: '客户备注', latestInternalNote: '最新内部备注', measurement: null, preload: null, loading: null, delivery: null, transport: null }],
|
||||
page: 1, size: 20, total: 1, pages: 1,
|
||||
} })
|
||||
await expect(listPlatformUnifiedOrders({ page: 1, size: 20 })).resolves.toMatchObject({
|
||||
records: [{ orderId: '90001', tenantId: '208', inboundId: '77', inboundVersion: 3 }],
|
||||
records: [{ orderId: '90001', tenantId: '208', inboundId: '77', inboundVersion: 3, customerRemark: '客户备注', latestInternalNote: '最新内部备注' }],
|
||||
})
|
||||
})
|
||||
|
||||
@@ -72,14 +72,11 @@ describe('unified orders API contract', () => {
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/orders/90001', { params: { tenantId: '208' } })
|
||||
})
|
||||
|
||||
it('uses the explicit first-leg carrier and approval boundaries for pending review', async () => {
|
||||
vi.mocked(http.put).mockResolvedValue({ data: null })
|
||||
it('uses the explicit first-leg approval boundary for pending review', async () => {
|
||||
vi.mocked(http.post).mockResolvedValue({ data: null })
|
||||
|
||||
await assignPlatformUnifiedOrderCarrier('208', '90001', '30001')
|
||||
await approvePlatformUnifiedOrder('208', '90001')
|
||||
|
||||
expect(http.put).toHaveBeenCalledWith('/platform/v1/orders/first-leg/90001/carrier', { carrierId: '30001' }, { params: { tenantId: '208' } })
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/v1/orders/first-leg/90001/approve', undefined, { params: { tenantId: '208' } })
|
||||
})
|
||||
|
||||
@@ -88,4 +85,10 @@ describe('unified orders API contract', () => {
|
||||
await expect(addPlatformUnifiedOrderNote('208', '90001', '已确认船期')).resolves.toBe('91001')
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/v1/orders/90001/internal-notes', { content: '已确认船期' }, { params: { tenantId: '208' } })
|
||||
})
|
||||
|
||||
it('loads fee detail rows from the inbound fee-detail contract', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ data: [{ id: '1', inboundId: '88', reviewStatus: 'APPROVED', amount: 100 }] })
|
||||
await expect(listPlatformUnifiedOrderFeeDetails('208', '88')).resolves.toHaveLength(1)
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/inbounds/88/fee-details', { params: { accountId: '208' } })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -124,6 +124,7 @@ export interface UnifiedOrderResource {
|
||||
expressTrackingNo?: string | null
|
||||
remark?: string | null
|
||||
customerRemark?: string | null
|
||||
latestInternalNote?: string | null
|
||||
internalRemark?: string | null
|
||||
createdBy?: string | null
|
||||
}
|
||||
@@ -208,6 +209,36 @@ export interface UnifiedOrderDetailResource {
|
||||
timeline: UnifiedOrderTimelineEvent[]
|
||||
}
|
||||
|
||||
export interface UnifiedOrderFeeDetailResource {
|
||||
id: number | string
|
||||
inboundId: number | string
|
||||
inboundCode: string | null
|
||||
reviewStatus: string | null
|
||||
direction: string | null
|
||||
customerName: string | null
|
||||
invoiceTitle: string | null
|
||||
businessDate: string | null
|
||||
channelName: string | null
|
||||
destinationName: string | null
|
||||
fbaNo?: string | null
|
||||
packageCount: number | null
|
||||
actualGrossWeightKg: number | null
|
||||
actualVolumeCbm: number | null
|
||||
feeTypeNameSnapshot: string | null
|
||||
currency: string | null
|
||||
amount: number | null
|
||||
chargeableQuantity: number | null
|
||||
chargeUnit: string | null
|
||||
unitPrice: number | null
|
||||
inboundedAt: string | null
|
||||
outboundAt?: string | null
|
||||
storageDays?: number | null
|
||||
settlementIncluded: boolean | null
|
||||
billNo?: string | null
|
||||
settlementStartDate?: string | null
|
||||
settlementEndDate?: string | null
|
||||
}
|
||||
|
||||
export interface UnifiedOrderPageResource {
|
||||
records: UnifiedOrderResource[]
|
||||
page: number
|
||||
@@ -327,14 +358,6 @@ export async function getPlatformUnifiedOrder(tenantId: string, orderId: string)
|
||||
return { ...result, summary: normalizeRow(result.summary) }
|
||||
}
|
||||
|
||||
export function assignPlatformUnifiedOrderCarrier(tenantId: string, orderId: string, carrierId: string) {
|
||||
return http.put<ApiEnvelope<void>, ApiEnvelope<void>>(
|
||||
`/platform/v1/orders/first-leg/${orderId}/carrier`,
|
||||
{ carrierId },
|
||||
{ params: { tenantId } },
|
||||
).then(unwrapApiResponse)
|
||||
}
|
||||
|
||||
export function approvePlatformUnifiedOrder(tenantId: string, orderId: string) {
|
||||
return http.post<ApiEnvelope<void>, ApiEnvelope<void>>(
|
||||
`/platform/v1/orders/first-leg/${orderId}/approve`,
|
||||
@@ -351,6 +374,14 @@ export function addPlatformUnifiedOrderNote(tenantId: string, orderId: string, c
|
||||
).then(unwrapApiResponse)
|
||||
}
|
||||
|
||||
export async function listPlatformUnifiedOrderFeeDetails(accountId: string, inboundId: string) {
|
||||
const response = await http.get<ApiEnvelope<UnifiedOrderFeeDetailResource[]>, ApiEnvelope<UnifiedOrderFeeDetailResource[]>>(
|
||||
`/platform/v1/inbounds/${encodeURIComponent(inboundId)}/fee-details`,
|
||||
{ params: { accountId } },
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export function unifiedOrderStatusLabel(status: UnifiedOrderMainStatus) {
|
||||
return unifiedOrderStatusOptions.find((item) => item.value === status)?.label || status
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user