refactor(margin): 4处散落marginTypes收敛到MarginModes

SwapEodPositionService: 删除 marginTypes 字段(13处.Contains全改MarginModes.Contains)
SwapEventEmailService: marginTypes 字段改为 MarginModes.All.ToList()
EodClientBalanceCalc: 删除未使用的 marginTypes 局部变量(死代码)
ClientBalanceUtility: 删除未使用的 marginTypes 局部变量(死代码)

收敛后 {初始预付金,追加预付金} 集合只在 MarginModes.All 一处定义,
消除6处副本口径分裂风险。

验证: sln编译0错误, 全量485测试7失败(基线一致,零回归)。
注: 上次27失败是stash残留导致的状态不一致,本次从干净状态逐步改。
This commit is contained in:
hjhan
2026-08-11 09:40:48 +08:00
parent 553e3d4c6d
commit ef1a126b8f
4 changed files with 14 additions and 15 deletions
@@ -12,6 +12,7 @@ using YLErp.Model.Enum;
using YLErp.Models;
using YLErp.Modules.DataProviderModule;
using YLErp.Modules.EodModule;
using YLErp.Modules.SwapModule.Margin;
using YLErp.QdpModule;
namespace YLErp.Modules.SwapModule
@@ -21,7 +22,6 @@ namespace YLErp.Modules.SwapModule
/// </summary>
public class SwapEodPositionService : SwapTradeBaseService
{
private List<int> marginTypes = new List<int>() { (int)InterestModeEnum., (int)InterestModeEnum. };
private static readonly IYcLogger Log = LogFactory.GetLogger(typeof(SwapEodPositionService).FullName);
public SwapEodPositionService(OptUserInfo optUser) : base(optUser)
{
@@ -1041,7 +1041,7 @@ namespace YLErp.Modules.SwapModule
}
var tradeExtend = td.trade_extend.ExtendObj;
decimal ratio = position.InterestDirection == (int)SwapDirectionEnum. ? 1m : -1m;//收取为正,支付为负
if (marginTypes.Contains(position.InterestMode))
if (MarginModes.Contains(position.InterestMode))
{
ratio = -ratio;
}
@@ -1176,7 +1176,7 @@ namespace YLErp.Modules.SwapModule
decimal posiNotionalValue = posiLongNotional + posiShortNational;
decimal closePercent = 1;
decimal ratio = position.InterestDirection == (int)SwapDirectionEnum. ? 1m : -1m;//收取为正,支付为负
if (marginTypes.Contains(position.InterestMode))
if (MarginModes.Contains(position.InterestMode))
{
ratio = -ratio;
}
@@ -1296,7 +1296,7 @@ namespace YLErp.Modules.SwapModule
decimal posiNotionalValue = posiLongNotional + posiShortNational;
// ratio 只负责把腿内原始金额转换为本方盈亏方向,不参与计息金额本身的计算。
decimal ratio = position.InterestDirection == (int)SwapDirectionEnum. ? 1m : -1m;//收取为正,支付为负
if (marginTypes.Contains(position.InterestMode))
if (MarginModes.Contains(position.InterestMode))
{
ratio = -ratio;
}
@@ -1604,7 +1604,7 @@ namespace YLErp.Modules.SwapModule
closePercent = 1;
}
decimal ratio = eodPayPosition.InterestDirection == (int)SwapDirectionEnum. ? 1m : -1m;//收取为正,支付为负
if (marginTypes.Contains(position.InterestMode))
if (MarginModes.Contains(position.InterestMode))
{
ratio = -ratio;
}
@@ -2207,7 +2207,7 @@ namespace YLErp.Modules.SwapModule
interestPositions.ForEach(x =>
{
decimal ratio = x.InterestDirection == (int)SwapDirectionEnum. ? 1 : -1;//收取为正,支付为负
if (marginTypes.Contains(x.InterestMode))
if (MarginModes.Contains(x.InterestMode))
{
ratio = -ratio;
}
@@ -2275,7 +2275,7 @@ namespace YLErp.Modules.SwapModule
interestPositions.ForEach(x =>
{
decimal ratio = x.InterestDirection == (int)SwapDirectionEnum. ? 1 : -1;//收取为正,支付为负
if (marginTypes.Contains(x.InterestMode))
if (MarginModes.Contains(x.InterestMode))
{
ratio = -ratio;
}
@@ -2284,7 +2284,7 @@ namespace YLErp.Modules.SwapModule
eodSwapPositions.ForEach(x =>
{
decimal ratio = x.InterestDirection == (int)SwapDirectionEnum. ? 1 : -1;//收取为正,支付为负
if (marginTypes.Contains(x.InterestMode))
if (MarginModes.Contains(x.InterestMode))
{
ratio = -ratio;
}
@@ -2531,7 +2531,7 @@ namespace YLErp.Modules.SwapModule
.Where(x => x.SwapTradeId == item.position.SwapTradeId && x.ValueDate == item.position.ValueDate)
.ToList();
var floatingLegs = details.Where(x => !string.IsNullOrEmpty(x.UnderlyingCode)).ToList();
var marginLegs = details.Where(x => marginTypes.Contains(x.InterestMode)).ToList();
var marginLegs = details.Where(x => MarginModes.Contains(x.InterestMode)).ToList();
var tradeExtend = tradeExtends.FirstOrDefault(x => x.TradeId == item.position.SwapTradeId);
var dividendPayDate = tradeExtend?.ExtendObj?.DividendPayDate ?? 1;
@@ -2780,7 +2780,7 @@ namespace YLErp.Modules.SwapModule
// 主查询分页后再取同交易、同估值日的全部辅助腿,避免利息/保证金归集跨估值日串数据。
var eodPositions = DbContext.eod_swap_position.Where(interestPredicate).ToList();
var marginPositions = DbContext.swap_position
.Where(x => tradeIds.Contains(x.SwapTradeId) && marginTypes.Contains(x.InterestMode) && x.IsInitial && !x.Invalid)
.Where(x => tradeIds.Contains(x.SwapTradeId) && MarginModes.Contains(x.InterestMode) && x.IsInitial && !x.Invalid)
.ToList();
var tradeExtends = DbContext.trade_extend.Where(x => tradeIds.Contains(x.TradeId)).ToList();
Dictionary<string, bool> tradeDic = new Dictionary<string, bool>();
@@ -2832,8 +2832,8 @@ namespace YLErp.Modules.SwapModule
&& (!x.HappenDate.HasValue || x.HappenDate.Value <= item.position.ValueDate))
.ToList();
var interests = eodPositions.Where(x => x.SwapTradeId == item.position.SwapTradeId && x.ValueDate == item.position.ValueDate);
var eodMargins = interests.Where(x => marginTypes.Contains(x.InterestMode)).ToList();
var eodInterests = interests.Where(x => !marginTypes.Contains(x.InterestMode)).ToList();
var eodMargins = interests.Where(x => MarginModes.Contains(x.InterestMode)).ToList();
var eodInterests = interests.Where(x => !MarginModes.Contains(x.InterestMode)).ToList();
var initialMargins = tradeMargins.Where(x => x.InterestMode == (int)InterestModeEnum.).ToList();
var additionalMargins = tradeMargins.Where(x => x.InterestMode == (int)InterestModeEnum.).ToList();
var floatRateInterest = eodInterests.Where(x => !string.IsNullOrEmpty(x.FloatRateUnderlyingCode)).FirstOrDefault();
@@ -22,6 +22,7 @@ using YLErp.MailKit;
using YLErp.Model;
using YLErp.Models;
using YLErp.Modules.EodModule.QueryModule;
using YLErp.Modules.SwapModule.Margin;
using YLErp.Office.Converters;
using YLErp.Office.Helpers;
using static YLErp.ConsGlobal;
@@ -31,7 +32,7 @@ namespace YLErp.Modules.SwapModule
public class SwapEventEmailService : YLBaseService
{
private List<int> eventTypes = new List<int>() { (int)SwapFlowEventTypeEnum., (int)SwapFlowEventTypeEnum. };
private List<int> marginTypes = new List<int>() { (int)InterestModeEnum., (int)InterestModeEnum. };
private List<int> marginTypes = MarginModes.All.ToList();
private decimal wan = 10000m;
public SwapEventEmailService(OptUserInfo userInfo) : base(userInfo)
{