fix(lastleg): inspect occupied pallets for PDA queries
This commit is contained in:
+7
-1
@@ -29,13 +29,19 @@ test('钱包闭环覆盖充值、授信、采购冻结结算和换标结算释
|
||||
"'RELEASED'",
|
||||
"terminalStatus === 'COMPLETED'",
|
||||
"'CANCELLED'",
|
||||
'relabelPayload(context, warehouseId, suffix, 0.01)',
|
||||
'relabelPayload(context, warehouseId, source, suffix, 0.01)',
|
||||
'/relabel-applications/inventory-candidates',
|
||||
'operationWarehouseId: id(warehouseId)',
|
||||
'sourceInventoryBalanceId:',
|
||||
'sourceInventoryPositionId:',
|
||||
'sourceInboundOrderId:',
|
||||
'cartonMark:',
|
||||
'fbaCartonMark:',
|
||||
]) assert.ok(source.includes(token), token)
|
||||
assert.match(source, /actualBalance[\s\S]*frozenBalance[\s\S]*availableBalance[\s\S]*creditLimit[\s\S]*creditUsed[\s\S]*availableCredit/)
|
||||
assert.match(source, /voucherFileId: id\(files\.find\(\(item\) => item\.category === 'VOUCHER'\)\?\.fileId\)/)
|
||||
assert.doesNotMatch(source, /voucherFileId:\s*Number\(/)
|
||||
assert.doesNotMatch(source, /customerOrderNo:[^\n]+overseasWarehouseId:/)
|
||||
assert.doesNotMatch(source, /internal\/finance|jdbc|mysql|process\.env|https?:\/\//i)
|
||||
})
|
||||
|
||||
|
||||
@@ -169,14 +169,17 @@ async function procurementFlow(context, fixture, overseasToken) {
|
||||
return { orderNo, feeNo, freezePollRequests: frozen.attempts, settlePollRequests: settled.attempts }
|
||||
}
|
||||
|
||||
function relabelPayload(context, warehouseId, suffix, chargeAmount) {
|
||||
function relabelPayload(context, warehouseId, source, suffix, chargeAmount) {
|
||||
const value = String(context.marker).replace(/[^A-Za-z0-9]/g, '').slice(-18).toUpperCase()
|
||||
return {
|
||||
customerOrderNo: `${context.marker}-${suffix}`.slice(0, 128), overseasWarehouseId: id(warehouseId),
|
||||
customerOrderNo: `${context.marker}-${suffix}`.slice(0, 128), operationWarehouseId: id(warehouseId),
|
||||
labelDeadline: new Date(Date.now() + 86_400_000).toISOString().slice(0, 19),
|
||||
contactName: '全量验收联系人', contactPhone: '+1-213-555-0199', chargeAmount,
|
||||
remark: context.marker, idempotencyKey: `${context.marker}-${suffix}`.slice(0, 255),
|
||||
items: [{ skuCode: `OLD-${value}-${suffix}`.slice(0, 128), productNameZh: `${context.marker} 换标商品`,
|
||||
items: [{ sourceInventoryBalanceId: id(source.inventoryBalanceId),
|
||||
sourceInventoryPositionId: id(source.position.positionId), sourceInboundOrderId: id(source.inboundOrderId),
|
||||
skuCode: source.skuCode || `OLD-${value}-${suffix}`.slice(0, 128),
|
||||
productNameZh: source.productNameZh || `${context.marker} 换标商品`,
|
||||
totalPackageCount: 1, notifiedPackageCount: 1, shipmentNo: `SHIP-${value}-${suffix}`.slice(0, 128),
|
||||
newSkuCode: `NEW-${value}-${suffix}`.slice(0, 128), labelRequirement: context.marker,
|
||||
cartonMark: `CM-${value}-${suffix}`.slice(0, 255),
|
||||
@@ -185,7 +188,20 @@ function relabelPayload(context, warehouseId, suffix, chargeAmount) {
|
||||
}
|
||||
|
||||
async function relabelFlow(context, overseasToken, warehouseId, suffix, terminalStatus) {
|
||||
const payload = relabelPayload(context, warehouseId, suffix, 0.01)
|
||||
const candidatesResponse = await context.requestOverseas('GET', query(
|
||||
'/api/merchant/v1/last-leg/relabel-applications/inventory-candidates', { operationWarehouseId: warehouseId }),
|
||||
undefined, {}, overseasToken)
|
||||
const candidates = success(candidatesResponse) && Array.isArray(candidatesResponse.body?.data)
|
||||
? candidatesResponse.body.data : []
|
||||
const source = candidates.find((candidate) => id(candidate.inboundOrderId)
|
||||
&& id(candidate.inventoryBalanceId)
|
||||
&& candidate.positions?.some((position) => id(position.positionId) && Number(position.availablePackages) > 0))
|
||||
if (source) source.position = source.positions.find((position) => id(position.positionId)
|
||||
&& Number(position.availablePackages) > 0)
|
||||
assert(context, `${suffix}换标读取当前客户权威库存候选`, candidatesResponse,
|
||||
Boolean(source?.position), `warehouseId=${warehouseId}, candidates=${candidates.length}`)
|
||||
if (!source?.position) return null
|
||||
const payload = relabelPayload(context, warehouseId, source, suffix, 0.01)
|
||||
const created = await context.requestOverseas('POST', '/api/merchant/v1/last-leg/relabel-applications', payload, {}, overseasToken)
|
||||
const relabelNo = created?.body?.data?.application?.relabelNo
|
||||
assert(context, `${suffix}换标单创建并携带收费金额`, created,
|
||||
|
||||
Reference in New Issue
Block a user