public ActionResult AppReCommendProduct(int pageIndex = 1, int pageSize = 10) { Parameters param = CreateParam(pageIndex, pageSize); if (Request.QueryString["IsCheckProduct"] != null && Request.QueryString["IsCheckProduct"] == "1")//剔除下架商品 { } SearchSortService dal = new SearchSortService(); XMLReturnClassLists model = dal.GetLists(param);//接口查询 商品列表 ViewBag.pageIndex = pageIndex; ViewBag.pageSize = pageSize; return(View(model)); }
public ActionResult ProductList(int pageIndex = 1, int pageSize = 10) { Parameters param = CreateParam(pageIndex, pageSize); if (Request.QueryString["IsRecord"] != null && Request.QueryString["IsRecord"] == "1")//说明是查询并保存 { SWfsSortHistoryService sshsDal = new SWfsSortHistoryService(); Passport passport = PresentationHelper.GetPassport(); if (passport != null && !string.IsNullOrEmpty(passport.UserName)) { string thisUrl = Request.Url.ToString().Replace("http://" + Request.Url.Host, "").Replace("IsRecord", "IsRecoaddrd"); if (!string.IsNullOrEmpty(Request.QueryString["ProductName"]) && Request.QueryString["ProductName"] != "") { string ProductName = Server.UrlDecode(Request.QueryString["ProductName"]); ProductName = ProductName.Replace(" ", "+"); thisUrl = thisUrl.Replace(ProductName, Server.UrlEncode(Request.QueryString["ProductName"])); } sshsDal.InsertHistory(param, thisUrl, passport.UserName); return(Redirect(thisUrl)); } } SearchSortService dal = new SearchSortService(); XMLReturnClassLists model = dal.GetLists(param);//接口查询 商品列表 //按品牌编号查询修改热度的商品列表 if (model.ListProducts.Count() > 0) { IEnumerable <ProductHot> hotProductList = dal.GetProductListByProductNoList(model.ListProducts.Select(p => p.ProductNo)); for (int i = 0; i < model.ListProducts.Count; i++) { if (hotProductList.Count(p => p.ProductNo == model.ListProducts[i].ProductNo) > 0) { model.ListProducts[i].EditeHot = model.ListProducts[i].Hot + hotProductList.Where(p => p.ProductNo == model.ListProducts[i].ProductNo).ElementAt(0).ProductHotValue; model.ListProducts[i].EditeSevenHot = model.ListProducts[i].SevenHot + hotProductList.Where(p => p.ProductNo == model.ListProducts[i].ProductNo).ElementAt(0).ProductSevenHotValue; } else { model.ListProducts[i].EditeHot = model.ListProducts[i].Hot; model.ListProducts[i].EditeSevenHot = model.ListProducts[i].SevenHot; } } } ProductSortService tian = new ProductSortService(); string categoryNo = string.Empty; if (!string.IsNullOrEmpty(param.categoryNO)) { categoryNo = param.categoryNO; } else { categoryNo = param.brandNO; } IEnumerable <SWfsSortProduct> saveProductList = tian.GetSortProductList(categoryNo); if (saveProductList.Count() > 0) { for (int i = 0; i < model.ListProducts.Count; i++)//对比商品是否已经加入排序池 { if (saveProductList.Count(q => q.ProductNo == model.ListProducts.ElementAt(i).ProductNo) > 0) { model.ListProducts.ElementAt(i).IsSelected = 1; } } } List <SearchResultCategorys> result = new List <SearchResultCategorys>(); //分类递归 if (!string.IsNullOrEmpty(Request.QueryString["categoryNO"]) && Request.QueryString["categoryNO"].Length >= 3) { List <SearchResultCategorys> first = model.ListCategorys.Where(p => p.CategoryNo.Contains(Request.QueryString["categoryNO"]) && p.CategoryNo.Length == (Request.QueryString["categoryNO"].Length + 3)).ToList(); List <SearchResultCategorys> second; List <SearchResultCategorys> third; for (int i = 0; i < first.Count; i++) { result.Add(first[i]); second = model.ListCategorys.Where(p => p.PrentNo == first[i].CategoryNo).ToList(); for (int j = 0; j < second.Count; j++) { second[j].CateGoryName = "|-" + second[j].CateGoryName; result.Add(second[j]); third = model.ListCategorys.Where(p => p.PrentNo == second[j].CategoryNo).ToList(); for (int k = 0; k < third.Count; k++) { third[k].CateGoryName = "|-|-" + third[k].CateGoryName; result.Add(third[k]); } } } first = null; second = null; third = null; } else { List <SearchResultCategorys> first = model.ListCategorys.Where(p => p.CateGoryLevel == 2).ToList(); List <SearchResultCategorys> second; List <SearchResultCategorys> third; for (int i = 0; i < first.Count; i++) { result.Add(first[i]); second = model.ListCategorys.Where(p => p.PrentNo == first[i].CategoryNo).ToList(); for (int j = 0; j < second.Count; j++) { second[j].CateGoryName = "|-" + second[j].CateGoryName; result.Add(second[j]); third = model.ListCategorys.Where(p => p.PrentNo == second[j].CategoryNo).ToList(); for (int k = 0; k < third.Count; k++) { third[k].CateGoryName = "|-|-" + third[k].CateGoryName; result.Add(third[k]); } } } first = null; second = null; third = null; } model.ListCategorys = result; model.SaveProductCount = saveProductList.Count(); SWfsSortHistoryService HistoryDal = new SWfsSortHistoryService(); IList <SWfsSortHistory> listHistory = HistoryDal.SelectHistory(); ViewBag.listHistory = listHistory; return(View(model)); }