fix: 限制互换展期新到期日不得早于原到期日
This commit is contained in:
@@ -94,28 +94,34 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
var obj = DbContext.swap_event.Where(O => O.id == swap_Event.id).FirstOrDefault();
|
||||
var trade = DbContext.trade.Where(O => O.id == swap_Event.SwapTradeId).FirstOrDefault();
|
||||
if (trade == null)
|
||||
{
|
||||
throw new ServiceException("未找到交易,请刷新页面后再次尝试!");
|
||||
}
|
||||
var oldMaturityDate = trade.ExerciseDate.Value;
|
||||
if (obj != null && !string.IsNullOrEmpty(obj.EventData))
|
||||
{
|
||||
oldMaturityDate = JsonConvert.DeserializeObject<ExtenstionData>(obj.EventData).OldMaturityDate;
|
||||
}
|
||||
if (swap_Event.extenstionData.NewMaturityDate <= oldMaturityDate)
|
||||
{
|
||||
throw new ServiceException("新到期日应晚于原到期日!");
|
||||
}
|
||||
if (obj != null && obj.ValueDate >= swap_Event.ValueDate)
|
||||
{
|
||||
throw new ServiceException("新展期日应晚于原展期日!");
|
||||
}
|
||||
if (swap_Event.extenstionData.NewMaturityDate< trade.StartDate)
|
||||
{
|
||||
throw new ServiceException("新到期日不应早于交易开始日期!");
|
||||
}
|
||||
swap_Event.extenstionData.OldMaturityDate = oldMaturityDate;
|
||||
string data = JsonConvert.SerializeObject(swap_Event.extenstionData);
|
||||
if (obj != null)
|
||||
{
|
||||
obj.Invalid = true;
|
||||
}
|
||||
swap_Event.EventReason = "交易展期";
|
||||
if (swap_Event.extenstionData.OldMaturityDate == swap_Event.extenstionData.NewMaturityDate)
|
||||
{
|
||||
throw new ServiceException("新到期日不应和原到期日一致!");
|
||||
}
|
||||
if (obj!=null&&obj.ValueDate >= swap_Event.ValueDate)
|
||||
{
|
||||
throw new ServiceException("新展期日应晚于原展期日!");
|
||||
}
|
||||
if (trade == null)
|
||||
{
|
||||
throw new ServiceException("未找到交易,请刷新页面后再次尝试!");
|
||||
}
|
||||
if (swap_Event.extenstionData.NewMaturityDate< trade.StartDate)
|
||||
{
|
||||
throw new ServiceException("新到期日不应早于交易开始日期!");
|
||||
}
|
||||
trade.ExerciseDate = swap_Event.extenstionData.NewMaturityDate;
|
||||
//修改互换观察日到期日
|
||||
new SwapTradeService(this).UpdateObservationDay(trade.id, swap_Event.extenstionData.OldMaturityDate, trade.ExerciseDate.Value);
|
||||
|
||||
Reference in New Issue
Block a user