From a0f8dc9df71b7ea9146180357225937dd646e3fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8D=E9=94=90?= <1565842059@qq.com> Date: Mon, 20 Jul 2026 09:30:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(SwapModule):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E9=A2=84=E4=BB=98=E9=87=91=E5=88=A9=E6=81=AF=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除本金绝对值加权平均的复杂计算方式 - 直接对各腿利息金额进行轧差求和 - 保留收取为正、支付为负的方向转换逻辑 - 删除不再使用的本金权重计算代码 - 简化方法实现并提高计算效率 --- .../Modules/SwapModule/SwapEodPositionService.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 6865b195..38004aa4 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -2611,18 +2611,13 @@ namespace YLErp.Modules.SwapModule } /// - /// 计算预付金利息。先按收取为正、支付为负转换为我方视角, - /// 再按日终本金绝对值加权平均;本金合计为零时返回零。 + /// 计算预付金利息金额。InterestIncomeSum 已是各腿利息金额, + /// 按收取为正、支付为负直接轧差求和,不做本金加权。 /// private static decimal CalculateWeightedMarginInterest(IEnumerable margins) { - var marginList = margins.ToList(); - var totalWeight = marginList.Sum(x => Math.Abs(x.InterestPrincipalFix)); - return totalWeight == 0 - ? 0 - : marginList.Sum(x => x.InterestIncomeSum - * (x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1) - * Math.Abs(x.InterestPrincipalFix)) / totalWeight; + return margins.Sum(x => + x.InterestIncomeSum * (x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1)); } /// /// 将数据库中以公司/交易簿记方向保存的日终字段转换为客户视角。