test(acceptance): align current gateway contracts
This commit is contained in:
@@ -224,6 +224,37 @@ export async function run(context) {
|
||||
}
|
||||
if (!await ensureReleasedOceanBooking(context, container)) return
|
||||
|
||||
const currentPath = `/api/platform/v1/customs/loading-plans/${encodeURIComponent(loadingPlanId)}`
|
||||
const currentDetailResponse = await context.request('GET', currentPath)
|
||||
let currentCustoms = context.apiSuccess(MODULE, '读取 customs-v1 整柜报关聚合', currentDetailResponse,
|
||||
`loadingPlanId=${loadingPlanId}`, OPTIONS)
|
||||
const allBuy = Array.isArray(currentCustoms?.inbounds) && currentCustoms.inbounds.length > 0
|
||||
&& currentCustoms.inbounds.every((item) => item?.taxMode === 'BUY_DECLARATION')
|
||||
if (allBuy) {
|
||||
if (currentCustoms.status === 'READY_TO_START') {
|
||||
const startedResponse = await context.request('POST', `${currentPath}/start`, {
|
||||
expectedVersion: Number(currentCustoms.version), confirm: true, remark: context.marker,
|
||||
}, context.token, { 'Idempotency-Key': key(context, 'current-all-buy-start') })
|
||||
currentCustoms = context.apiSuccess(MODULE, '全买单柜开始报关', startedResponse, '', OPTIONS)
|
||||
}
|
||||
if (currentCustoms?.status === 'DECLARING') {
|
||||
const completedResponse = await context.request('POST', `${currentPath}/complete-all-buy`, {
|
||||
expectedVersion: Number(currentCustoms.version), confirm: true, remark: context.marker,
|
||||
}, context.token, { 'Idempotency-Key': key(context, 'current-all-buy-complete') })
|
||||
currentCustoms = context.apiSuccess(MODULE, '全买单柜完成报关', completedResponse, '', OPTIONS)
|
||||
}
|
||||
context.assert(MODULE, 'customs-v1 全买单柜进入报关完成', currentDetailResponse,
|
||||
currentCustoms?.status === 'COMPLETED' && id(currentCustoms?.loadingPlanId) === loadingPlanId,
|
||||
`status=${currentCustoms?.status || 'missing'}, loadingPlanId=${id(currentCustoms?.loadingPlanId) || 'missing'}`, OPTIONS)
|
||||
if (currentCustoms?.status === 'COMPLETED') {
|
||||
context.createdResources.phase3Customs = {
|
||||
marker: context.marker, tenantId, parentOrderId, orderId: parentOrderId, inboundId,
|
||||
containerBookingId, loadingPlanId, finalStatus: 'CLEARANCE_COMPLETED',
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const slicesPath = `/api/platform/v1/orders/container-bookings/${encodeURIComponent(containerBookingId)}/fulfillment-slices?tenantId=${encodeURIComponent(tenantId)}`
|
||||
const slicesResponse = await context.request('GET', slicesPath)
|
||||
const slices = context.apiSuccess(MODULE, '读取柜次真实履约分片以确定报关订单', slicesResponse,
|
||||
|
||||
Reference in New Issue
Block a user