public ActionResult GetFreeDetail(long userid, int freeid) { var product = FreeProductService.GetInfo(freeid); var frecordToday = FreeRecordService.GetTodayRecord(userid); var frecord = FreeRecordService.GetInfo(userid, freeid); if (product != null) { var obj = new { id = product.ID, name = product.Name, imgs = product.ImgUrls.Split('|'), desc = product.Desc, count = product.Count, remain = product.RQty, isget = frecord != null, isgetother = frecordToday != null, status = product.Status, time = product.AddedTime.Value.ToString("MM/dd 23:59") }; return(Json(new { code = 0, data = obj }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = 1, msg = "赠品不存在" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(FreeRecord fr) { string msg = ""; int result = 0; long id = fr.ID; if (fr.ID > 0) { result = FreeRecordService.Update(fr); if (result > 0) { msg = "更新成功"; } else { msg = "更新失败"; } } else { result = 0; if (fr.UserID > 0 && fr.FreeID > 0) { Users user = UsersService.GetInfo(fr.UserID); if (user == null || user.ID <= 0) { msg = "用户ID不正确"; } else { result = FreeRecordService.CheckAndInsert(fr.UserID, fr.FreeID, out id); switch (result) { case 0: msg = "添加成功"; break; case 1: msg = "赠品ID不正确"; break; case 2: msg = "赠品已送完"; break; case 3: msg = "活动已结束"; break; case 4: msg = "已申请过赠品"; break; case 5: msg = "添加失败"; break; case 6: msg = "更新赠品失败"; break; case 7: msg = "该用户今天已领过赠品"; break; default: msg = "添加失败"; break; } } } else { msg = "用户ID和赠品ID不能为空"; } } return(Content("<script>alert('" + msg + "');window.location.href='" + Url.Content("~/record/add?id=") + id + "';</script>")); }
public ActionResult GetFree(long userid, string wechat, int freeid) { var code = 101; var msg = "101-系统错误,请联系客服"; if (string.IsNullOrWhiteSpace(wechat)) { code = 102; msg = "请填写微信号"; } else if (userid <= 0) { code = 103; msg = "103-用户不存在"; } else { Users u = UsersService.GetInfo(userid); if (u == null) { code = 104; msg = "104-用户不存在"; } else { if (string.IsNullOrWhiteSpace(u.WeChat) || u.WeChat.ToLower() != wechat.ToLower()) { u.WeChat = wechat; UsersService.Update(u); } long frid = 0; int result = FreeRecordService.CheckAndInsert(userid, freeid, out frid); switch (result) { case 0: code = 0; msg = "领取成功"; break; case 1: code = 1; msg = "赠品ID错误"; break; case 2: code = 2; msg = "赠品已送完"; break; case 3: code = 3; msg = "活动已结束"; break; case 4: code = 4; msg = "您已领过该赠品"; break; case 5: code = 5; msg = "赠品领取失败,请联系客服"; break; case 6: code = 6; msg = "数据出错,请联系客服"; break; case 7: code = 7; msg = "您今天已经领过其它赠品了"; break; default: code = 101; msg = "数据出错,请联系客服"; break; } } } return(Json(new { code = code, msg = msg }, JsonRequestBehavior.AllowGet)); }
// GET: Record public ActionResult Index(int freeId = 0, int pageIndex = 1, int pageSize = 20) { int totalCount = 0; var productList = FreeRecordService.GetList(freeId, pageSize, pageIndex, out totalCount); ViewBag.PageCount = totalCount % pageSize == 0 ? (int)totalCount / pageSize : (int)totalCount / pageSize + 1; ViewBag.FreeID = freeId; ViewBag.PageIndex = pageIndex; return(View(productList)); }
public ActionResult Delete(string ids) { string[] idArr = ids.Split(','); if (idArr.Length > 0) { foreach (var s in idArr) { FreeRecordService.Delete(Convert.ToInt64(s)); } } return(Json(new { code = 0 }, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(long?id) { FreeRecord fr = new FreeRecord(); if (id.HasValue && id > 0) { fr = FreeRecordService.GetInfo(id.Value); if (fr == null) { fr = new FreeRecord(); } } return(View(fr)); }