fix(orders): send version and idempotency key for platform cancellation
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
|||||||
acceptPlatformFirstLegOrder,
|
acceptPlatformFirstLegOrder,
|
||||||
approvePlatformFirstLegOrder,
|
approvePlatformFirstLegOrder,
|
||||||
cancelPlatformFirstLegOrder,
|
cancelPlatformFirstLegOrder,
|
||||||
completePlatformFirstLegOrder,
|
|
||||||
getPlatformFirstLegOrder,
|
getPlatformFirstLegOrder,
|
||||||
listPlatformFirstLegOrders,
|
listPlatformFirstLegOrders,
|
||||||
startPlatformFirstLegOrder,
|
startPlatformFirstLegOrder,
|
||||||
@@ -82,15 +81,14 @@ describe('platform first-leg order API', () => {
|
|||||||
await approvePlatformFirstLegOrder('10001', '90001')
|
await approvePlatformFirstLegOrder('10001', '90001')
|
||||||
await acceptPlatformFirstLegOrder('10001', '90001')
|
await acceptPlatformFirstLegOrder('10001', '90001')
|
||||||
await startPlatformFirstLegOrder('10001', '90001')
|
await startPlatformFirstLegOrder('10001', '90001')
|
||||||
await completePlatformFirstLegOrder('10001', '90001')
|
await cancelPlatformFirstLegOrder('10001', '90001', { expectedVersion: 7, reason: '客户取消' }, 'cancel-original-key')
|
||||||
await cancelPlatformFirstLegOrder('10001', '90001', '客户取消')
|
|
||||||
|
|
||||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/orders/first-leg/90001', { params: { tenantId: '10001' } })
|
expect(http.get).toHaveBeenCalledWith('/platform/v1/orders/first-leg/90001', { params: { tenantId: '10001' } })
|
||||||
expect(http.post).toHaveBeenNthCalledWith(1, '/platform/v1/orders/first-leg/90001/approve', undefined, { params: { tenantId: '10001' } })
|
expect(http.post).toHaveBeenNthCalledWith(1, '/platform/v1/orders/first-leg/90001/approve', undefined, { params: { tenantId: '10001' } })
|
||||||
expect(http.post).toHaveBeenNthCalledWith(2, '/platform/v1/orders/first-leg/90001/accept', undefined, { params: { tenantId: '10001' } })
|
expect(http.post).toHaveBeenNthCalledWith(2, '/platform/v1/orders/first-leg/90001/accept', undefined, { params: { tenantId: '10001' } })
|
||||||
expect(http.post).toHaveBeenNthCalledWith(3, '/platform/v1/orders/first-leg/90001/start', undefined, { params: { tenantId: '10001' } })
|
expect(http.post).toHaveBeenNthCalledWith(3, '/platform/v1/orders/first-leg/90001/start', undefined, { params: { tenantId: '10001' } })
|
||||||
expect(http.post).toHaveBeenNthCalledWith(4, '/platform/v1/orders/first-leg/90001/complete', undefined, { params: { tenantId: '10001' } })
|
expect(http.post).toHaveBeenNthCalledWith(4, '/platform/v1/orders/first-leg/90001/cancel', { expectedVersion: 7, reason: '客户取消' }, { params: { tenantId: '10001' }, headers: { 'Idempotency-Key': 'cancel-original-key' } })
|
||||||
expect(http.post).toHaveBeenNthCalledWith(5, '/platform/v1/orders/first-leg/90001/cancel', { reason: '客户取消' }, { params: { tenantId: '10001' } })
|
expect(http.post).toHaveBeenCalledTimes(4)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('writes the backend express contract as names, not a guessed master-data ID', async () => {
|
it('writes the backend express contract as names, not a guessed master-data ID', async () => {
|
||||||
|
|||||||
@@ -184,12 +184,17 @@ export function startPlatformFirstLegOrder(tenantId: string, orderId: string) {
|
|||||||
return postData<void>(`/platform/v1/orders/first-leg/${orderId}/start`, undefined, { tenantId })
|
return postData<void>(`/platform/v1/orders/first-leg/${orderId}/start`, undefined, { tenantId })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function completePlatformFirstLegOrder(tenantId: string, orderId: string) {
|
export async function cancelPlatformFirstLegOrder(
|
||||||
return postData<void>(`/platform/v1/orders/first-leg/${orderId}/complete`, undefined, { tenantId })
|
tenantId: string,
|
||||||
}
|
orderId: string,
|
||||||
|
payload: { expectedVersion: number; reason: string },
|
||||||
export function cancelPlatformFirstLegOrder(tenantId: string, orderId: string, reason: string) {
|
idempotencyKey: string,
|
||||||
return postData<void>(`/platform/v1/orders/first-leg/${orderId}/cancel`, { reason }, { tenantId })
|
) {
|
||||||
|
const response = await http.post<ApiEnvelope<void>, ApiEnvelope<void>>(
|
||||||
|
`/platform/v1/orders/first-leg/${orderId}/cancel`, payload,
|
||||||
|
{ params: { tenantId }, headers: { 'Idempotency-Key': idempotencyKey } },
|
||||||
|
)
|
||||||
|
return unwrapApiResponse(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updatePlatformFirstLegOrderExpress(
|
export function updatePlatformFirstLegOrderExpress(
|
||||||
|
|||||||
Reference in New Issue
Block a user