feat(admin): validate and cancel co-load groups
This commit is contained in:
@@ -25,12 +25,12 @@ describe('co-load group API', () => {
|
||||
expect(result.members.map((member) => member.tenantId)).toEqual(['2093000000000000004', '2093000000000000007'])
|
||||
})
|
||||
|
||||
it('cancels only the whole group with optimistic version and an optional reason', async () => {
|
||||
it('cancels the whole group by its visible inbound code without exposing group identifiers', async () => {
|
||||
const post = vi.spyOn(http, 'post').mockResolvedValue({ code: '200', message: 'ok', data: { ...group, status: 'CANCELLED', version: 1 } })
|
||||
await cancelPlatformCoLoadGroup('2093000000000000001', 0, '路线调整')
|
||||
await cancelPlatformCoLoadGroup('NYEXX2608310001', '路线调整')
|
||||
expect(post).toHaveBeenCalledWith(
|
||||
'/platform/v1/first-leg/coload-groups/2093000000000000001/cancel',
|
||||
{ expectedVersion: 0, reason: '路线调整' },
|
||||
'/platform/v1/first-leg/coload-groups/by-inbound-code/NYEXX2608310001/cancel',
|
||||
{ reason: '路线调整' },
|
||||
{ headers: { 'Idempotency-Key': expect.any(String) } },
|
||||
)
|
||||
})
|
||||
|
||||
@@ -81,10 +81,10 @@ export async function createPlatformCoLoadGroup(orderIds: string[]) {
|
||||
return normalizeGroup(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export async function cancelPlatformCoLoadGroup(groupId: string, expectedVersion: number, reason?: string | null) {
|
||||
export async function cancelPlatformCoLoadGroup(inboundCode: string, reason?: string | null) {
|
||||
const response = await http.post<ApiEnvelope<RawCoLoadGroup>, ApiEnvelope<RawCoLoadGroup>>(
|
||||
`${basePath}/${encodeURIComponent(groupId)}/cancel`,
|
||||
{ expectedVersion, reason: reason?.trim() || null },
|
||||
`${basePath}/by-inbound-code/${encodeURIComponent(inboundCode)}/cancel`,
|
||||
{ reason: reason?.trim() || null },
|
||||
{ headers: { 'Idempotency-Key': operationId('admin-coload-cancel') } },
|
||||
)
|
||||
return normalizeGroup(unwrapApiResponse(response))
|
||||
|
||||
Reference in New Issue
Block a user