public JsonResult AddSharBargainProduct(ShareBargainProductModel request) { if (request.EndDateTime < request.BeginDateTime) { return(Json(new { Code = 0, Info = "下架时间必须大于上架时间" })); } if (request.ShowBeginTime >= request.BeginDateTime) { return(Json(new { Code = 0, Info = "开始显示时间必须小于上架时间" })); } var data = ShareBargainManager.CheckPid(request.PID, request.BeginDateTime, request.EndDateTime); if (data.Code == 2) { return(Json(new { Code = 0, Info = "该时间段不能配置该商品" })); } var dat = ShareBargainManager.AddSharBargainProduct(request, ThreadIdentity.Operator.Name); if (dat) { using (var client = new ShareBargainClient()) { client.RefreshShareBargainCache(); } return(Json(new { Code = 1, Info = "添加成功" })); } return(Json(new { Code = 0, Info = "添加失败,请稍后重试" })); }
public JsonResult AddSharBargainProduct(ShareBargainProductModel request) { request.ProductType = 1; if (request.EndDateTime < request.BeginDateTime) { return(Json(new { Code = 0, Info = "下架时间必须大于上架时间" })); } if (request.ShowBeginTime > request.BeginDateTime) { return(Json(new { Code = 0, Info = "开始显示时间必须小于等于上架时间" })); } if (request.BigCutBeforeCount != null && request.BigCutPriceRate != null) { if ((request.BigCutBeforeCount == null && request.BigCutPriceRate != null) || (request.BigCutBeforeCount != null && request.BigCutPriceRate == null)) { return(Json(new { Code = 0, Info = "请填写完整的金额分布人数和百分比" })); } if (request.BigCutBeforeCount <= 0 || request.BigCutPriceRate <= 0 || request.BigCutPriceRate >= 100) { return(Json(new { Code = 0, Info = "请填写正确的金额分布人数和百分比" })); } if (request.Times <= request.BigCutBeforeCount) { return(Json(new { Code = 0, Info = "金额分布人数应小于砍价次数" })); } } try { var data = ShareBargainManager.CheckPid(request.PID, request.BeginDateTime, request.EndDateTime); if (data.Code == 2) { return(Json(new { Code = 0, Info = "该时间段不能配置该商品" })); } var addResultPKID = ShareBargainManager.AddSharBargainProduct(request, ThreadIdentity.Operator.Name); if (addResultPKID > 0) { AddSharBargainLog(addResultPKID); using (var client = new ShareBargainClient()) { var refreshResult = client.RefreshShareBargainCache(); if (!refreshResult.Success) { //缓存刷新失败补偿一次 var repeatRefreshResult = client.RefreshShareBargainCache(); if (!repeatRefreshResult.Success) { Logger.Log(Level.Warning, $"AddSharBargainProduct,刷新缓存失败,ErrorMessage:{repeatRefreshResult.ErrorMessage}"); return(Json(new { Code = 1, Info = "数据保存成功,但刷新缓存失败,请手动刷新缓存" })); } } } return(Json(new { Code = 1, Info = "添加成功" })); } } catch (Exception ex) { Logger.Log(Level.Error, $"AddSharBargainProduct异常,ex{ex}"); } return(Json(new { Code = 0, Info = "添加失败,请稍后重试" })); }