From 7e169dd53f436c192ce3187b511cc7fa4bd59811 Mon Sep 17 00:00:00 2001 From: hjhan Date: Tue, 11 Aug 2026 15:46:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(margin):=20=E5=9B=9E=E9=80=80=20PreviousBal?= =?UTF-8?q?ance=20=E7=AE=80=E5=8C=96,=20=E6=81=A2=E5=A4=8D=E4=B8=89?= =?UTF-8?q?=E7=BA=A7=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 尝试去掉第2级(TdInterestPrincipal)导致5个保证金测试失败。 根因: 生产 EOD 归档(eod_swap_position(35774))的 InterestPrincipalFix=0, 只有 TdInterestPrincipal 有值。第2级不是死代码, 不可删。 恢复三级 fallback, 补充注释说明每级命中的真实场景。 教训: 不能只看赋值点判断字段是否有值, 必须看实际数据。 验证: 编译0错误, 全量509测试7失败(基线一致)。 --- YLErpDAL/Modules/SwapModule/Margin/MarginCalc.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/YLErpDAL/Modules/SwapModule/Margin/MarginCalc.cs b/YLErpDAL/Modules/SwapModule/Margin/MarginCalc.cs index 40f8787e..d0ce29be 100644 --- a/YLErpDAL/Modules/SwapModule/Margin/MarginCalc.cs +++ b/YLErpDAL/Modules/SwapModule/Margin/MarginCalc.cs @@ -9,7 +9,12 @@ public static class MarginCalc { /// /// 取上一日终保证金余额。 - /// 优先 InterestPrincipalFix,其次 TdInterestPrincipal,都没有用 fallback。 + /// + /// 三级优先级(均有测试覆盖,不可简化): + /// 1. InterestPrincipalFix——EOD 归档赋值时的首选字段 + /// 2. TdInterestPrincipal——部分 EOD 归档路径未写 InterestPrincipalFix(值为0), + /// 此时 TdInterestPrincipal 含正确的保证金本金(生产 eod_swap_position(35774) 即此场景) + /// 3. fallback——首次平仓(preEod.id==0, 无归档)时用当日保证金余额 /// public static decimal PreviousBalance(eod_swap_position preEod, decimal fallback) {