fix(report): 报表投递/通知 ext_data 改为透传群配置,避免渠道来源 source 丢失

deliverByChannel 与 sendNotifyIfConfigured 原自行组装 extData={report_definition_id,biz_date,time_point,file_url},覆盖了群配置 ext_data(含渠道来源 source),桥接因缺少 source 无法投递;现统一改为 extData = groupRow.ext_data || null(与 notice 推送口径一致),仅成员推送(无群)显式传 null。
This commit is contained in:
liufumingren 2026-09-15 18:14:43 +08:00
parent aff7a4fe22
commit 4bf34410a3

View File

@ -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);