fix(swap): EQD-5320 批量发送确认书改走C#服务端代理——原前端直连/trs_hub_api反向代理在未配nginx的环境404(UAT实测),与计算器(SendConfirmEamil同款BondOmsInterface_BaseUrl服务端出口)通路不一致;新增SwapEndConfirmService.BatchSendSettleEmail(POST代理bond-oms batchSend,契约DTO+成败日志)与SwapTrade2Controller.BatchSendSettleEmail(逗号id串防呆解析);前端改调同源/swaptrade2端点保留error兜底;232/232前端测试通过
This commit is contained in:
@@ -256,5 +256,47 @@ namespace YLErp.Modules.SwapModule
|
||||
}
|
||||
return "未配置邮件接口地址";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EQD-5320 批量发送结算确认书邮件:服务端代理 bond-oms /swap/email/settle/batchSend。
|
||||
/// 前端原直连 /trs_hub_api 反向代理(依赖 nginx 配置,未配的环境 404)——统一改走本代理,
|
||||
/// 与债券计算器/SendEmail 同一条 BondOmsInterface_BaseUrl 出口,不再依赖前端网关。
|
||||
/// 返回 空串=成功;非空=失败原因(透传 bond-oms message)。
|
||||
/// </summary>
|
||||
public string BatchSendSettleEmail(List<long> 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<OmsSettleBatchSendReq, SendEmailResult>(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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>bond-oms SettleEmailSendParam 契约(字段名须与 Java 端一致,Jackson 按 swapFlowEventIds 绑定)</summary>
|
||||
private class OmsSettleBatchSendReq
|
||||
{
|
||||
public List<long> swapFlowEventIds { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,6 +1207,34 @@ namespace YLErp.Web.Controllers
|
||||
return JsonSuccess(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EQD-5320 批量发送结算确认书邮件——经服务端代理 bond-oms(BondOmsInterface_BaseUrl 出口),
|
||||
/// 替代前端直连 /trs_hub_api 反向代理(未配 nginx 的环境 404)。
|
||||
/// </summary>
|
||||
/// <param name="swapFlowEventIds">平仓流水id,逗号分隔</param>
|
||||
[HttpPost]
|
||||
public JsonResult BatchSendSettleEmail(string swapFlowEventIds)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(swapFlowEventIds))
|
||||
{
|
||||
return JsonError("请选择交易");
|
||||
}
|
||||
var ids = new List<long>();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user