diff --git a/YLErpDAL/Modules/SwapModule/SwapEventService.cs b/YLErpDAL/Modules/SwapModule/SwapEventService.cs index 844d30b5..782b83e1 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEventService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEventService.cs @@ -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(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); diff --git a/YLErpWeb/Views/SwapTrade2/ExtensionTime.cshtml b/YLErpWeb/Views/SwapTrade2/ExtensionTime.cshtml index 0c7748b9..3b541234 100644 --- a/YLErpWeb/Views/SwapTrade2/ExtensionTime.cshtml +++ b/YLErpWeb/Views/SwapTrade2/ExtensionTime.cshtml @@ -55,7 +55,7 @@ {{dateFormat(extenstion.extenstionData.OldMaturityDate)}} - + {{extenstion.OptName}} {{dateFormat(extenstion.OptTime,'YYYY-MM-DD HH:mm:ss')}} diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/ExtenstionTime.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/ExtenstionTime.js index ce15be8f..7749b49b 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/ExtenstionTime.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/ExtenstionTime.js @@ -31,6 +31,10 @@ main.message("新到期日不能为空"); return; } + if (this.extenstion.extenstionData.NewMaturityDate <= this.extenstion.extenstionData.OldMaturityDate) { + main.message("新到期日应晚于原到期日"); + return; + } main.post("/swaptrade2/SaveExtension", { swap_Event: thisObj.extenstion }) .done(function (res) { thisObj.extenstion.id = res.obj.id; @@ -80,4 +84,4 @@ components: { 'vue-datepicker': FastVue.vueDatePicker(), } -}); \ No newline at end of file +});