diff --git a/backend/app/lib/printPlatform/dgj.js b/backend/app/lib/printPlatform/dgj.js index 4dc9dd1..e005e7a 100644 --- a/backend/app/lib/printPlatform/dgj.js +++ b/backend/app/lib/printPlatform/dgj.js @@ -81,6 +81,27 @@ function buildPlatformError(message, res) { return error; } +/** + * 收集发货回传响应里的逐单错误(各平台结构不统一,这里按常见字段兜底) + * @param {Object} json 平台响应 + * @return {string[]} 可读错误文案 + */ +function describeSendErrors(json) { + const out = []; + const data = json && json.Data; + const list = Array.isArray(data) ? data : (data && Array.isArray(data.List) ? data.List : []); + for (const item of list) { + if (!item || typeof item !== 'object') continue; + const isError = item.IsError === true || Number(item.IsError) === 1; + const message = item.ErrorMsg || item.ErrMsg || item.Message || (isError ? '平台返回失败' : ''); + if (!message) continue; + const code = item.LogicOrderId || item.OrderCode || item.PlatformOrderId || ''; + out.push(code ? `${code}: ${message}` : message); + } + // 去重但保留顺序 + return [ ...new Set(out) ].slice(0, 3); +} + /** 订单列表单页条数(平台允许 500) */ const ORDER_PAGE_SIZE = 500; @@ -2848,7 +2869,21 @@ class DgjService extends PrintPlatformService { throw buildPlatformError(`店管家登录已失效:${(res.json && res.json.Message) || 'token is invalid'}`, res); } if (!res.json || res.json.Success !== true) { - const reason = (res.json && (res.json.Message || res.json.ErrorCode)) || `HTTP ${res.status}`; + const json = res.json || {}; + const hints = []; + if (json.ErrorCode !== undefined && json.ErrorCode !== null && String(json.ErrorCode) !== '') { + hints.push(`ErrorCode=${json.ErrorCode}`); + } + hints.push(...describeSendErrors(json)); + // 平台对「这一单还没运单号」只回一句「请先…」,补一句本地判断,避免只看到半句话 + const missingWaybill = orders.filter(item => !String(item.WaybillCode || '').trim()).length; + if (missingWaybill) { + hints.push(`其中 ${missingWaybill} 单在店管家还没有运单号(可能未取号/未打印面单)`); + } + const reason = [ + json.Message || `HTTP ${res.status}`, + ...hints, + ].filter(Boolean).join(';'); throw buildPlatformError(`店管家发货同步失败:${reason}`, res); } return res.json; diff --git a/frontend/src/views/Order/StatusPanel.vue b/frontend/src/views/Order/StatusPanel.vue index 42dfc79..f0be8cd 100644 --- a/frontend/src/views/Order/StatusPanel.vue +++ b/frontend/src/views/Order/StatusPanel.vue @@ -1007,7 +1007,9 @@ onBeforeUnmount(() => { 第 {{ row.external_send_times }} 次 -
{{ row.external_send_error }}
+ +
{{ row.external_send_error }}
+