From 535497c68acbecbe1a25a7507b3334bd3c245555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Thu, 4 Jun 2026 13:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E5=88=B0=E5=B9=B3=E4=BB=93=E6=88=96?= =?UTF-8?q?=E4=BA=92=E6=8D=A2=E5=88=A9=E6=81=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/SwapModule/SwapDealService.cs | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 3fd21bf8..fe89dd14 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -413,20 +413,32 @@ namespace YLErp.Modules.SwapModule interests.Add(CalcUnwindInterest(td, valueDate, endDate, positionClone, rate, floatRate, posiPrincipal, closePrincipal, newClosePercent, annualDays, preEodPosition, eventType, add, swap, orginPv, calcFirst, calcLast||newCalcLast)); } } - //当日有平仓或互换记录时,需要把平仓或互换已经结算的利息从计算结果中扣除,避免重复计算 - //互换始终需要扣除;平仓仅不算尾时需要(算尾时利息已包含关闭日,无重叠) - if (closeList != null && closeList.Count > 0 - && (eventType == (int)SwapEventTypeEnum.自动互换 || (!calcLast && !newCalcLast))) + //当日有平仓或互换记录时,避免重复结算 + 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; + if (eventType == (int)SwapEventTypeEnum.互换 || eventType == (int)SwapEventTypeEnum.自动互换) + { + // 互换:该仓位当天已有完成事件,直接归0 + if (closeEvent.Any()) + { + item.InterestAmount = 0; + item.TdInterestAmount = 0; + item.InterestClosePnL = 0; + } + } + else if (!calcLast && !newCalcLast) + { + // 平仓不算尾:扣除已结算的利息(算尾时利息已包含关闭日,无重叠) + 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;