public ActionResult ExamActivity(Guid aid) { try { var result = QiangGouManager.ExamActivity(aid); if (result > 0) { var del = SeckillManager.DeleteStatusData(aid.ToString()); if (del > 0) { result = 1; } } if (result > 0) { SeckillManager.OpertionLogs(SeckillManager.OpertionType.ApprovePass, "", "", aid.ToString()); } return(Json(new { code = result })); } catch (Exception e) { return(Json(new { code = -3, msg = e.Message + e.InnerException + e.StackTrace })); } }
private bool RefershSekillCache(Guid aid) { using (var client = new CacheClient()) { var cacheresult = client.RefreshRedisCachePrefixForCommon(new RefreshCachePrefixRequest() { Prefix = "SecondKillPrefix", ClientName = "FlashSale", Expiration = TimeSpan.FromDays(1) }); cacheresult.ThrowIfException(true); } var cache = QiangGouManager.ReflashQiangGouCache(aid, false, 1); if (cache == false) { return(false); } var pids = SeckillManager.SelectActivityProductPids(aid); Thread.Sleep(50); TuhuNotification.SendNotification("notification.productModify.ProductCommonTag", new { type = "RebuildCache", pids, tag = ProductCommonTag.Seckilling }); return(true); }
public JsonResult GetSeckillList(string dt) { try { var datedt = string.IsNullOrEmpty(dt) ? DateTime.Now : Convert.ToDateTime(dt.Replace("GMT+0800 (中国标准时间)", "")); var week = datedt.DayOfWeek.ToString(); var footDay = ""; switch (week) { case "Monday": footDay = $"{datedt.ToShortDateString()}-{datedt.AddDays(6).ToShortDateString()}"; break; case "Tuesday": footDay = $"{datedt.AddDays(-1).ToShortDateString()}-{datedt.AddDays(5).ToShortDateString()}"; break; case "Wednesday": footDay = $"{datedt.AddDays(-2).ToShortDateString()}-{datedt.AddDays(4).ToShortDateString()}"; break; case "Thursday": footDay = $"{datedt.AddDays(-3).ToShortDateString()}-{datedt.AddDays(3).ToShortDateString()}"; break; case "Friday": footDay = $"{datedt.AddDays(-4).ToShortDateString()}-{datedt.AddDays(2).ToShortDateString()}"; break; case "Saturday": footDay = $"{datedt.AddDays(-5).ToShortDateString()}-{datedt.AddDays(1).ToShortDateString()}"; break; case "Sunday": footDay = $"{datedt.AddDays(-6).ToShortDateString()}-{datedt.ToShortDateString()}"; break; default: break; } var result = SeckillManager.SelectSeckillList(datedt); return(Json(new { result, FooterDay = footDay }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Console.WriteLine(e); throw; } }
public ActionResult ExamActivity(Guid aid) { try { var result = QiangGouManager.ExamActivity(aid); if (result > 0) { var del = SeckillManager.DeleteStatusData(aid.ToString()); if (del > 0) { result = 1; } } if (result > 0) { using (var client = new CacheClient()) { var cacheresult = client.RefreshRedisCachePrefixForCommon(new RefreshCachePrefixRequest() { Prefix = "SecondKillPrefix", ClientName = "FlashSale", Expiration = TimeSpan.FromDays(1) }); cacheresult.ThrowIfException(true); } var cache = QiangGouManager.ReflashQiangGouCache(aid, false, 1); if (cache == false) { return(Json(new { Status = 0, Message = "刷新缓存失败【请手动刷新】" })); } SeckillManager.OpertionLogs(SeckillManager.OpertionType.ApprovePass, "", "", aid.ToString()); } return(Json(new { code = result })); } catch (Exception e) { return(Json(new { code = -3, msg = e.Message + e.InnerException + e.StackTrace })); } }
public JsonResult GetEditDatasByActivityId(string activityId, bool isDefault, string strStatus) { QiangGouModel model = new QiangGouModel(); if (strStatus == "待审核" || strStatus == "已驳回") { Guid activityID; if (Guid.TryParse(activityId, out activityID)) { model = QiangGouManager.FetchNeedExamQiangGouAndProducts(activityID); } } else { model = SeckillManager.FetchNeedExamQiangGouAndProducts(new Guid(activityId)); } return(Json( model?.Products ?? new List <QiangGouProductModel>() , JsonRequestBehavior.AllowGet)); }
public ActionResult ApproveBack(Guid aid) { try { var result = SeckillManager.ApproveBack(aid.ToString()); if (result > 0) { SeckillManager.OpertionLogs(SeckillManager.OpertionType.ApproveBack, "", "", aid.ToString()); } return(Json(new { code = result })); } catch (Exception e) { return(Json(new { code = -3, msg = e.Message + e.InnerException + e.StackTrace })); } }
public ActionResult Save(string strmodel, string products, string originProducts) { try { if (strmodel == null) { return(Json(new { Status = 0, Message = "保存失败【活动内容为空】" })); } var model1 = JsonConvert.DeserializeObject <QiangGouModel>(strmodel); if (model1.StrStatus == "已驳回") { if (SeckillManager.SelectQiangGouIsExist(model1.ActivityID.ToString()) == 0) { var delResult = SeckillManager.DeleteFirstCreateActivityApproveBack(model1.ActivityID.ToString()); if (delResult == -1) { return(Json(new { Status = 0, Message = "保存失败【请重试】" })); } model1.ActivityID = null; } } var model = new QiangGouModel(); if (model1.IsDefault) { switch (model1.ActivityName) { case "0点场": model.StartDateTime = Convert.ToDateTime(DateTime.Now.ToString("2018-04-26 00:00:00")); model.EndDateTime = Convert.ToDateTime(DateTime.Now.ToString("2019-04-26 10:00:00")); break; case "10点场": model.StartDateTime = Convert.ToDateTime(DateTime.Now.ToString("2018-04-26 10:00:00")); model.EndDateTime = Convert.ToDateTime(DateTime.Now.ToString("2019-04-26 13:00:00")); break; case "13点场": model.StartDateTime = Convert.ToDateTime(DateTime.Now.ToString("2018-04-26 13:00:00")); model.EndDateTime = Convert.ToDateTime(DateTime.Now.ToString("2019-04-26 16:00:00")); break; case "16点场": model.StartDateTime = Convert.ToDateTime(DateTime.Now.ToString("2018-04-26 16:00:00")); model.EndDateTime = Convert.ToDateTime(DateTime.Now.ToString("2019-04-26 20:00:00")); break; case "20点场": model.StartDateTime = Convert.ToDateTime(DateTime.Now.ToString("2018-04-26 20:00:00")); model.EndDateTime = Convert.ToDateTime(DateTime.Now.ToString("2019-04-26 23:59:59")); break; } model.IsDefault = model1.IsDefault; model.ActivityID = model1.ActivityID; model.ActiveType = 1; model.ActivityName = $"默认配置:{model1.ActivityName}"; model.NeedExam = model1.NeedExam; } else { switch (model1.ActivityName) { case "0点场": model.StartDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 00:00:00")); model.EndDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 10:00:00")); break; case "10点场": model.StartDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 10:00:00")); model.EndDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 13:00:00")); break; case "13点场": model.StartDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 13:00:00")); model.EndDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 16:00:00")); break; case "16点场": model.StartDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 16:00:00")); model.EndDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 20:00:00")); break; case "20点场": model.StartDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 20:00:00")); model.EndDateTime = Convert.ToDateTime(Convert.ToDateTime(model1.ShortDate).ToString("yyyy-MM-dd 23:59:59")); break; } model.IsDefault = model1.IsDefault; model.ActivityID = model1.ActivityID; model.ActiveType = 1; model.ActivityName = $"{model1.ShortDate}:{model1.ActivityName}"; model.NeedExam = model1.NeedExam; } var isUpdate = model.ActivityID != null; var originModels = new List <QiangGouProductModel>(); if (originProducts != "[]" && !string.IsNullOrWhiteSpace(originProducts)) { originModels = JsonConvert.DeserializeObject <List <QiangGouProductModel> >(originProducts); } model.Products = JsonConvert.DeserializeObject <List <QiangGouProductModel> >(products); List <QiangGouDiffModel> qiangGouDiff = new List <QiangGouDiffModel>(); if (!model.Products.Any()) { return(Json(new { Status = 0, Message = "保存失败【活动无产品】" })); } var result = QiangGouManager.Save(model, qiangGouDiff); if (result.Item1 == -1) { return(Json(new { Status = 0, Message = "保存失败【闪购活动时间不允许重叠】" })); } if (result.Item1 == -3) { return(Json(new { Status = 0, Message = "刷新缓存失败【请手动刷新】" })); } else if (result.Item1 > 0) { if (model.NeedExam) { var approveResult = SeckillManager.UpdateSeckillToToApprove(result.Item2.ToString()); { if (approveResult <= 0) { return(Json(new { Status = 0, Message = "保存失败重试" })); } } } if (!isUpdate) { SeckillManager.OpertionLogs(SeckillManager.OpertionType.Add, model.Products.Count().ToString(), "", result.Item2.ToString()); } else { var logdata = CompareModifyData(originModels, model.Products.ToList()); foreach (var log in logdata) { if (log.Key == SeckillManager.OpertionType.EditEdit) { var count = log.Value.Length; //先拆成两段来存储,如果后面出现还存不下的想办法多条存储 SeckillManager.OpertionLogs(log.Key, log.Value.Substring(0, count / 2), log.Value.Substring(count / 2), result.Item2.ToString()); } else { SeckillManager.OpertionLogs(log.Key, log.Value, "", result.Item2.ToString()); } } } var request = new ActivityTypeRequest() { ActivityId = model.ActivityID.Value, StartDateTime = model.StartDateTime, EndDateTime = model.EndDateTime, Status = 1, Type = 1 }; var activityTypeResult = QiangGouManager.RecordActivityType(request); if (!activityTypeResult) { return(Json(new { Status = 0, Message = "保存失败重试" })); } if (model.ActivityID != null && !model.NeedExam) { var cache = QiangGouManager.ReflashQiangGouCache(model.ActivityID.Value, false, model.ActiveType); if (cache == false) { return(Json(new { Status = 0, Message = "刷新缓存失败【请手动刷新】" })); } } return(Json(new { Status = 1, Message = "保存成功" })); } return(Json(new { Status = 0, Message = "保存失败【未知错误】" })); } catch (Exception e) { return(Json(new { Status = 0, Message = e.Message + e.InnerException + e.StackTrace })); } }