feat(swap): 完善自动互换资金记录管理功能

- 在SwapEodPositionService中添加clientCashIds列表追踪多笔资金记录
- 为UnwindData类新增ClientCashIds属性存储自动互换生成的资金记录ID集合
- 在SwapTradeBaseService中实现GetAutoSwapClientCashIds方法解析历史数据
- 添加GetLegacyAutoSwapClientCashRecords方法处理遗留资金记录删除逻辑
- 实现IsLegacyAutoSwapClientCashRecord方法精确匹配待删除资金记录
- 优化资金记录删除策略区分自动互换与手动操作产生的记录
This commit is contained in:
张名锐
2026-07-01 09:53:44 +08:00
parent 1a9b8af512
commit 78751f0a57
3 changed files with 135 additions and 14 deletions
@@ -510,16 +510,19 @@ namespace YLErp.Modules.SwapModule
var cashHappenDate = interval?.SettlementDate ?? unwindData.ValueDate;
int clientCashId = 0;
var clientCashIds = new List<int>();
// 利息腿:插入资金记录(使用系统操作_互换)
if (unwindData.SwapCloseAmount != 0)
{
clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapCloseAmount), ClientCashInCashOut._互换, cashHappenDate);
clientCashIds.Add(clientCashId);
}
// 预付金腿:单独插入一条资金记录(系统操作_预付金返息)
if (unwindData.SwapMarginRebatePnl != 0)
{
clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapMarginRebatePnl), ClientCashInCashOut._预付金返息, unwindData.ValueDate);
clientCashIds.Add(clientCashId);
}
unwindData.SwapCloseAmount = unwindData.SwapRealizedPnL;//需要算上预付金利息 和 分红; 只是不算预付金返还
// 分红:使用派息支付日偏移记录资金记录
@@ -529,8 +532,10 @@ namespace YLErp.Modules.SwapModule
? dividendEvents.First().PayDate.Value
: unwindData.ValueDate;
clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapDividendPnl), ClientCashInCashOut._互换, dividendPayDate);
clientCashIds.Add(clientCashId);
}
unwindData.ClientCashIds = clientCashIds;
string data = JsonConvert.SerializeObject(unwindData);
var swapEvent = new SwapEventService(this).AddSwapEventDate(unwindData.ValueDate, unwindData.SwapTradeId, (int)SwapEventTypeEnum., data, clientCashId, true, "系统操作-自动互换");//将互换总额存入事件
if (flowEvents!=null)