From de184dfdd6a84bb35744a0bc77e6041ed83902b8 Mon Sep 17 00:00:00 2001 From: gongpei Date: Thu, 23 Oct 2025 21:14:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E5=B9=B3=E4=BB=93=E6=97=B6?= =?UTF-8?q?=E4=BB=98=E6=81=AF=E8=AE=B0=E5=BD=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YLErpDAL/Modules/SwapModule/SwapDealService.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 09862168..a791eca8 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -889,7 +889,7 @@ namespace YLErp.Modules.SwapModule floatEvent.OptLog = "流水自动"; floatEvent.ClientId = td.ClientId; floatEvent.SetOpt(UserInfo); - EnrichDividendIn(floatEvent, unwindQty); + EnrichDividendIn(floatEvent, unwindQty, td); } unwindData.FlowEvents.Add(floatEvent); var interestPositions = GetUnwindInterests(unwindData.ValueDate, unwindData.UnwindDate.Value, td.id, unwindPercent, (int)SwapEventTypeEnum.平仓); @@ -908,23 +908,20 @@ namespace YLErp.Modules.SwapModule DealUnwind(unwindData, td); } - private void EnrichDividendIn(swap_flow_event flowEvent, decimal unwindQty) + private void EnrichDividendIn(swap_flow_event flowEvent, decimal unwindQty, trade td) { - if (flowEvent.UnwindDate == null) { + 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); + var payments = servie.GetBondPayments(flowEvent.UnderlyingCode, td.StartDate.Value, 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); + // + 付息日>上日日终且小于等于平仓日期的分红数据 + var dividendIn = servie.CalcPayment(payments, unwindQty, shortRatio, directionRatio); flowEvent.DividendIn = Math.Round(dividendIn, 2, MidpointRounding.AwayFromZero); }