From 4bf34410a32f8bb98eb623c55a9ec98ea79a6086 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Tue, 15 Sep 2026 18:14:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(report):=20=E6=8A=A5=E8=A1=A8=E6=8A=95?= =?UTF-8?q?=E9=80=92/=E9=80=9A=E7=9F=A5=20ext=5Fdata=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E9=80=8F=E4=BC=A0=E7=BE=A4=E9=85=8D=E7=BD=AE=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=B8=A0=E9=81=93=E6=9D=A5=E6=BA=90=20source=20?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit deliverByChannel 与 sendNotifyIfConfigured 原自行组装 extData={report_definition_id,biz_date,time_point,file_url},覆盖了群配置 ext_data(含渠道来源 source),桥接因缺少 source 无法投递;现统一改为 extData = groupRow.ext_data || null(与 notice 推送口径一致),仅成员推送(无群)显式传 null。 --- app/service/systems/reportDelivery.js | 29 ++++++++++++--------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/service/systems/reportDelivery.js b/app/service/systems/reportDelivery.js index 8f4cf6c..d721da5 100644 --- a/app/service/systems/reportDelivery.js +++ b/app/service/systems/reportDelivery.js @@ -976,7 +976,9 @@ class ReportDeliveryService extends Service { * (MAX_RETRY=3,退避 = retry_count × 60s); * 5. 完成后按计划配置附带发送文本通知(与投递渠道独立); * 6. 幂等键含货主维度(report:{store_id}:{report_definition_id}:{biz_date}:{time_point}), - * 不同货主的投递消息互不复用。 + * 不同货主的投递消息互不复用; + * 7. 推送体/消息表 ext_data 一律透传目标群配置的 ext_data(与 notice 推送口径一致), + * 不自行组装报表业务字段(会丢失渠道来源 source,导致桥接投递到错误/缺失渠道)。 * * @param {Object} options 入参 * @param {Object} options.plan 投递计划 @@ -1053,12 +1055,9 @@ class ReportDeliveryService extends Service { }, content: this.buildMessageContent(definition, bizDate, fileUrl), extId: idempotentKey, - extData: { - report_definition_id: reportDefinitionId, - biz_date: bizDate, - time_point: timePoint, - file_url: fileUrl, - }, + // ext_data 必须透传群配置(含渠道来源 source 等):自行组装业务字段会丢失渠道信息, + // 导致桥接按错误/缺失渠道投递(与 notice 推送口径一致:extData = group.ext_data) + extData: groupRow.ext_data || null, }); pushResults.push(pushResult); } @@ -1128,7 +1127,8 @@ class ReportDeliveryService extends Service { * 选择群时成员数组随每个群推送携带,未选择群时单独做一次仅成员推送; * 4. {url} 为空时由渲染器替换为兜底文案(生成中占位),不阻断投递; * 5. 推送失败抛出异常交由上层走失败退避重试(消息落库按 ext_id 幂等防重); - * 6. 幂等键含货主维度(report:notify:{store_id}:...),不同货主的文本通知互不复用。 + * 6. 幂等键含货主维度(report:notify:{store_id}:...),不同货主的文本通知互不复用; + * 7. ext_data 透传通知群配置的 ext_data(不自行组装业务字段);仅成员推送(无群)时传 null。 * * @param {Object} options 入参 * @param {Object} options.plan 投递计划 @@ -1181,18 +1181,14 @@ class ReportDeliveryService extends Service { // 幂等键含货主维度:不同货主的文本通知不得互相复用/串扰(货主限制不符缺陷) const notifyExtId = `report:notify:${storeId}:${reportDefinitionId}:${bizDate}:${timePoint}`; + // ext_data 不在此处组装:群推送透传群配置的 ext_data(含渠道来源), + // 仅成员推送(无群)时无群配置可取,按 null 透传 const commonOptions = { warehouseId, storeId, userIds: memberIds, content: notifyText, extId: notifyExtId, - extData: { - report_definition_id: reportDefinitionId, - biz_date: bizDate, - time_point: timePoint, - file_url: fileUrl, - }, }; const sentGroupIds = []; @@ -1206,12 +1202,13 @@ class ReportDeliveryService extends Service { group_name: groupRow.group_name || '货主群', ext_data: groupRow.ext_data || null, }, + extData: groupRow.ext_data || null, })); sentGroupIds.push(Number(groupRow.id)); } - // 仅成员(未选择任何群):单独一次成员推送,user_id 直接传数组不循环拆发 + // 仅成员(未选择任何群):单独一次成员推送,user_id 直接传数组不循环拆发(无群配置,ext_data 传 null) if (memberIds.length > 0 && results.length === 0) { - results.push(await warehouseNotify.pushSystemMessage(commonOptions)); + results.push(await warehouseNotify.pushSystemMessage({ ...commonOptions, extData: null })); } const failed = results.filter(result => !result || result.success === false);