fix: bind overseas receiving to shared warehouse
This commit is contained in:
@@ -635,7 +635,7 @@ export async function run(context) {
|
||||
const overflowResource = inventoryInbound?.resources?.find?.((resource) =>
|
||||
resource?.sharedOverflow === true && id(resource?.occupancyId))
|
||||
if (overflowResource) {
|
||||
const mutationSuffix = context.marker.replace(/\D/g, '').slice(-10)
|
||||
const mutationSuffix = markerSuffix(context.marker)
|
||||
const targetLocationResponse = await context.request('POST', '/api/platform/v1/locations?tenantId=0', {
|
||||
warehouseId, zoneCode: `SNAP-${mutationSuffix.slice(-6)}`, zoneName: '库存快照验收区',
|
||||
locationCode: `SNAP-${mutationSuffix}`, locationName: '库存快照换绑库位',
|
||||
@@ -644,6 +644,11 @@ export async function run(context) {
|
||||
})
|
||||
const targetLocationId = id(context.apiSuccess(MODULE, '创建库存快照变化目标库位',
|
||||
targetLocationResponse, '', OPTIONS))
|
||||
if (!targetLocationId) {
|
||||
context.addStep(MODULE, '库存变化fixture创建失败后停止旧snapshot提交', targetLocationResponse,
|
||||
false, responseEvidence(targetLocationResponse), OPTIONS)
|
||||
return
|
||||
}
|
||||
if (targetLocationId) {
|
||||
inventoryMutationCleanup = {
|
||||
cleaned: false, targetLocationId,
|
||||
@@ -664,11 +669,17 @@ export async function run(context) {
|
||||
})
|
||||
: targetLocationResponse
|
||||
const rebound = context.apiSuccess(MODULE, '通过公开 A0 换绑接口制造真实库存变化', rebindResponse, '', OPTIONS)
|
||||
const reboundValid = id(rebound?.occupancyId) === id(overflowResource.occupancyId)
|
||||
&& id(rebound?.previousLocationId) === id(overflowResource.locationId)
|
||||
&& id(rebound?.locationId) === targetLocationId
|
||||
context.assert(MODULE, '真实库存换绑保持同仓且位置发生变化', rebindResponse,
|
||||
id(rebound?.occupancyId) === id(overflowResource.occupancyId)
|
||||
&& id(rebound?.previousLocationId) === id(overflowResource.locationId)
|
||||
&& id(rebound?.locationId) === targetLocationId,
|
||||
reboundValid,
|
||||
`occupancyId=${id(rebound?.occupancyId) || 'missing'}, previousLocationId=${id(rebound?.previousLocationId) || 'missing'}, locationId=${id(rebound?.locationId) || 'missing'}`, OPTIONS)
|
||||
if (!reboundValid) {
|
||||
context.addStep(MODULE, '库存换绑未成功后停止旧snapshot提交', rebindResponse,
|
||||
false, responseEvidence(rebindResponse), OPTIONS)
|
||||
return
|
||||
}
|
||||
|
||||
const staleInventoryBatch = await request(context, 'POST', batchPath, batchPayload,
|
||||
{ 'Idempotency-Key': `${context.marker}-bridge-batch-stale-inventory`.slice(0, 128) })
|
||||
|
||||
Reference in New Issue
Block a user