/// <summary> /// 获取闪电抢购商品列表 /// </summary> /// <param name="page"></param> /// <param name="limte"></param> /// <returns></returns> public BuyingOutput GetBuyingGood(int page, int limte) { var buymod = new BuyingOutput(); var list = new List <HomeGoodOutput>(); var data = EF.GoodPromotions.OrderBy(a => a.StartTiem).FirstOrDefault(a => a.PromotionName.Contains("闪电抢购") && a.EndTime > DateTime.Now && a.IsDelect == true); var promotionlist = EF.Good_Promotions.Where(a => a.PromotionId == data.PromotionId).ToList(); foreach (var item in promotionlist) { var mod = new HomeGoodOutput() { GoodId = item.GoodId, GoodName = EF.Goods.FirstOrDefault(a => a.GoodId == item.GoodId).GoodName, HardId = item.PromotionId, HardName = EF.GoodPromotions.FirstOrDefault(a => a.PromotionId == item.PromotionId).PromotionName, ImgUrl = "https://localhost:44363/file/image/200/" + EF.Goods.FirstOrDefault(a => a.GoodId == item.GoodId).ThumbnailImg, CreateTime = EF.Goods.FirstOrDefault(a => a.GoodId == item.GoodId).CreateTime, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderByDescending(a => a.Price).FirstOrDefault(a => a.GoodId == item.GoodId && a.Price != 0 && a.IsDelect == true).Price), Discounts = item.Discounts, }; list.Add(mod); } buymod.ChlidGood = list.Skip((page - 1) * limte).Take(limte).ToList(); buymod.EndTime = EF.GoodPromotions.FirstOrDefault(a => a.PromotionId == data.PromotionId).EndTime.ToString("yyyy-MM-dd HH:mm:ss"); buymod.StartTiem = EF.GoodPromotions.FirstOrDefault(a => a.PromotionId == data.PromotionId).StartTiem.ToString("yyyy-MM-dd HH:mm:ss"); return(buymod); }
/// <summary> /// 查询首页分类商品 /// </summary> /// <param name="page"></param> /// <param name="limte"></param> /// <returns></returns> public List <HomeCateOutput> GetHomeGood(int page, int limte) { var homecatelist = new List <HomeCateOutput>(); var data = EF.GoodCategories.Where(a => a.IsDelect == true && a.ParentId == "").ToList(); foreach (var item in data) { var list = new List <HomeGoodOutput>(); var homecatemod = new HomeCateOutput(); var goodlist = EF.Goods.Where(a => a.CategoryID == item.CategoryID).Take(limte).ToList(); foreach (var i in goodlist) { var mod = new HomeGoodOutput() { HardId = i.CategoryID, HardName = EF.GoodCategories.FirstOrDefault(a => a.CategoryID == i.CategoryID).CategoryName, GoodId = i.GoodId, GoodName = i.GoodName, ImgUrl = "https://localhost:44363/file/image/200/" + i.ThumbnailImg, CreateTime = i.CreateTime, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderBy(a => a.Price).FirstOrDefault(a => a.GoodId == i.GoodId && a.Price != null && a.IsDelect == true).Price), }; list.Add(mod); } goodlist = EF.Goods.Where(a => a.CategoryID == EF.GoodCategories.FirstOrDefault(b => b.ParentId == item.CategoryID).CategoryID).Take(8 - goodlist.Count).ToList(); foreach (var i in goodlist) { var mod = new HomeGoodOutput() { HardId = i.CategoryID, HardName = EF.GoodCategories.FirstOrDefault(a => a.CategoryID == i.CategoryID).CategoryName, GoodId = i.GoodId, GoodName = i.GoodName, ImgUrl = "https://localhost:44363/file/image/200/" + i.ThumbnailImg, CreateTime = i.CreateTime, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderBy(a => a.Price).FirstOrDefault(a => a.GoodId == i.GoodId && a.Price != null && a.IsDelect == true).Price), }; list.Add(mod); } homecatemod.GetHomeGood = list; homecatelist.Add(homecatemod); } return(homecatelist); }
/// 查询商品or类别 /// </summary> /// <param name="str"></param> /// <param name="page"></param> /// <param name="limte"></param> /// <returns></returns> public List <HomeGoodOutput> GetFuzzyGood(string str, int page, int limte) { var list = new List <HomeGoodOutput>(); var data = EF.Goods.ToList(); if (str == "") { foreach (var item in data) { var mod = new HomeGoodOutput() { CreateTime = item.CreateTime, GoodId = item.GoodId, GoodName = item.GoodName, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderByDescending(a => a.Price).FirstOrDefault(a => a.GoodId == a.GoodId && a.Price != 0 && a.IsDelect == true).Price), ImgUrl = "https://localhost:44363/file/image/200/" + item.ThumbnailImg, }; list.Add(mod); } return(list); } ; list = (from x in data join b in EF.GoodCategories on x.CategoryID equals b.CategoryID where b.CategoryName.Contains(str) || x.GoodName.Contains(str) && x.IsDelect == true && b.IsDelect == true select new HomeGoodOutput { CreateTime = x.CreateTime, GoodId = x.GoodId, GoodName = x.GoodName, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderByDescending(a => a.Price).FirstOrDefault(a => a.GoodId == x.GoodId && a.Price != 0 && a.IsDelect == true).Price), ImgUrl = "https://localhost:44363/file/image/200/" + x.ThumbnailImg, }).ToList(); return(list.Skip(limte * (page - 1)).Take(limte).ToList()); }
public List <HomeTopOutput> HomeTopList() { var list = new List <HomeTopOutput>(); var data1 = EF.Goods.Where(a => a.GoodName.Contains("小米") && a.CategoryID == "C1001").ToList(); var goodlist1 = new List <HomeGoodOutput>(); foreach (var item in data1) { var mod = new HomeGoodOutput() { GoodId = item.GoodId, GoodName = item.GoodName, ImgUrl = "https://localhost:44363/file/image/200/" + item.ThumbnailImg, CreateTime = item.CreateTime, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderByDescending(a => a.Price).FirstOrDefault(a => a.GoodId == item.GoodId).Price), }; goodlist1.Add(mod); } var mod1 = new HomeTopOutput() { Name = "小米手机", GetGoodList = goodlist1.OrderBy(a => a.CreateTime).ToList(), }; list.Add(mod1); var data2 = EF.Goods.Where(a => a.GoodName.Contains("Redmi") && a.CategoryID == "C1001").ToList(); var goodlist2 = new List <HomeGoodOutput>(); foreach (var item in data2) { var mod = new HomeGoodOutput() { GoodId = item.GoodId, GoodName = item.GoodName, ImgUrl = "https://localhost:44363/file/image/200/" + item.ThumbnailImg, CreateTime = item.CreateTime, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderByDescending(a => a.Price).FirstOrDefault(a => a.GoodId == item.GoodId).Price), }; goodlist2.Add(mod); } var mod2 = new HomeTopOutput() { Name = "红米手机", GetGoodList = goodlist2.OrderBy(a => a.CreateTime).ToList(), }; list.Add(mod2); var data3 = EF.Goods.Where(a => a.GoodName.Contains("电视") && a.CategoryID == "C1002").ToList(); var goodlist3 = new List <HomeGoodOutput>(); foreach (var item in data1) { var mod = new HomeGoodOutput() { GoodId = item.GoodId, GoodName = item.GoodName, ImgUrl = "https://localhost:44363/file/image/200/" + item.ThumbnailImg, CreateTime = item.CreateTime, FloorPrice = Convert.ToDecimal(EF.Good_Specifications.OrderByDescending(a => a.Price).FirstOrDefault(a => a.GoodId == item.GoodId).Price), }; goodlist3.Add(mod); } var mod3 = new HomeTopOutput() { Name = "电视", GetGoodList = goodlist3.OrderBy(a => a.CreateTime).ToList(), }; list.Add(mod3); return(list); }