public ActionResult GetList(int id, string title, DateTime start, DateTime end, int page = 1, int size = 100) { List <Product_MY> plist = ProductMyService.GetList(id, start, end, title, page, size); List <object> objList = new List <object>(); if (plist.Count > 0) { foreach (var item in plist) { objList.Add(new { id = item.ID, title = item.PTitle, intro = item.PIntro, img = item.PImgUrls.Split('|')[0], coupon = item.CouponMoney, key = item.CouponCommand, price = item.PPrice, link = item.CouponShortLink, sales = item.PSales }); } } return(Json(new { code = 0, data = objList }, JsonRequestBehavior.AllowGet)); }
public ActionResult TaobaoP(string cmdText, int cid = 0) { int code = 0; string msg = "添加成功"; if (string.IsNullOrWhiteSpace(cmdText)) { code = 107; msg = "参数错误"; return(Json(new { code = code, msg = msg }, JsonRequestBehavior.AllowGet)); } int result = ProductMyService.TaobaoAppInput(cmdText, cid); switch (result) { case 0: code = 0; msg = "添加成功"; break; case 1: code = 1; msg = "无法获取短链接"; 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; } return(Json(new { code = code, msg = msg }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetDetail(long id) { Product_MY product = ProductMyService.GetInfo(id); if (product != null) { var redpack = UtilityService.GetRedPack(product.PPrice.Value, product.CouponMoney.Value, 10); return(Json(new { code = 0, result = new { id = product.ID, name = product.PTitle, img = product.PImgUrls.Split('|')[0], price = product.PPrice - product.CouponMoney - redpack, coupon = product.CouponMoney, redpack = redpack, sales = product.PSales, key = product.CouponCommand } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = 1, result = new { } }, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetList(string name, int type = 0, int page = 1, int size = 5) { List <Product_MY> list = ProductMyService.GetList(0, DateTime.Now.AddDays(-2), DateTime.Now.AddDays(1)); if (type == 0 && !String.IsNullOrWhiteSpace(name)) { list = list.FindAll(l => l.PTitle.Contains(name)); } if (type == 1) { list = list.FindAll(l => (l.PPrice - l.CouponMoney) < 9.9m); } int totalPage = 0; if (list.Count > 0) { totalPage = list.Count % size == 0 ? Convert.ToInt16(list.Count / size) : Convert.ToInt16(list.Count / size) + 1; } if (page > totalPage) { return(Json(new { code = 0, result = new { }, total = totalPage }, JsonRequestBehavior.AllowGet)); } else { var objList = new List <object>(); list = list.Take(size * page).Skip(size * (page - 1)).ToList <Product_MY>(); var redpack = 0.00m; foreach (var item in list) { redpack = UtilityService.GetRedPack(item.PPrice.Value, item.CouponMoney.Value, 10); objList.Add(new { id = item.ID, name = item.PTitle, img = item.PImgUrls.Split('|')[0], price = item.PPrice - item.CouponMoney - redpack, coupon = item.CouponMoney, sales = item.PSales, redpack = redpack }); } return(Json(new { code = 0, result = objList, total = totalPage }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Detail(long id, bool isjson = false) { Product_MY product = ProductMyService.GetInfo(id); if (string.IsNullOrWhiteSpace(product.CouponCommand)) { ITopClient client = new DefaultTopClient(ConfigService.TaoBaoApiUrl, "24526506", "5a9e071dacf3f6f925eccce6f7b99602", "json"); TbkTpwdCreateRequest req = new TbkTpwdCreateRequest(); req.UserId = "98776048"; req.Text = product.PTitle; req.Url = product.CouponLink; req.Logo = product.PImgUrls.Replace("300x300", "100x100"); req.Ext = "{\"test\":\"testv\"}"; TbkTpwdCreateResponse rsp = client.Execute(req); JObject obj = JObject.Parse(rsp.Body); if (obj["tbk_tpwd_create_response"] != null && obj["tbk_tpwd_create_response"]["data"] != null && obj["tbk_tpwd_create_response"]["data"]["model"] != null) { product.CouponCommand = obj["tbk_tpwd_create_response"]["data"]["model"].ToString(); ProductMyService.Update(product); if (isjson) { return(Json(new { key = product.CouponCommand }, JsonRequestBehavior.AllowGet)); } } else { ErrorLog.WriteTextLog("", rsp.Body, DateTime.Now); if (isjson) { return(Json(new { key = "" }, JsonRequestBehavior.AllowGet)); } } } else if (isjson) { return(Json(new { key = product.CouponCommand }, JsonRequestBehavior.AllowGet)); } return(View(product)); }
public ActionResult HandP(string imgUrl, string cmdText, int cid = 0) { int code = 0; string msg = "添加成功"; if (string.IsNullOrWhiteSpace(imgUrl) || string.IsNullOrWhiteSpace(cmdText)) { code = 107; msg = "参数错误"; return(Json(new { code = code, msg = msg }, JsonRequestBehavior.AllowGet)); } int result = ProductMyService.QTKInput(imgUrl, cmdText, cid); switch (result) { case 0: code = 0; msg = "添加成功"; break; case 1: code = 1; msg = "数据转换出错"; break; case 2: code = 2; msg = "系统出错"; break; } return(Json(new { code = code, msg = msg }, JsonRequestBehavior.AllowGet)); }
// GET: Weibo //public ActionResult Index(int? id, DateTime? dt,string title="") //{ // DateTime dtStart = dt.HasValue ? dt.Value.AddDays(-7) : DateTime.Now.AddDays(-1).Date; // DateTime dtEnd = dt.HasValue ? dt.Value : DateTime.Now.AddDays(1).Date; // ViewBag.Start = dtStart; // ViewBag.End = dtEnd; // ViewBag.ID = id.HasValue ? id.Value : 0; // ViewBag.Title = title; // return View(); //} //public ActionResult GetList(int id,string title,DateTime start,DateTime end,int page=1,int size=100) //{ // List<Product_MY> plist = ProductMyService.GetList(id, start, end, title, page, size); // List<object> objList = new List<object>(); // if (plist.Count > 0) // { // foreach (var item in plist) // { // objList.Add(new // { // title = item.PTitle, // intro = item.PIntro, // img = item.PImgUrls.Split('|')[0], // coupon = item.CouponMoney, // key = item.CouponCommand, // price = item.PPrice, // link = item.CouponShortLink, // sales = item.PSales // }); // } // } // return Json(new { code = 0, data = objList }, JsonRequestBehavior.AllowGet); //} public ActionResult Index(int?id, DateTime?dt, string title = "") { DateTime dtStart = dt.HasValue ? dt.Value.AddDays(-7) : DateTime.Now.AddDays(-2).Date; DateTime dtEnd = dt.HasValue ? dt.Value : DateTime.Now.AddDays(1).Date; List <Product_MY> plist = ProductMyService.GetList(id.HasValue?id.Value:0, dtStart, dtEnd, title, 1, 90); Dictionary <string, string> dict = new Dictionary <string, string>(); if (plist != null && plist.Count > 0) { string key = ""; string value = ""; int index = 1; int total = 0; foreach (var item in plist) { total++; key += item.PImgUrls.Split('|')[0] + "|"; value += "图" + (index) + item.PTitle + item.CouponShortLink + ","; if (index % 9 == 0 || total == plist.Count) { key = key.TrimEnd('|'); value = "#淘宝大牌优惠#" + value.TrimEnd(',') + ",更多优惠http://yougou8.com.cn/wechat/1.html"; dict.Add(key, value); key = ""; value = ""; index = 1; } else { index++; } } } ViewBag.Dict = dict; return(View()); }
public ActionResult Code(long id) { Product_MY product = ProductMyService.GetInfo(id); string imgSrc = ""; if (product != null) { if (string.IsNullOrWhiteSpace(product.Remark)) { imgSrc = CodeHelper.CombinImage(product.PImgUrls.Split('|')[0], product.ID, product.PTitle, product.PPrice.Value, product.CouponMoney.Value, product.PSales.Value); if (!string.IsNullOrWhiteSpace(imgSrc)) { product.Remark = imgSrc; ProductMyService.Update(product); } } else { imgSrc = product.Remark; } } ViewBag.Src = imgSrc; return(View()); }