diff --git a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs index 81363154..4a64222f 100644 --- a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs +++ b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs @@ -1402,7 +1402,6 @@ namespace YLErp.BLL.EodSettlement public static void FillClientBalanceHisTradeFee() { - List marginTypes = new List() { (int)InterestModeEnum.追加预付金, (int)InterestModeEnum.初始预付金 }; var clients = DataCacheProvider.GetClientDataSource().AsQueryable().Where(x => x.ProcessStatus == "已开户").ToList(); using var db = new YLContext(); var firstEodStatusDate = db.eodStatus.OrderBy(o => o.ValueDate).FirstOrDefault(); diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs index 927b2157..f89b7689 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs @@ -40,7 +40,6 @@ namespace YLErp.Modules.EodModule.SettlementModule var currencyCodes = _context.CurrencyCodes; var currencyProvider = _context.EodCurrencyProvider; - List marginTypes = new List() { (int)InterestModeEnum.追加预付金, (int)InterestModeEnum.初始预付金 }; //预付金可取上浮比率 var marginRatio = Math.Round((decimal)(_context.SystemValue.MarginRatio ?? 0.15), 2, MidpointRounding.AwayFromZero); var marginMaxRatio = marginRatio + 0.02m; diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 689ee096..17d62d18 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -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 /// public class SwapEodPositionService : SwapTradeBaseService { - private List marginTypes = new List() { (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 tradeDic = new Dictionary(); @@ -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(); diff --git a/YLErpDAL/Modules/SwapModule/SwapEventEmailService.cs b/YLErpDAL/Modules/SwapModule/SwapEventEmailService.cs index 73cd88ab..a6bad2cc 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEventEmailService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEventEmailService.cs @@ -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 eventTypes = new List() { (int)SwapFlowEventTypeEnum.开仓, (int)SwapFlowEventTypeEnum.平仓 }; - private List marginTypes = new List() { (int)InterestModeEnum.追加预付金, (int)InterestModeEnum.初始预付金 }; + private List marginTypes = MarginModes.All.ToList(); private decimal wan = 10000m; public SwapEventEmailService(OptUserInfo userInfo) : base(userInfo) {