From 5ee62775b73db30c4467e90f3ac7e17afb5bc6c1 Mon Sep 17 00:00:00 2001 From: gongpei Date: Thu, 23 Oct 2025 18:58:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=A1=E7=AE=97=E5=B9=B3=E4=BB=93?= =?UTF-8?q?=E5=88=86=E7=BA=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YLErpDAL/Modules/SwapModule/SwapDealService.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 23490925..09862168 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -910,10 +910,21 @@ namespace YLErp.Modules.SwapModule private void EnrichDividendIn(swap_flow_event flowEvent, decimal unwindQty) { - // 平仓数量/平仓前的数量*平仓对象的待实现分红收益,保留2位小数 - var yest = QdpCalendarHelper.GetNonHolidayDefore(flowEvent.EventDate.AddDays(-1)); - var eod = DbContext.eod_swap_position.Where(e => e.SwapTradeId == flowEvent.SwapTradeId && !e.Invalid && e.PosiQuantity > 0 && e.ValueDate == yest).FirstOrDefault(); + if (flowEvent.UnwindDate == null) { + throw new ArgumentNullException("平仓日期缺失"); + } + var date = flowEvent.UnwindDate.GetValueOrDefault(); + var preDate = date.AddDays(-1); + // 平仓数量/平仓前的数量 * 上一自然日待实现分红收益,保留2位小数 + var eod = DbContext.eod_swap_position.Where(e => e.SwapTradeId == flowEvent.SwapTradeId && !e.Invalid && e.PosiQuantity > 0 && e.ValueDate == preDate).FirstOrDefault(); var dividendIn = eod.PosiDividendSum * unwindQty / eod.PosiQuantity; + // + 付息日>上日日终且小于等于平仓日期的分红数据 + BondPaymentService servie = new BondPaymentService(UserInfo); + var payments = servie.GetBondPayments(flowEvent.UnderlyingCode, preDate, date); + + int shortRatio = flowEvent.PositionType == (int)PositionTypeFlag.Long ? 1 : -1; + int directionRatio = flowEvent.PayDirection == (int)SwapDirectionEnum.收取 ? 1 : -1; + dividendIn = dividendIn + servie.CalcPayment(payments, unwindQty, shortRatio, directionRatio); flowEvent.DividendIn = Math.Round(dividendIn, 2, MidpointRounding.AwayFromZero); }