diff --git a/UnitTestProject/Modules/SwapModule/Margin/MarginModesTest.cs b/UnitTestProject/Modules/SwapModule/Margin/MarginModesTest.cs
index edf94c89..7732e13b 100644
--- a/UnitTestProject/Modules/SwapModule/Margin/MarginModesTest.cs
+++ b/UnitTestProject/Modules/SwapModule/Margin/MarginModesTest.cs
@@ -8,7 +8,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
{
///
/// MarginModes 统一判断口径测试。
- /// 验证它和现有散落的 marginTypes/InterestMarginModels/premiumModes 内容一致。
+ /// 验证 MarginModes 由框架常量 ConsTrade.InterestMarginModels 派生,内容一致。
///
[TestClass]
public class MarginModesTest
@@ -37,7 +37,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
Assert.IsFalse(MarginModes.Contains((int)InterestModeEnum.标的期初全价));
}
- /// 守护:和 ConsTrade.InterestMarginModels 内容必须一致(迁移期对齐)。
+ /// 回归护栏:MarginModes 由 ConsTrade.InterestMarginModels 派生,内容须一致(防止有人又独立重写集合导致口径分裂)。
[TestMethod]
public void 与ConsTradeInterestMarginModels内容一致()
{
diff --git a/YLErpDAL/Modules/SwapModule/Margin/MarginModes.cs b/YLErpDAL/Modules/SwapModule/Margin/MarginModes.cs
index 359e3fc9..99346d4b 100644
--- a/YLErpDAL/Modules/SwapModule/Margin/MarginModes.cs
+++ b/YLErpDAL/Modules/SwapModule/Margin/MarginModes.cs
@@ -7,14 +7,18 @@ namespace YLErp.Modules.SwapModule.Margin;
///
/// 保证金计息模式(mode 5 初始预付金 / mode 6 追加预付金)的统一判断口径。
///
-/// 现状(待收敛):同一集合 {初始预付金, 追加预付金} 在代码里复制了至少 6 次——
-/// ConsTrade.InterestMarginModels(框架级)
-/// SwapEodPositionService.marginTypes(实例字段)
-/// SwapEodPositionService.premiumModes(局部变量)
-/// SwapEventEmailService.marginTypes
-/// EodClientBalanceCalc.marginTypes
-/// ClientBalanceUtility.marginTypes
-/// 任何一处漏改(如新增保证金形态)都会导致口径分裂。本类收敛到单一来源。
+/// 依赖方向:本类位于 YLErpDAL 层,单一真源是框架层常量
+/// (YLErp.DBModels)。Core 不能反向依赖 DAL,
+/// 故本类的集合直接由该框架常量派生(new HashSet/List),而非独立重写——
+/// 任何一处要新增保证金形态,只需改 ConsTrade.InterestMarginModels 即全局生效。
+///
+/// 收敛历史:早期同一集合 {初始预付金, 追加预付金} 在代码里被复制多次
+/// (ConsTrade.InterestMarginModels / SwapEodPositionService.marginTypes /
+/// SwapEodPositionService.premiumModes / SwapEventEmailService.marginTypes /
+/// EodClientBalanceCalc.marginTypes / ClientBalanceUtility.marginTypes)。
+/// 现余额/邮件/利息等入口已改用本类;SwapEodPositionService.premiumModes 局部变量
+/// 也已替换为 MarginModes.ForLinq。ConsTrade.InterestMarginModels 作为框架级常量保留
+/// (它是唯一真源,并非冗余)。
///
/// 注意:这里的"保证金 mode"是现有系统把保证金错误建模为计息腿的历史遗留。
/// 按 Margin 限界上下文的设计方向,未来保证金不应用 InterestMode 标识,
@@ -22,34 +26,24 @@ namespace YLErp.Modules.SwapModule.Margin;
///
public static class MarginModes
{
- /// 所有属于保证金的 InterestMode(初始预付金 / 追加预付金)。
- public static readonly IReadOnlyCollection All = new HashSet
- {
- (int)InterestModeEnum.初始预付金,
- (int)InterestModeEnum.追加预付金,
- };
+ /// 所有属于保证金的 InterestMode(派生自 ConsTrade.InterestMarginModels)。
+ public static readonly IReadOnlyCollection All = new HashSet(ConsTrade.InterestMarginModels);
///
/// List 形态,供 EF Core LINQ 表达式用(HashSet.Contains 无法翻译成 SQL)。
- /// 替代 ConsTrade.InterestMarginModels。
+ /// 内容派生自框架常量 ConsTrade.InterestMarginModels(单一真源),本类仅做形态适配。
///
- public static readonly List ForLinq = new()
- {
- (int)InterestModeEnum.初始预付金,
- (int)InterestModeEnum.追加预付金,
- };
+ public static readonly List ForLinq = new List(ConsTrade.InterestMarginModels);
/// 判断 mode 是否属于保证金(非 LINQ 场景用)。
public static bool Contains(int interestMode) => All.Contains(interestMode);
/// 固定值 + 保证金 mode 集合(固定值/初始预付金/追加预付金)。
/// 用于 EOD 场景判断"计息基数取 InterestPrincipalFix 而非持仓名义本金"的腿。
- /// 替代 SwapEodPositionService 中 3 处内联 new List{固定值, 初始预付金, 追加预付金}。
- public static readonly IReadOnlyCollection FixedAmountAndMargin = new HashSet
+ /// 保证金部分派生自 ConsTrade.InterestMarginModels,固定值额外并入。
+ public static readonly IReadOnlyCollection FixedAmountAndMargin = new HashSet(ConsTrade.InterestMarginModels)
{
(int)InterestModeEnum.固定值,
- (int)InterestModeEnum.初始预付金,
- (int)InterestModeEnum.追加预付金,
};
/// 判断 mode 是否为固定值或保证金。
diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs
index d6fa2a48..d96ed571 100644
--- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs
+++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs
@@ -615,7 +615,7 @@ namespace YLErp.Modules.SwapModule
autoInterests.ForEach(x => x.PayDate = settleDate);
- var premiumModes = new List() { (int)InterestModeEnum.初始预付金, (int)InterestModeEnum.追加预付金 };
+ var premiumModes = MarginModes.ForLinq;
var premiumInterests = autoInterests.Where(x => premiumModes.Contains(x.InterestMode)).ToList();
var interestLegs = autoInterests.Where(x => !premiumModes.Contains(x.InterestMode)).ToList();