Merge branch 'glms/feature/0812_zmr_divPower' into 'glms/feature/1.4.2'
fix(swap): 修复公司行为事件生命周期管理问题 See merge request otc-dev/zszq-trs!15
This commit is contained in:
@@ -207,8 +207,8 @@ namespace YLErp.Modules.SwapModule
|
||||
return events;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取交易操作历史。登记日创建但尚未到 EffectiveDate 的公司行为事件也保留,
|
||||
/// 由 EventData.Applied=false 表示“待生效”,保证审计日志完整可追溯。
|
||||
/// 获取交易操作历史。登记日创建的待生效公司行为仍保留在审计数据中,
|
||||
/// 但在 EffectiveDate 将其更新为 Applied=true 前不对操作历史展示。
|
||||
/// </summary>
|
||||
/// <param name="tradeId">交易id</param>
|
||||
/// <returns></returns>
|
||||
@@ -218,7 +218,30 @@ namespace YLErp.Modules.SwapModule
|
||||
.Where(x => x.SwapTradeId == tradeId)
|
||||
.OrderByDescending(o => o.id)
|
||||
.ToList();
|
||||
return list;
|
||||
return FilterOperationHistory(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 过滤尚未生效的公司行为事件。非公司行为、已生效事件和无法识别的历史事件均保留,
|
||||
/// 避免过滤条件误伤既有操作记录。
|
||||
/// </summary>
|
||||
private static List<swap_event> FilterOperationHistory(IEnumerable<swap_event> events)
|
||||
{
|
||||
if (events == null)
|
||||
{
|
||||
return new List<swap_event>();
|
||||
}
|
||||
|
||||
return events
|
||||
.Where(x => !IsPendingCorporateActionEvent(x))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static bool IsPendingCorporateActionEvent(swap_event swapEvent)
|
||||
{
|
||||
return swapEvent?.EventType == (int)SwapEventTypeEnum.公司行为
|
||||
&& TryDeserializeCorporateActionEventData(swapEvent, out var data)
|
||||
&& !data.Applied;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -257,9 +280,36 @@ namespace YLErp.Modules.SwapModule
|
||||
return "公司行为快照为空";
|
||||
}
|
||||
|
||||
// 使用 InvariantCulture 固定小数格式,说明文本不随服务器区域设置变化。
|
||||
// 使用 InvariantCulture 固定小数和日期格式,说明文本不随服务器区域设置变化。
|
||||
string D(decimal value) => value.ToString(CultureInfo.InvariantCulture);
|
||||
return $"调整前:名义本金:{D(data.BeforeNotional)} 期初标的价格:{D(data.BeforePrice)} 持仓数量:{D(data.BeforeQuantity)}"
|
||||
string Date(DateTime? value) => value.HasValue
|
||||
? value.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
|
||||
: "";
|
||||
string ActionDescription()
|
||||
{
|
||||
if (data.RationedSharesAmount != 0m)
|
||||
{
|
||||
return "配股";
|
||||
}
|
||||
if (data.GiveShareAmount != 0m)
|
||||
{
|
||||
return "送股";
|
||||
}
|
||||
if (data.Split.HasValue && data.Split.Value != 1m)
|
||||
{
|
||||
return "拆分";
|
||||
}
|
||||
if (data.GiveCashAmount != 0m)
|
||||
{
|
||||
// return $"产生分红:{D(data.CashFlowChange)}";
|
||||
return $"产生分红";
|
||||
}
|
||||
return "公司行为";
|
||||
}
|
||||
|
||||
return $"股权登记日:{Date(data.ExDividendDate)} 发生公司行为({ActionDescription()})"
|
||||
+ Environment.NewLine
|
||||
+ $"调整前:名义本金:{D(data.BeforeNotional)} 期初标的价格:{D(data.BeforePrice)} 持仓数量:{D(data.BeforeQuantity)}"
|
||||
+ Environment.NewLine
|
||||
+ $"调整后:名义本金:{D(data.AfterNotional)} 期初标的价格:{D(data.AfterPrice)} 持仓数量:{D(data.AfterQuantity)}";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user