From a868f3eb15ea19446013c0f5fcc9a58ba2ea45b0 Mon Sep 17 00:00:00 2001 From: hjhan Date: Tue, 11 Aug 2026 10:27:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(margin):=20=E6=8A=BD=E5=8F=96=20FlipMa?= =?UTF-8?q?rginDirection=20=E4=BF=9D=E8=AF=81=E9=87=91=E6=96=B9=E5=90=91?= =?UTF-8?q?=E7=BF=BB=E8=BD=AC=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2处 inline 的保证金方向翻转(收取↔支付)抽成独立方法 FlipMarginDirection。 保证金利息是券商付给客户, 方向与融资腿相反。 - GetInterests 路径(854行): if(5||6) → MarginModes.Contains + FlipMarginDirection - 衡泰路径(1934行): 同上, 保留 _closePosiNotionalValue=0 判断从 InterestModeEnum==5||6 改为 MarginModes.Contains(统一口径)。 纯提取, 行为零变化。 验证: 编译0错误, 全量489测试7失败(基线一致)。 --- YLErpDAL/Modules/SwapModule/SwapDealService.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index ffcc5ee7..5f87491a 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -12,6 +12,7 @@ using YLErp.Modules.EodModule; using YLErp.Modules.TradeModule; using YLErp.Modules.TradeModule.DealModule; using YLErp.Modules.SwapModule.InterestLegs; +using YLErp.Modules.SwapModule.Margin; using YLErp.QdpModule; namespace YLErp.Modules.SwapModule @@ -848,9 +849,9 @@ namespace YLErp.Modules.SwapModule { closePrincipal = closePosiNotionalValue; } - if ((InterestModeEnum)position.InterestMode == InterestModeEnum.追加预付金 || (InterestModeEnum)position.InterestMode == InterestModeEnum.初始预付金) + if (MarginModes.Contains(position.InterestMode)) { - positionClone.InterestDirection = position.InterestDirection == (int)SwapDirectionEnum.收取 ? (int)SwapDirectionEnum.支付 : (int)SwapDirectionEnum.收取; + positionClone.InterestDirection = FlipMarginDirection(position.InterestDirection); } // 获取利率 @@ -1169,6 +1170,15 @@ namespace YLErp.Modules.SwapModule : fallback; } + /// + /// 保证金腿的利息方向翻转。保证金利息是券商付给客户(方向与融资腿相反)。 + /// 待迁入 Margin 模块。 + /// + private static int FlipMarginDirection(int direction) + => direction == (int)SwapDirectionEnum.收取 + ? (int)SwapDirectionEnum.支付 + : (int)SwapDirectionEnum.收取; + /// /// 初始化利息腿信息 /// @@ -1918,10 +1928,10 @@ namespace YLErp.Modules.SwapModule _closePosiNotionalValue = _posiNotionalValue * grossPrice * newClosePercent; _posiNotionalValue = _posiNotionalValue * grossPrice; } - else if (item.InterestMode == (int)InterestModeEnum.追加预付金 || item.InterestMode == (int)InterestModeEnum.初始预付金) + else if (MarginModes.Contains(item.InterestMode)) { _closePosiNotionalValue = 0; - positionClone.InterestDirection = position.InterestDirection == (int)SwapDirectionEnum.收取 ? (int)SwapDirectionEnum.支付 : (int)SwapDirectionEnum.收取; + positionClone.InterestDirection = FlipMarginDirection(position.InterestDirection); } decimal rate = item.InterestRateDefault; if (swapIntervalToday != null)//当日无适用观察日