上次失败根因: EodClientBalanceCalc:134 是 EF Core LINQ 表达式,
HashSet.Contains 无法翻译成 SQL, 导致场景3/4 全红。
修正: MarginModes 新增 ForLinq(List<int>) 供 EF Core 翻译用。
- SwapEodPositionService 2处纯函数(非LINQ): 用 MarginModes.Contains
- EodClientBalanceCalc LINQ表达式: 用 MarginModes.ForLinq.Contains
- RealTimeClientBanlanceService(已ToList,内存集合): 用 MarginModes.Contains
ConsTrade.InterestMarginModels 产品代码引用: 4处 → 0(只剩定义+注释)。
保证金mode判断 {初始预付金,追加预付金} 现在统一由 MarginModes 提供。
验证: sln编译0错误, 全量485测试7失败(基线一致,零回归)。
45 lines
1.8 KiB
C#
45 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using YLErp.DBModels;
|
|
|
|
namespace YLErp.Modules.SwapModule.Margin;
|
|
|
|
/// <summary>
|
|
/// 保证金计息模式(mode 5 初始预付金 / mode 6 追加预付金)的统一判断口径。
|
|
///
|
|
/// 现状(待收敛):同一集合 {初始预付金, 追加预付金} 在代码里复制了至少 6 次——
|
|
/// ConsTrade.InterestMarginModels(框架级)
|
|
/// SwapEodPositionService.marginTypes(实例字段)
|
|
/// SwapEodPositionService.premiumModes(局部变量)
|
|
/// SwapEventEmailService.marginTypes
|
|
/// EodClientBalanceCalc.marginTypes
|
|
/// ClientBalanceUtility.marginTypes
|
|
/// 任何一处漏改(如新增保证金形态)都会导致口径分裂。本类收敛到单一来源。
|
|
///
|
|
/// 注意:这里的"保证金 mode"是现有系统把保证金错误建模为计息腿的历史遗留。
|
|
/// 按 Margin 限界上下文的设计方向,未来保证金不应用 InterestMode 标识,
|
|
/// 但在历史代码完全迁出前,需要一个统一判断点。
|
|
/// </summary>
|
|
public static class MarginModes
|
|
{
|
|
/// <summary>所有属于保证金的 InterestMode(初始预付金 / 追加预付金)。</summary>
|
|
public static readonly IReadOnlyCollection<int> All = new HashSet<int>
|
|
{
|
|
(int)InterestModeEnum.初始预付金,
|
|
(int)InterestModeEnum.追加预付金,
|
|
};
|
|
|
|
/// <summary>
|
|
/// List 形态,供 EF Core LINQ 表达式用(HashSet.Contains 无法翻译成 SQL)。
|
|
/// 替代 ConsTrade.InterestMarginModels。
|
|
/// </summary>
|
|
public static readonly List<int> ForLinq = new()
|
|
{
|
|
(int)InterestModeEnum.初始预付金,
|
|
(int)InterestModeEnum.追加预付金,
|
|
};
|
|
|
|
/// <summary>判断 mode 是否属于保证金(非 LINQ 场景用)。</summary>
|
|
public static bool Contains(int interestMode) => All.Contains(interestMode);
|
|
}
|