diff --git a/YLErpDAL/Modules/SystemModule/XBondSpreadService.cs b/YLErpDAL/Modules/SystemModule/XBondSpreadService.cs index 1aa8e9e0..38caacfe 100644 --- a/YLErpDAL/Modules/SystemModule/XBondSpreadService.cs +++ b/YLErpDAL/Modules/SystemModule/XBondSpreadService.cs @@ -13,30 +13,28 @@ namespace YLErp.Modules.SystemModule public XBondSpreadService() { } - - public XBondSpread Result { get; private set; } public void SetXBondSpread(XBondSpread xBondSpread, IYLCache ylCache) { - if (ylCache.CacheEnable()) + try { - ylCache.StringSet(RedisKey, xBondSpread); + ylCache.StringSetWithNoPrefix(RedisKey, xBondSpread, null); } - else + catch(Exception) { - Result = xBondSpread; + throw new Exception("偏移设置保存失败"); } } public XBondSpread GetXBondSpread(IYLCache ylCache) { - if (ylCache.CacheEnable()) + try { - return ylCache.StringGet(RedisKey); + return ylCache.StringGetWithNoPrefix(RedisKey); } - else + catch(Exception) { - return Result; + throw new Exception("偏移设置获取失败"); } } } diff --git a/YLErpWeb/Controllers/ExchangeTradeController.cs b/YLErpWeb/Controllers/ExchangeTradeController.cs index 3317e17a..7b25707c 100644 --- a/YLErpWeb/Controllers/ExchangeTradeController.cs +++ b/YLErpWeb/Controllers/ExchangeTradeController.cs @@ -270,13 +270,28 @@ namespace YLErp.Web.Controllers [MyAuthorize("交易管理-偏移设置")] public ActionResult SpreadSetting() { - return View(new XBondSpreadService().GetXBondSpread(_yLCache) ?? new XBondSpread() { bid = 0, ofr = 0 }); + var result = new XBondSpread() { bid = 0, ofr = 0 }; + try + { + result = new XBondSpreadService().GetXBondSpread(_yLCache); + } + catch(Exception) + { + } + return View(result); } public JsonResult AjaxSaveSpreadSetting(XBondSpread data) { - new XBondSpreadService().SetXBondSpread(data, _yLCache); - return JsonSuccess(); + try + { + new XBondSpreadService().SetXBondSpread(data, _yLCache); + return JsonSuccess(); + } + catch(Exception ex) + { + return JsonError(ex.Message); + } } } } diff --git a/YLErpWeb/Views/ExchangeTrade/SpreadSetting.cshtml b/YLErpWeb/Views/ExchangeTrade/SpreadSetting.cshtml index 6c950785..62c3c761 100644 --- a/YLErpWeb/Views/ExchangeTrade/SpreadSetting.cshtml +++ b/YLErpWeb/Views/ExchangeTrade/SpreadSetting.cshtml @@ -29,8 +29,12 @@ url: "/ExchangeTrade/AjaxSaveSpreadSetting", data: { bid, ofr }, success: function (data) { - window.parent.showmiddlemessage('偏移设置成功'); - // 关闭对话框 + if (!data.success){ + main.alert(data.msg); + return + } + window.parent.showmiddlemessage('偏移设置成功'); + // 关闭对话框 layer.closeMe(); } });