fix(overseas): expose permission-gated cargo discard review

This commit is contained in:
2026-10-04 16:57:16 +08:00
parent 1d73a40a07
commit cc973c72c0
6 changed files with 152 additions and 1 deletions
@@ -1,10 +1,18 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { reviewCargoDiscard } from './lastMileOrders'
import { changeContainerReceivingWarehouse, convertLastMileContainerToInboundPlans, createManualInboundPlan, downloadLastMileOrders, getContainerPlanProgress, getLastMileOrder, getLastMileOrderManualNodes, listContainerPlanProgress, listLastMileOrders, transferLastMileOrders, updateLastMileOrderHold, updateLastMileOrderManualNodes } from './lastMileOrders'
vi.mock('@/shared/api/http', async (importOriginal) => ({ ...(await importOriginal<typeof import('@/shared/api/http')>()), http: { get: vi.fn(), put: vi.fn(), post: vi.fn() } }))
describe('last-mile order overseas API', () => {
it('reviews a discard by business number with an explicit string customer query', async () => {
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: { status: 'REJECTED' } })
await expect(reviewCargoDiscard('CD/TEST-1', '2092618717861048321', 'REJECT', ' 箱数不符 ')).resolves.toEqual({ status: 'REJECTED' })
expect(http.post).toHaveBeenCalledExactlyOnceWith('/platform/v1/last-leg/cargo-discards/CD%2FTEST-1/review',
{ decision: 'REJECT', remark: '箱数不符' }, { params: { customerId: '2092618717861048321' } })
})
beforeEach(() => {
vi.mocked(http.get).mockReset()
vi.mocked(http.put).mockReset()
@@ -365,6 +365,15 @@ export async function getLastMileOrder(orderId: string) {
return unwrapApiResponse(response)
}
export async function reviewCargoDiscard(discardNo: string, customerId: string, decision: 'APPROVE' | 'REJECT', remark?: string) {
const response = await http.post<ApiEnvelope<unknown>, ApiEnvelope<unknown>>(
`/platform/v1/last-leg/cargo-discards/${encodeURIComponent(discardNo)}/review`,
{ decision, remark: remark?.trim() || undefined },
{ params: { customerId } },
)
return unwrapApiResponse(response)
}
export async function reviewReturnOrder(returnNo: string, customerId: string, decision: 'APPROVE' | 'REJECT', remark?: string) {
const response = await http.post<ApiEnvelope<unknown>, ApiEnvelope<unknown>>(
`/platform/v1/last-leg/return-orders/${encodeURIComponent(returnNo)}/review`,