fix(overseas-pda): localize workflow errors

This commit is contained in:
2026-09-08 17:56:56 +08:00
parent a5c1170da6
commit 8be8f6ac3d
6 changed files with 110 additions and 5 deletions
+33
View File
@@ -95,3 +95,36 @@ export function isNoCurrentReceiving(error) {
export function isReceivingConflict(error) {
return ['409', 'A0409', 'B0409'].includes(String(error?.code || ''))
}
export function toReceivingError(error, fallback = '海外仓作业失败') {
const code = error?.code
const rawMessage = String(error?.message || '').trim()
const palletConflictMessages = {
'Pallet is not idle': '该托盘已被占用,当前不可用于收货,请更换可用托盘',
'Pallet location was not found': '该托盘未关联有效库位,请联系管理员维护后重试',
'Pallet virtual location is not active': '该托盘所在虚拟库位不可用,请更换托盘或联系管理员',
'Pallet location is not idle': '该托盘所在库位已被占用,请更换可用托盘',
'Pallet resource availability could not be verified': '无法确认该托盘是否可用,请更换托盘或联系管理员',
'Pallet does not match an available destination pallet in this inbound code': '该托盘不适用于当前入仓码,请更换符合目的仓要求的可用托盘',
'Pallet is scrapped': '该托盘已报废,请更换可用托盘',
'Pallet belongs to another overseas warehouse': '该托盘属于其他海外仓,当前仓不可使用',
'Pallet FBA destination does not match the inbound code': '该托盘的FBA目的仓与当前入仓码不一致,请更换托盘',
'FBA-designated pallet cannot receive an OVERSEAS destination carton': 'FBA专用托盘不能接收海外仓目的箱,请更换托盘'
}
const conflictMessage = ['409', 'A0409', 'B0409'].includes(String(code || ''))
? palletConflictMessages[rawMessage]
: ''
const palletUnavailable = String(code || '') === 'S0503'
&& rawMessage === 'Warehouse pallet service returned no usable response'
const mapped = Object.assign(new Error(
conflictMessage || (palletUnavailable
? '该托盘当前不可用于收货,请更换可用托盘或联系管理员检查托盘状态'
: rawMessage || fallback)
), {
code,
requestId: error?.requestId,
traceId: error?.traceId,
network: Boolean(error?.network)
})
return mapped
}