From 0567955434b1d2b881636b919c6b5d88e2c3a864 Mon Sep 17 00:00:00 2001 From: hjhan Date: Fri, 21 Aug 2026 09:40:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(swap):=20EQD-5320=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=A1=AE=E8=AE=A4=E4=B9=A6=E6=94=B9=E8=B5=B0?= =?UTF-8?q?C#=E6=9C=8D=E5=8A=A1=E7=AB=AF=E4=BB=A3=E7=90=86=E2=80=94?= =?UTF-8?q?=E2=80=94=E5=8E=9F=E5=89=8D=E7=AB=AF=E7=9B=B4=E8=BF=9E/trs=5Fhu?= =?UTF-8?q?b=5Fapi=E5=8F=8D=E5=90=91=E4=BB=A3=E7=90=86=E5=9C=A8=E6=9C=AA?= =?UTF-8?q?=E9=85=8Dnginx=E7=9A=84=E7=8E=AF=E5=A2=83404(UAT=E5=AE=9E?= =?UTF-8?q?=E6=B5=8B)=EF=BC=8C=E4=B8=8E=E8=AE=A1=E7=AE=97=E5=99=A8(SendCon?= =?UTF-8?q?firmEamil=E5=90=8C=E6=AC=BEBondOmsInterface=5FBaseUrl=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E5=87=BA=E5=8F=A3)=E9=80=9A=E8=B7=AF?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=EF=BC=9B=E6=96=B0=E5=A2=9ESwapEndCo?= =?UTF-8?q?nfirmService.BatchSendSettleEmail(POST=E4=BB=A3=E7=90=86bond-om?= =?UTF-8?q?s=20batchSend,=E5=A5=91=E7=BA=A6DTO+=E6=88=90=E8=B4=A5=E6=97=A5?= =?UTF-8?q?=E5=BF=97)=E4=B8=8ESwapTrade2Controller.BatchSendSettleEmail(?= =?UTF-8?q?=E9=80=97=E5=8F=B7id=E4=B8=B2=E9=98=B2=E5=91=86=E8=A7=A3?= =?UTF-8?q?=E6=9E=90)=EF=BC=9B=E5=89=8D=E7=AB=AF=E6=94=B9=E8=B0=83?= =?UTF-8?q?=E5=90=8C=E6=BA=90/swaptrade2=E7=AB=AF=E7=82=B9=E4=BF=9D?= =?UTF-8?q?=E7=95=99error=E5=85=9C=E5=BA=95=EF=BC=9B232/232=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SwapModule/SwapEndConfirmService.cs | 42 +++++++++++++++++++ YLErpWeb/Controllers/SwapTrade2Controller.cs | 28 +++++++++++++ .../app/swaptrade/tradeEndConfirmList.js | 19 +++++---- 3 files changed, 80 insertions(+), 9 deletions(-) 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) {