test(acceptance): reuse fixed customers and align native fulfillment flows

This commit is contained in:
2026-10-23 04:48:02 +08:00
parent b92f7fe991
commit 139f6b1932
51 changed files with 1076 additions and 228 deletions
@@ -38,15 +38,28 @@ export async function resolveF40ReceivingWarehouse(context, producers) {
&& new Set(producers.map(row => id(row.tenantId))).size === 1, 'exact-producer-identities')
const sources = []
for (const producer of producers) {
const page = await api(context, 'GET', 'F40 读取本柜实际尾程来源与接柜仓',
query('/api/platform/v1/last-leg/orders', { page: 1, size: 200, containerNo: producer.containerNo }))
const rows = Array.isArray(page?.records) ? page.records : []
const rows = [], seen = new Set(); let total
for (let page = 1; page <= 100; page++) {
const data = await api(context, 'GET', 'F40 读取本柜实际尾程来源与接柜仓',
query('/api/platform/v1/last-leg/orders', { page, size: 200, containerNo: producer.containerNo }))
check(context, 'F40 来源柜客户入仓身份分页完整且总数稳定', Array.isArray(data?.records)
&& Number.isSafeInteger(Number(data.total)) && Number(data.total) >= 0
&& (total === undefined || total === Number(data.total)) && data.records.length <= 200
&& (data.records.length > 0 || rows.length === Number(data.total)), `page=${page}`)
total ??= Number(data.total)
for (const row of data.records) {
const key = `${id(row.customerId)}:${id(row.id)}`
check(context, 'F40 来源柜客户入仓身份分页无重复或缺失', Boolean(id(row.id)) && !seen.has(key), `page=${page}`)
seen.add(key); rows.push(row)
}
if (rows.length >= total) break
}
check(context, 'F40 来源柜客户入仓身份分页完整', rows.length === total, `rows=${rows.length}, total=${total}`)
const matching = rows.filter(row => row.containerNo === producer.containerNo
&& id(row.sourceContainerBookingId) === id(producer.containerBookingId)
&& id(row.customerId) === id(producer.tenantId)
&& id(row.sourceInboundId) === id(producer.sourceInboundId) && row.inboundCode === producer.inboundCode)
check(context, 'F40 尾程来源柜客户入仓身份唯一且接柜仓明确', matching.length === 1
&& (page?.total == null || Number(page.total) <= rows.length)
&& Boolean(id(matching[0]?.id) && id(matching[0]?.overseasWarehouseId)),
`container=${producer.containerNo}, exactSources=${matching.length}`)
sources.push(matching[0])
@@ -504,8 +517,12 @@ export async function sendFragment(context, producer, picker, merchantToken, ind
context.createdResources.phase5OverseasFulfillment = dispatchProof
context = await fulfillmentEvidenceContext(context)
try {
const planIds = context.createdResources?.phase4OverseasPda?.generatedPlanIds
check(context, 'F40 正式候选限定本轮转换计划', Array.isArray(planIds) && planIds.length > 0
&& planIds.every(value => /^[1-9][0-9]*$/.test(id(value))) && new Set(planIds.map(id)).size === planIds.length,
'current-converted-plan-scope')
const candidates = await api(context, 'GET', '读取该来源入仓码原生实收排车候选',
query(`${DISPATCH}/candidates`, { warehouseId }))
query(`${DISPATCH}/candidates`, { warehouseId, sourceStage: 'RECEIVED', planIds: planIds.map(id).join(','), page: 1, size: 50 }))
check(context, 'F40 正式候选列表完整', candidates?.complete === true && Array.isArray(candidates.candidates), 'native-complete-candidate-list')
const matches = candidates.candidates.filter(row => row.selection?.sourceType === 'INBOUND_PLAN'
&& row.inboundCode === producer.inboundCode && id(row.customerId) === customerId && id(row.warehouseId) === warehouseId)