From 1cc195cb781fb92b3f6c02af4eee7d8a2ffd1cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Tue, 3 Jun 2025 13:25:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E9=87=91=E7=9B=91=E6=8E=A7=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=AD=97=E8=8A=82=E6=B5=81=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RealTimeClientBanlanceService.cs | 5 ++-- .../SettlementModule/EodClientBalanceCalc.cs | 9 +++---- YLErpWeb/Controllers/clientController.cs | 9 ++++++- .../Scripts/app/client/clientRiskMonitor.js | 24 ++++++++++++++++--- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index 096f7cff..727a2448 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -328,7 +328,7 @@ namespace YLErp.BLL.Eod select t; ProcessAllTrades(tQuery); - ProcessTodayFinishedTrades(startDate, tQuery); + //ProcessTodayFinishedTrades(startDate, tQuery); ProcessTodayTradesAfterConfirmed(); } @@ -1197,6 +1197,7 @@ namespace YLErp.BLL.Eod else if (data.action == "应收^" + ClientCashInCashOut.系统操作_平仓费) { balance.SwapBalance += data.moneySum; + balance.WinLoss += data.moneySum; } else if (data.action == "入金^") { @@ -1309,7 +1310,7 @@ namespace YLErp.BLL.Eod { balance.UpdateDate = balance.UpdateDate > lastEodSwap.OptTime ? balance.UpdateDate : lastEodSwap.OptTime; } - balance.WinLoss += Convert.ToDouble(tdRealizedPnL) * -1; + //balance.WinLoss += Convert.ToDouble(tdRealizedPnL) * -1; balance.PositionPnl += Convert.ToDouble(pnl) * -1; balance.RoundedPositionPnl += Math.Round(Convert.ToDouble(pnl), 2) * -1; //期权空头浮动盈利=∑max(期权空头持仓*(期权合约成本价-期权合约现价), 0) 从客户角度看的 diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs index e620f40c..d0402e7a 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs @@ -611,11 +611,13 @@ namespace YLErp.Modules.EodModule.SettlementModule { CurrChangeAmount += clientEntryexit.Money ?? 0.0; SwapBalance += clientEntryexit.Money ?? 0.0; + WinLoss += clientEntryexit.Money ?? 0.0; } else if (ClientCashInCashOut.系统操作_互换.Equals(clientEntryexit.Action)) { CurrChangeAmount += clientEntryexit.Money ?? 0.0; SwapBalance += clientEntryexit.Money ?? 0.0; + WinLoss += clientEntryexit.Money ?? 0.0; } if (ClientCashInCashOut.已确认.Equals(clientEntryexit.State)) @@ -804,11 +806,6 @@ namespace YLErp.Modules.EodModule.SettlementModule var todaySwapFinishedTradeIds = todaySwapFinishedTrades.Select(s => s.id).ToList(); var todaySwapFinishedCash = clientEntryexits_swap.Where(x => todaySwapFinishedTradeIds.Contains(x.TradeId ?? 0)).ToList(); var list = todayFinishedTradeCash.ToList(); - WinLoss = todayFinishedTrades.ToArray().Sum(t => - t.TradeType != "远期" ? - -TradeCalcHelper.GetSign(t.BuySell) * (t.TradePrice ?? 0) * finishedTradeNotionalPercentDic[t.id] + (todayFinishedTradeCash.FirstOrDefault(x => x.tradeId == t.id)?.amountSum ?? 0) - // 远期客户角度的实现盈亏 = 开仓总费用+平仓总费用 - : (t.TradePrice ?? 0) * finishedTradeNotionalPercentDic[t.id] + (todayFinishedTradeCash.FirstOrDefault(x => x.tradeId == t.id)?.amountSum ?? 0)) * -1; //了结开仓费用 EndPremium = todayFinishedTrades.Sum(t => t.TradeType != "远期" ? -TradeCalcHelper.GetSign(t.BuySell) * (t.TradePrice ?? 0) * finishedTradeNotionalPercentDic[t.id] : (t.TradePrice ?? 0) * finishedTradeNotionalPercentDic[t.id]) * -1; EndPremium = EndPremium + todaySwapFinishedCash.Sum(s => s.Money ?? 0); @@ -850,7 +847,7 @@ namespace YLErp.Modules.EodModule.SettlementModule var lastEodSwapPosition = eodSwapPosis.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == preBalanceDate&&t.PosiStartDate<= preBalanceDate); var eodSwapPosition = clientEodSwapPositionLast.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == balanceDate && t.PosiStartDate <= balanceDate); PotentialSurpluses += Convert.ToDouble(item.PostionValue) * (-1); - WinLoss += Convert.ToDouble(item.TdRealizedPnL) * (-1); + // WinLoss += Convert.ToDouble(item.TdRealizedPnL) * (-1); var lastPv = lastEodSwap != null ? Convert.ToDouble(lastEodSwap.PostionValue- lastEodSwapPosition?.VTradingFee+lastEodSwapPosition?.PosiFeePending) * (-1) : 0; eodPnlSum.LastPvSum = eodPnlSum.LastPvSum.HasValue ? eodPnlSum.LastPvSum + lastPv : lastPv; var pnl = item.PostionValue- eodSwapPosition?.VTradingFee+ eodSwapPosition?.PosiFeePending; diff --git a/YLErpWeb/Controllers/clientController.cs b/YLErpWeb/Controllers/clientController.cs index c770f1d9..fa8739f6 100644 --- a/YLErpWeb/Controllers/clientController.cs +++ b/YLErpWeb/Controllers/clientController.cs @@ -924,7 +924,14 @@ namespace YLErp.Web.Controllers ExcelPackage.LicenseContext = LicenseContext.NonCommercial; new ExcelTemplateGenerator().SetTemplateFile(sourceFileName).SetTemplateData(modleDict).OutputToFile(result.PhysicalPath); - return JsonSuccess("导出资金监控成功", result.WebPath); + // 读取字节流 + byte[] fileBytes = System.IO.File.ReadAllBytes(result.PhysicalPath); + + // 删除临时文件 + System.IO.File.Delete(result.PhysicalPath); + + // 返回文件流 + return File(fileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", targetFileName); } [HttpPost] diff --git a/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js b/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js index 7f405253..e437b0ec 100644 --- a/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js +++ b/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js @@ -448,9 +448,27 @@ function execExport() { postData.StartDate = $("#startDate").val(); postData.ValueDate = $("#endDate").val(); postData.MarginShownType = $("#ShownType").val(); - main.post("/client/ClientBanlanceExport", postData).done(function (res) { - main.downloadFiles(res.obj); - }); + // 构造并提交表单 + var $form = $('
'); + $form.attr('action', '/client/ClientBanlanceExport'); + for (var key in postData) { + if (postData.hasOwnProperty(key)) { + var value = postData[key]; + if (Array.isArray(value)) { + value.forEach(function (v) { + $form.append($('').val(v)); + }); + } else { + $form.append($('').val(value)); + } + } + } + $('body').append($form); + $form.submit(); + $form.remove(); + //main.post("/client/ClientBanlanceExport", postData).done(function (res) { + // // main.downloadFiles(res.obj); + //}); parent.layer.closeAll(); }