//把商品加入推荐池 public ActionResult AddProductToAppRecommondAjax() { string productNO = Request.Form["productNo"]; if (string.IsNullOrEmpty(productNO)) { TempData["tip"] = "<script>alert('添加失败')</script>"; return(Redirect("/Shangpin/AppRecommendProductManger/Index?categoryNO=" + Request.QueryString["categoryNO"] + "&ProductNo=" + Request.QueryString["ProductNo"] + "&ProductName=" + Request.QueryString["ProductName"] + "&brandNO=" + Request.QueryString["brandNO"] + "&colorId=" + Request.QueryString["colorId"] + "&shelfType=" + Request.QueryString["shelfType"] + "&ShelfDate=" + Request.QueryString["ShelfDate"] + "&MinPrice=" + Request.QueryString["MinPrice"] + "&MaxPrice=" + Request.QueryString["MaxPrice"] + "&MinStock=" + Request.QueryString["MinStock"] + "&MaxStock=" + Request.QueryString["MaxStock"] + "&MinDiscountRate=" + Request.QueryString["MinDiscountRate"] + "&MaxDiscountRate=" + Request.QueryString["MaxDiscountRate"] + "&hot=" + Request.QueryString["hot"] + "&sevenHot=" + Request.QueryString["sevenHot"])); } SWfsSortHistoryService sshsDal = new SWfsSortHistoryService(); Passport passport = PresentationHelper.GetPassport(); AppRecommendService zhao = new AppRecommendService(); List <AppRecommendProductModle> saveProductList = zhao.GetAppRecommendProductList(); if ((saveProductList.Count + productNO.Split(',').Length) > 50) { int remoteIndex = 0; remoteIndex = (saveProductList.Count + productNO.Split(',').Length) - 50; for (int i = 0; i < saveProductList.Count; i++) { if (i < remoteIndex) { zhao.DelAppRecommendProductById(saveProductList[i].ProductNo); } } } int result = 0; for (int i = 0; i < productNO.Split(',').Length; i++) { AppRecommendProductModle DTO = new AppRecommendProductModle() { ProductNo = productNO.Split(',')[i], Creator = passport.UserName }; result = zhao.AddAppRecommendProduct(DTO); } sshsDal = null; TempData["tip"] = "<script>alert('添加成功')</script>"; return(Redirect("/Shangpin/AppRecommendProductManger/Index?categoryNO=" + Request.QueryString["categoryNO"] + "&ProductNo=" + Request.QueryString["ProductNo"] + "&ProductName=" + Request.QueryString["ProductName"] + "&brandNO=" + Request.QueryString["brandNO"] + "&colorId=" + Request.QueryString["colorId"] + "&shelfType=" + Request.QueryString["shelfType"] + "&ShelfDate=" + Request.QueryString["ShelfDate"] + "&MinPrice=" + Request.QueryString["MinPrice"] + "&MaxPrice=" + Request.QueryString["MaxPrice"] + "&MinStock=" + Request.QueryString["MinStock"] + "&MaxStock=" + Request.QueryString["MaxStock"] + "&MinDiscountRate=" + Request.QueryString["MinDiscountRate"] + "&MaxDiscountRate=" + Request.QueryString["MaxDiscountRate"] + "&hot=" + Request.QueryString["hot"] + "&sevenHot=" + Request.QueryString["sevenHot"])); }
public ActionResult TopShopProductList(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(); //param.brandNO = "B1885"; XMLReturnClassLists model = dal.GetTopShopLists(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)); }