diff --git a/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs b/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs
index 05c0ec86..0517f9c3 100644
--- a/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs
+++ b/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs
@@ -256,5 +256,47 @@ namespace YLErp.Modules.SwapModule
}
return "未配置邮件接口地址";
}
+
+ ///
+ /// EQD-5320 批量发送结算确认书邮件:服务端代理 bond-oms /swap/email/settle/batchSend。
+ /// 前端原直连 /trs_hub_api 反向代理(依赖 nginx 配置,未配的环境 404)——统一改走本代理,
+ /// 与债券计算器/SendEmail 同一条 BondOmsInterface_BaseUrl 出口,不再依赖前端网关。
+ /// 返回 空串=成功;非空=失败原因(透传 bond-oms message)。
+ ///
+ public string BatchSendSettleEmail(List swapFlowEventIds)
+ {
+ var baseUrl = Environment.GetEnvironmentVariable("BondOmsInterface_BaseUrl");
+ if (string.IsNullOrEmpty(baseUrl))
+ {
+ return "未配置邮件接口地址(BondOmsInterface_BaseUrl)";
+ }
+ const string url = "/swap/email/settle/batchSend";
+ var logger = LogFactory.GetLogger("SwapEndConfirm");
+ var idsDesc = string.Join(",", swapFlowEventIds);
+ try
+ {
+ var result = new HttpHelper(baseUrl, null)
+ .PostRequestNoAuth(url,
+ new OmsSettleBatchSendReq { swapFlowEventIds = swapFlowEventIds })
+ .Result;
+ logger.Info($"批量发送结算确认书: url={baseUrl}{url} ids=[{idsDesc}] → success={result?.success} message={result?.message}");
+ if (result == null)
+ {
+ return "邮件服务无响应";
+ }
+ return result.success ? "" : (result.message ?? "发送失败");
+ }
+ catch (Exception ex)
+ {
+ logger.Error($"批量发送结算确认书异常: url={baseUrl}{url} ids=[{idsDesc}]", ex);
+ return "请求邮件服务异常:" + ex.GetBaseException().Message;
+ }
+ }
+
+ /// bond-oms SettleEmailSendParam 契约(字段名须与 Java 端一致,Jackson 按 swapFlowEventIds 绑定)
+ private class OmsSettleBatchSendReq
+ {
+ public List swapFlowEventIds { get; set; }
+ }
}
}
diff --git a/YLErpWeb/Controllers/SwapTrade2Controller.cs b/YLErpWeb/Controllers/SwapTrade2Controller.cs
index 33c82881..91512f91 100644
--- a/YLErpWeb/Controllers/SwapTrade2Controller.cs
+++ b/YLErpWeb/Controllers/SwapTrade2Controller.cs
@@ -1207,6 +1207,34 @@ namespace YLErp.Web.Controllers
return JsonSuccess(result);
}
+ ///
+ /// EQD-5320 批量发送结算确认书邮件——经服务端代理 bond-oms(BondOmsInterface_BaseUrl 出口),
+ /// 替代前端直连 /trs_hub_api 反向代理(未配 nginx 的环境 404)。
+ ///
+ /// 平仓流水id,逗号分隔
+ [HttpPost]
+ public JsonResult BatchSendSettleEmail(string swapFlowEventIds)
+ {
+ if (string.IsNullOrWhiteSpace(swapFlowEventIds))
+ {
+ return JsonError("请选择交易");
+ }
+ var ids = new List();
+ foreach (var s in swapFlowEventIds.Split(',', StringSplitOptions.RemoveEmptyEntries))
+ {
+ if (long.TryParse(s.Trim(), out var id))
+ {
+ ids.Add(id);
+ }
+ }
+ if (ids.Count == 0)
+ {
+ return JsonError("平仓流水id解析为空");
+ }
+ var result = new SwapEndConfirmService(CurUser).BatchSendSettleEmail(ids);
+ return string.IsNullOrEmpty(result) ? JsonSuccess("发送成功") : JsonError(result);
+ }
+
}
}
diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/tradeEndConfirmList.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/tradeEndConfirmList.js
index 90eb900d..f6ee26e4 100644
--- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/tradeEndConfirmList.js
+++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/tradeEndConfirmList.js
@@ -167,29 +167,30 @@ function SendEmailEitherReport() {
main.message("请选择普通交易");
return;
}
- var url = "/trs_hub_api/swap/email/settle/batchSend";
- var postData = { swapFlowEventIds: selIds }
+ // EQD-5320: 改走本系统后端代理(/swaptrade2/BatchSendSettleEmail → BondOmsInterface_BaseUrl → bond-oms),
+ // 与债券计算器同一条服务端出口;原直连 /trs_hub_api 反向代理在未配 nginx 的环境 404
+ var url = "/swaptrade2/BatchSendSettleEmail";
+ var postData = { swapFlowEventIds: selIds.join(',') }
$.ajax({
type: "post",
url: url,
- data: JSON.stringify(postData),
+ data: postData,
dataType: "json",
- contentType:"application/json",
success: function (res) {
- // 代理/网关异常时可能返回非标准结构——统一兜底提示,绝不让点击"无反应"
+ // 兜底非标准返回结构,绝不让点击"无反应"
if (res && res.success) {
- main.message("发送成功(共" + selIds.length + "笔),详情见bond-oms日志[结算确认书邮件]");
+ main.message(res.msg || ("发送成功(共" + selIds.length + "笔)"));
SearchClick(); // 刷新列表以反映发送状态
} else {
- var msg = (res && (res.message || res.msg)) || "发送失败:服务返回异常结构";
+ var msg = (res && (res.msg || res.message)) || "发送失败:服务返回异常结构";
main.message(msg);
console.error("[批量发送确认书] 业务失败:", res);
}
},
error: function (xhr, textStatus, errThrown) {
- // 请求层失败:代理不通/超时/返回非JSON(如被登录页重定向)——此前无error回调导致点击"毫无反应"
+ // 请求层失败:超时/返回非JSON(如被登录页重定向)
var detail = "HTTP " + xhr.status + " " + (textStatus || "") + (errThrown ? " " + errThrown : "");
- main.message("发送请求失败(" + detail + "):请检查服务是否可用(含/trs_hub_api代理),详情见控制台与网络面板");
+ main.message("发送请求失败(" + detail + "):请检查服务是否可用,详情见控制台与网络面板");
console.error("[批量发送确认书] 请求失败:", detail, xhr);
},
beforeSend(jqXHR) {