|
|
|
@@ -17,6 +17,7 @@ function forbidden(response) { return [401, 403].includes(response?.http) || (re
|
|
|
|
|
function trace(response) { return `HTTP=${response?.http ?? 'missing'}, code=${response?.body?.code ?? 'missing'}, requestId=${response?.requestId || 'missing'}, traceId=${response?.traceId || 'missing'}` }
|
|
|
|
|
function key(context, action, suffix = '') { return `${context.marker}-${context.pdaContainerSuffix || ''}-${action}-${suffix}`.replace(/[^A-Za-z0-9:_-]/g, '').slice(0, 120) }
|
|
|
|
|
function markerSuffix(context) { return `${context.marker}${context.pdaContainerSuffix || ''}`.replace(/[^A-Za-z0-9]/g, '').slice(-16).toUpperCase() }
|
|
|
|
|
function records(data) { return Array.isArray(data?.records) ? data.records : Array.isArray(data) ? data : [] }
|
|
|
|
|
|
|
|
|
|
function blockerGap(context, name, reason, category = 'fixture-unavailable', response = null) {
|
|
|
|
|
context.addCoverageGap(MODULE, SCENARIO, name, reason, category, { deploymentBlocker: true })
|
|
|
|
@@ -35,6 +36,23 @@ async function expected(context, token, method, name, path, body, predicate) {
|
|
|
|
|
return response
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function captureCompletedOrder(context, containerNo, expectedCustomerId) {
|
|
|
|
|
const response = await context.requestOverseas('GET',
|
|
|
|
|
`/api/platform/v1/last-leg/orders?page=1&size=200&containerNo=${encodeURIComponent(containerNo)}`)
|
|
|
|
|
const candidates = records(response?.body?.data)
|
|
|
|
|
.filter((item) => id(item?.containerNo) === id(containerNo))
|
|
|
|
|
const exactCustomer = expectedCustomerId == null ? candidates
|
|
|
|
|
: candidates.filter((item) => id(item?.customerId) === id(expectedCustomerId))
|
|
|
|
|
const order = exactCustomer[0] || candidates[0]
|
|
|
|
|
const mapped = success(response) && longId(order?.id) && nonBlank(id(order?.customerId))
|
|
|
|
|
context.assert(MODULE, '完成柜回查平台尾程订单并冻结跨区身份', response, mapped,
|
|
|
|
|
`containerNo=${containerNo}, orderId=${id(order?.id) || 'missing'}, customerId=${id(order?.customerId) || 'missing'}; ${trace(response)}`, OPTIONS)
|
|
|
|
|
if (mapped) {
|
|
|
|
|
context.createdResources.phase4OverseasPda.orderId = id(order.id)
|
|
|
|
|
context.createdResources.phase4OverseasPda.customerId = id(order.customerId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loginMerchantForNegativeProbe(context) {
|
|
|
|
|
const fixture = context.context?.merchantQualificationFixture
|
|
|
|
|
if (!fixture?.username || !fixture?.password) return null
|
|
|
|
@@ -362,11 +380,14 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe
|
|
|
|
|
const after = await context.requestOverseas('GET', '/api/pda/v1/last-leg/receiving-containers/current', undefined, {}, token)
|
|
|
|
|
context.addStep(MODULE, '完成后current返回404正常空态', after, notFound(after), trace(after), OPTIONS)
|
|
|
|
|
context.createdResources.phase4OverseasPda.finalStatus = completed.data?.status || null
|
|
|
|
|
if (context.createdResources.phase4OverseasPda.finalStatus === 'COMPLETED') {
|
|
|
|
|
await captureCompletedOrder(context, containerNo, preferredProducer?.tenantId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function run(context) {
|
|
|
|
|
context.createdResources.phase4OverseasPda = {
|
|
|
|
|
marker: context.marker, containerNo: null, customerId: null,
|
|
|
|
|
marker: context.marker, containerNo: null, customerId: null, orderId: null,
|
|
|
|
|
palletIds: [], locationIds: [], finalStatus: null, pickerMembershipIds: [], completedContainers: [],
|
|
|
|
|
overseasWarehouseId: null, overseasWarehouseName: null,
|
|
|
|
|
cleanup: 'Shared warehouse, pallets and locations used by completed inventory are retained as acceptance evidence',
|
|
|
|
|