From 9cc301916ea892d9deb5d7360ab480bd8f9ee61f Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sat, 7 Nov 2026 08:01:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(external-send):=20=E5=8F=91=E8=B4=A7?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A4=B1=E8=B4=A5=E7=BB=99=E5=87=BA=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E5=8E=9F=E5=9B=A0=EF=BC=8C=E5=89=8D=E7=AB=AF=E5=8F=AF?= =?UTF-8?q?=E7=9C=8B=E5=85=A8=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现象:配送列表只显示「店管家发货同步失败:请先」,看不出到底缺什么。 - dgj.sendOrders:失败时拼上平台 ErrorCode、逐单错误(Data[].IsError/ErrMsg/Message), 并在订单没有运单号时补一句「N 单在店管家还没有运单号(可能未取号/未打印面单)」 - StatusPanel:同步失败原因加 tooltip,鼠标悬停可看完整文案(原来只有 CSS 省略号) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- backend/app/lib/printPlatform/dgj.js | 37 +++++++++++++++++++++++- frontend/src/views/Order/StatusPanel.vue | 4 ++- 2 files changed, 39 insertions(+), 2 deletions(-) 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 }}
+