refactor(swap): ComposePage补充接缝-AddClientCash/SaveEodSwapRecord/ClearSwapPositionsForCompose
ComposePage内部还有3处DB依赖需要接缝: - AddClientCashInCashOut(cs:804平仓资金记录) → AddClientCash虚方法 - SaveEodSwap(cs:862框架合约汇总) → SaveEodSwapRecord虚方法 - ClearSwapPositions(cs:729清理旧事件) → ClearSwapPositionsForCompose虚方法 测试时override这3个虚方法可避免连库。 验证: 100个测试全通过。
This commit is contained in:
@@ -135,6 +135,24 @@ namespace YLErp.Modules.SwapModule
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>添加资金记录(生产: AddClientCashInCashOut;测试: 收集到计数器)</summary>
|
||||
protected virtual int AddClientCash(trade td, double amount, string action, DateTime valueDate)
|
||||
{
|
||||
return AddClientCashInCashOut(td, amount, action, valueDate);
|
||||
}
|
||||
|
||||
/// <summary>保存框架合约日终汇总(生产: SaveEodSwap私有方法;测试: 收集到列表)</summary>
|
||||
protected virtual void SaveEodSwapRecord(trade td, DateTime settleDate, DateTime preSettleDate)
|
||||
{
|
||||
SaveEodSwap(td, settleDate, preSettleDate);
|
||||
}
|
||||
|
||||
/// <summary>清理旧持仓事件(生产: ClearSwapPositions;测试: 空操作)</summary>
|
||||
protected virtual void ClearSwapPositionsForCompose(trade td, DateTime tradeDate, List<int> eventTypes)
|
||||
{
|
||||
ClearSwapPositions(td, tradeDate, eventTypes, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -708,7 +726,7 @@ namespace YLErp.Modules.SwapModule
|
||||
var preSettleDate = GetPreValueDate(tradeDate);//上一交易日期
|
||||
List<int> eventTyps = new List<int>() { (int)SwapEventTypeEnum.平仓, (int)SwapEventTypeEnum.互换, (int)SwapEventTypeEnum.自动互换 };
|
||||
List<int> removeEventTyps = new List<int>() { (int)SwapEventTypeEnum.平仓, (int)SwapEventTypeEnum.互换, (int)SwapEventTypeEnum.自动互换 };
|
||||
ClearSwapPositions(td, tradeDate, removeEventTyps, false);
|
||||
ClearSwapPositionsForCompose(td, tradeDate, removeEventTyps);
|
||||
td.trade_extend = FindTradeExtend(swapTradeId);
|
||||
var allEodPositions = FindEodSwapPositions(swapTradeId, preSettleDate);
|
||||
var eodPositions = allEodPositions.Where(x => x.ValueDate == preSettleDate).ToList();//上一日终持仓信息
|
||||
@@ -789,7 +807,7 @@ namespace YLErp.Modules.SwapModule
|
||||
//记录资金记录
|
||||
if (amount != 0)
|
||||
{
|
||||
int clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(x.MarkClosePnl), ClientCashInCashOut.系统操作_平仓费, x.UnwindDate.Value);
|
||||
int clientCashId = AddClientCash(td, Convert.ToDouble(x.MarkClosePnl), ClientCashInCashOut.系统操作_平仓费, x.UnwindDate.Value);
|
||||
x.ClientCashId = clientCashId;
|
||||
}
|
||||
payQty = payQty - x.Quantity;
|
||||
@@ -847,7 +865,7 @@ namespace YLErp.Modules.SwapModule
|
||||
unwindData.CloseNotionalValue = tdCloseNotionalValue;
|
||||
swapEvent.EventData = JsonHelper.Serialize(unwindData);
|
||||
SaveAllChanges();
|
||||
SaveEodSwap(td, tradeDate, preSettleDate);
|
||||
SaveEodSwapRecord(td, tradeDate, preSettleDate);
|
||||
SaveAllChanges();
|
||||
trans?.Commit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user