refactor(swap): 提取 SwapPositionQueries.ActiveByTrade 收口有效持仓查询
- 新增 SwapPositionQueries.ActiveByTrade 静态扩展,收口 'SwapTradeId==X && !Invalid' 规则到单一真相 - 替换 SwapDealService/SwapEodPositionService/SwapTradeService 共 7 处纯重复谓词 - 仅返回 IQueryable,不调 SaveChanges,不动 FindTrade seam / 事务边界;行为保持等价
This commit is contained in:
@@ -210,7 +210,7 @@ namespace YLErp.Modules.SwapModule
|
||||
public UnwindData InitUnwind(int tradeId)
|
||||
{
|
||||
var td = DbContext.trade.Find(tradeId);
|
||||
var positions = DbContext.swap_position.Where(x => x.SwapTradeId == tradeId && !x.Invalid);
|
||||
var positions = DbContext.swap_position.ActiveByTrade(tradeId);
|
||||
var um = DataCacheProvider.GetUnderlyingDataSource().GetData(td.UnderlyingCode);
|
||||
bool commodity = ConsGlobal.InstrumentType.CalcTypeIsFutures(um.UnderlyingInstrumentType);
|
||||
List<int> eventTyps = new List<int>() { (int)SwapEventTypeEnum.自动互换, (int)SwapEventTypeEnum.互换 };
|
||||
@@ -355,7 +355,7 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
var checkEventTypes = new List<int>() { (int)SwapEventTypeEnum.互换, (int)SwapEventTypeEnum.自动互换 };
|
||||
var td = DbContext.trade.Find(tradeId);
|
||||
var positions = DbContext.swap_position.Where(x => x.SwapTradeId == tradeId && !x.Invalid);
|
||||
var positions = DbContext.swap_position.ActiveByTrade(tradeId);
|
||||
var um = DataCacheProvider.GetUnderlyingDataSource().GetData(td.UnderlyingCode);
|
||||
List<int> eventTypes = new List<int>() { (int)SwapFlowEventTypeEnum.互换, (int)SwapFlowEventTypeEnum.自动互换 };
|
||||
var maxIncomeValueDate = GetMaxIncomeValueDate(td);
|
||||
@@ -460,7 +460,7 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
throw new ServiceException("未找到交易信息");
|
||||
}
|
||||
var allpositions = DbContext.swap_position.Where(x => x.SwapTradeId == tradeId && !x.Invalid).ToList();
|
||||
var allpositions = DbContext.swap_position.ActiveByTrade(tradeId).ToList();
|
||||
var origPositions = allpositions.Where(x => x.IsInitial).ToList();
|
||||
var realPostitions = allpositions.Where(x => !x.IsInitial).ToList();
|
||||
// 根因修复(多次部分平仓预付金返还错误):见 ResolveInterestLegPositions 注释。
|
||||
@@ -1571,7 +1571,7 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
unwindPriceFee = decimal.Parse(unwindPriceFee.ToString("F10"));
|
||||
var td = DbContext.trade.Find(tradeid);
|
||||
var positions = DbContext.swap_position.Where(x => x.SwapTradeId == td.id && !x.Invalid);
|
||||
var positions = DbContext.swap_position.ActiveByTrade(td.id);
|
||||
List<int> eventTypes = new List<int>() { (int)SwapEventTypeEnum.平仓, (int)SwapEventTypeEnum.互换 };
|
||||
var dealDate = valueDate;
|
||||
var tradeExtend = DbContext.trade_extend.FirstOrDefault(x => x.TradeId == td.id);
|
||||
|
||||
Reference in New Issue
Block a user