From 4e53f822ab9cd483660b39f3a4dc18e87a95a7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Fri, 29 May 2026 14:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=98=E4=B8=AD=E9=83=A8=E5=88=86=E5=B9=B3?= =?UTF-8?q?=E4=BB=93=E9=80=BB=E8=BE=91=E6=8C=AA=E5=88=B0=E5=86=85=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/SwapModule/SwapDealService.cs | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 6096a395..8772ad0c 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -333,18 +333,7 @@ namespace YLErp.Modules.SwapModule var grossPrice = realPostitions.Where(x => x.PosiDirection > 0).FirstOrDefault()?.PosiGrossPrice; var closeList = DbContext.swap_flow_event.Where(x => x.SwapTradeId == tradeId && x.UnwindDate == unwindDate && eventTypes.Contains(x.EventType) && x.DataState == (int)SwapFlowDateStateEnum.完成).ToList(); bool tdClose = closeList.Count > 0; - interests = GetInterests(td, tradeExtend, valueDate, unwindDate, lastEodPositions, positions, stockEqvNotional, posiLongNotionalValue, posiShortNotionalValue, posiNotionalValue, closePercent, eventType, tdClose, false, grossPrice ?? 0, orginPv, true, false); - //当日有平仓或互换记录时,需要把平仓或互换已经结算的利息从计算结果中扣除,避免重复计算 - foreach (var item in interests) - { - var closeEvent = closeList.Where(x => x.PositionId == item.PositionId); - var closePnl = closeEvent.Sum(s=>s.InterestClosePnL); - var closeAmount = closeEvent.Sum(s=>s.InterestAmount); - var closeTdAmount= closeEvent.Sum(s=>s.TdInterestAmount); - item.InterestAmount=item.InterestAmount-closeAmount; - item.TdInterestAmount=item.TdInterestAmount-closeTdAmount; - item.InterestClosePnL= item.InterestClosePnL-closePnl; - } + interests = GetInterests(td, tradeExtend, valueDate, unwindDate, lastEodPositions, positions, stockEqvNotional, posiLongNotionalValue, posiShortNotionalValue, posiNotionalValue, closePercent, eventType, tdClose, false, grossPrice ?? 0, orginPv, true, false, closeList); return interests; } /// @@ -382,7 +371,8 @@ namespace YLErp.Modules.SwapModule decimal grossPrice, decimal orginPv, bool add = false, - bool settment = true) + bool settment = true, + List closeList = null) { List interests = new List(); var annualDays = tradeExtend == null ? 365 : tradeExtend.ExtendObj.AnnualDays; @@ -422,6 +412,20 @@ namespace YLErp.Modules.SwapModule interests.Add(CalcUnwindInterest(td, valueDate, endDate, positionClone, rate, floatRate, posiPrincipal, closePrincipal, newClosePercent, annualDays, preEodPosition, eventType, add, swap, orginPv, calcFirst, calcLast)); } } + //当日有平仓或互换记录时,需要把平仓或互换已经结算的利息从计算结果中扣除,避免重复计算 + if (closeList != null && closeList.Count > 0) + { + foreach (var item in interests) + { + var closeEvent = closeList.Where(x => x.PositionId == item.PositionId); + var closePnl = closeEvent.Sum(s => s.InterestClosePnL); + var closeAmount = closeEvent.Sum(s => s.InterestAmount); + var closeTdAmount = closeEvent.Sum(s => s.TdInterestAmount); + item.InterestAmount = item.InterestAmount - closeAmount; + item.TdInterestAmount = item.TdInterestAmount - closeTdAmount; + item.InterestClosePnL = item.InterestClosePnL - closePnl; + } + } return interests; }