fix: close phase4 overseas acceptance gaps

This commit is contained in:
2026-08-24 21:00:22 +08:00
parent 005c3f54e2
commit 3607bebbfd
42 changed files with 860 additions and 203 deletions
@@ -55,6 +55,13 @@ function assertPage(context, name, result) {
function businessConflict(response) {
return response?.http === 409 || (response?.http === 200 && String(response?.body?.code) === 'A0409')
}
function voidMutationSucceeded(result) {
return result?.response?.http === 200 && String(result?.response?.body?.code) === '200'
&& result.data == null
}
function businessNotFound(response) {
return response?.http === 404 || (response?.http === 200 && String(response?.body?.code) === 'A0404')
}
export async function run(context) {
context.createdResources.phase4OverseasWarehouse = { marker: context.marker, customerId: null, warehouseId: null, palletId: null, terminalStatus: null }
@@ -216,7 +223,7 @@ async function verifyLocationLifecycle(context, warehouseId) {
zoneCode: 'ACC', locationCode, locationType: 'STORAGE', maxLoadKg: 1200,
status: 'ACTIVE', remark: `${context.marker}-edited`,
})
context.assert(MODULE, '公共库位编辑成功', updated.response, updated.data === null,
context.assert(MODULE, '公共库位编辑成功', updated.response, voidMutationSucceeded(updated),
`locationId=${locationId}; ${trace(updated.response)}`, OPTIONS)
const after = await overseasGet(context, '回查公共库位编辑结果', detailPath)
context.assert(MODULE, '公共库位编辑字段已生效', after.response,
@@ -226,9 +233,12 @@ async function verifyLocationLifecycle(context, warehouseId) {
if (locationId) {
const removed = await overseasMutation(context, 'DELETE', '删除本轮公共库位',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`)
context.createdResources.phase4OverseasWarehouse.locationTerminalStatus = removed.data === null ? 'DELETED' : null
context.assert(MODULE, '本轮公共库位已删除收口', removed.response, removed.data === null,
`locationId=${locationId}, terminalStatus=${context.createdResources.phase4OverseasWarehouse.locationTerminalStatus || 'missing'}; ${trace(removed.response)}`, OPTIONS)
const deletedDetail = await context.requestOverseas('GET',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`)
const deleted = voidMutationSucceeded(removed) && businessNotFound(deletedDetail)
context.createdResources.phase4OverseasWarehouse.locationTerminalStatus = deleted ? 'DELETED' : null
context.assert(MODULE, '本轮公共库位已删除且回查不存在', deletedDetail, deleted,
`locationId=${locationId}, terminalStatus=${context.createdResources.phase4OverseasWarehouse.locationTerminalStatus || 'missing'}; delete=${trace(removed.response)}, readback=${trace(deletedDetail)}`, OPTIONS)
}
}
}
@@ -354,7 +364,7 @@ async function verifyPalletLifecycle(context, warehouseId) {
palletCode, palletType: '木托盘', capacityCbm: 2.5, unitPrice: 1, status: 'IDLE',
locationId: id(detail.data?.locationId) || undefined, remark: `${context.marker}-edited`, version: Number(detail.data?.version),
})
context.assert(MODULE, '公共托盘编辑成功', updated.response, updated.data === null,
context.assert(MODULE, '公共托盘编辑成功', updated.response, voidMutationSucceeded(updated),
`palletId=${palletId}; ${trace(updated.response)}`, OPTIONS)
const after = await overseasGet(context, '回查公共托盘编辑结果', detailPath)
context.assert(MODULE, '公共托盘编辑字段已生效', after.response,
@@ -376,8 +386,8 @@ async function verifyPalletLifecycle(context, warehouseId) {
'读取公共托盘报废前最新版本',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`)).data?.version),
})
context.createdResources.phase4OverseasWarehouse.terminalStatus = retired.data === null ? 'SCRAPPED' : null
context.assert(MODULE, '本轮公共托盘已报废收口', retired.response, retired.data === null,
context.createdResources.phase4OverseasWarehouse.terminalStatus = voidMutationSucceeded(retired) ? 'SCRAPPED' : null
context.assert(MODULE, '本轮公共托盘已报废收口', retired.response, voidMutationSucceeded(retired),
`palletId=${palletId}, terminalStatus=${context.createdResources.phase4OverseasWarehouse.terminalStatus || 'missing'}; ${trace(retired.response)}`, OPTIONS)
const retiredDetail = await overseasGet(context, '回查本轮公共托盘报废状态',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`)