test(firstleg): parse platform warehouse scope explicitly

This commit is contained in:
2026-09-01 10:17:41 +08:00
parent 3d6216910f
commit cdcf3e0f4f
2 changed files with 16 additions and 3 deletions
@@ -14,6 +14,10 @@ function data(response) { return codeOf(response) === '200' ? response.body.data
function failure(response) { return response?.http === 0 || response?.http >= 400 || (response?.http === 200 && codeOf(response) !== '200') }
function records(value) { return Array.isArray(value) ? value : value?.records || [] }
export function platformWarehouseIdentity(item) {
return { warehouseId: id(item?.warehouseId || item?.id || item?.warehouse?.id), platformTenantId: '0' }
}
async function request(context, method, path, body, headers = {}) {
try {
const response = await fetch(`${context.options.gateway}${path}`, {
@@ -67,7 +71,7 @@ async function bookingMaster(context, suffix) {
const customerName = String(context.options?.customerName || `全量验收下单客户-${suffix}`).trim()
const warehousesResponse = await request(context, 'GET', '/api/platform/v1/warehouse-admin?tenantId=0&status=ACTIVE&page=1&size=100')
for (const item of records(data(warehousesResponse))) {
const warehouseId = id(item?.id || item?.warehouse?.id)
const { warehouseId } = platformWarehouseIdentity(item)
if (!warehouseId) continue
const channelsResponse = await request(context, 'GET', `${BOOKINGS}/channels?originWarehouseId=${warehouseId}`)
const channel = (data(channelsResponse) || [])[0]
@@ -75,7 +79,7 @@ async function bookingMaster(context, suffix) {
channelCode: channel.channelCode, channelName: channel.channelName }
}
context.addStep(MODULE, '解析具备有效海运渠道的平台仓库', warehousesResponse, false,
`tenantId=${tenantId || 'missing'}`, OPTIONS)
`platformTenantId=0, customerId=${tenantId || 'missing'}`, OPTIONS)
return null
}