fix: treat missing return records as empty results

This commit is contained in:
2026-09-11 15:01:17 +08:00
parent f7d3a9a73f
commit fdd9302c4d
6 changed files with 69 additions and 11 deletions
+11 -1
View File
@@ -4,6 +4,11 @@ const BASE = '/pda/v1/last-leg/return-inventory'
const encoded = (value) => encodeURIComponent(String(value || '').trim())
const count = (value) => Number.isFinite(Number(value)) ? Math.max(0, Number(value)) : 0
function isNotFound(error) {
const code = String(error?.code || '').toUpperCase()
return code === 'A0404' || code === '404'
}
function normalizeItems(items) {
return Array.isArray(items) ? items.map((item) => ({
skuCode: String(item.skuCode || ''), productNameZh: String(item.productNameZh || ''),
@@ -34,7 +39,12 @@ export function normalizeReturnLabel(value = {}) {
export async function findPackingOrders(returnNo = '') {
const query = String(returnNo || '').trim()
return normalizePackingPreview(await overseasRequest('GET', `${BASE}/packing/orders${query ? `?returnNo=${encoded(query)}` : ''}`))
try {
return normalizePackingPreview(await overseasRequest('GET', `${BASE}/packing/orders${query ? `?returnNo=${encoded(query)}` : ''}`))
} catch (error) {
if (isNotFound(error)) return normalizePackingPreview()
throw error
}
}
export async function mergeReturnCartons(request) {