public ActionResult ProTuiList() { string type = Request.QueryString["type"] == null ? "ProTuiList" : Request.QueryString["type"].ToString(); if (type == "ProTuiList" || string.IsNullOrEmpty(type) || type == "undefined") { int pagerows = 4; string where = ""; string sortby = ""; //页数 string page = Request.QueryString["page"] == null ? "1" : Request.QueryString["page"].ToString(); //推荐 string tui = Request.QueryString["tui"] == null ? "" : Request.QueryString["tui"].ToString(); //分类ID string ptid = Request.QueryString["ptype"] == null ? "" : Request.QueryString["ptype"].ToString(); //查询条件 string condition = Request.QueryString["condition"] == null ? "" : Request.QueryString["condition"].ToString(); //价格 string price = Request.QueryString["price"] == null ? "" : Request.QueryString["price"].ToString(); //品牌 string brand = Request.QueryString["brand"] == null ? "" : Request.QueryString["brand"].ToString(); //排序 string sort = Request.QueryString["sort"] == null ? "" : Request.QueryString["sort"].ToString(); //存在推荐分类 if (!string.IsNullOrEmpty(tui) && tui != "undefined") { where += " and p_ID in (select p_ID from ProductRecommendDetail where prt_ID=" + tui + " and prd_Status=0 and prd_IsDelete=0) "; } else { string strptCon = ""; if (!string.IsNullOrWhiteSpace(ptid) && ptid != "undefined") { ptid = HttpUtility.UrlDecode(ptid); var proType = new BLL.ProductTypeBase().GetModelList(" pt_IsDel = 0 and pt_StatusCode = 0 and pt_Name = '" + ptid +"'").FirstOrDefault(); if (proType != null) { strptCon = " and pt_ID=" + proType.pt_ID; } } if (!string.IsNullOrWhiteSpace(condition) && condition != "undefined") { condition = HttpUtility.UrlDecode(condition); where += " and p_ID in (select p_ID from ProductBase where p_Name like '%[" + condition + "]%' and p_SellStatus=1 and p_IsDel=0 and p_StatusCode=0 " + strptCon + ") "; } } //存在分类 if (!string.IsNullOrEmpty(ptid) && ptid != "undefined") { where += " and pt_ID=" + ptid; } //存在品牌 if (!string.IsNullOrEmpty(brand) && brand != "undefined") { where += " and b_id=" + brand; } //价格 if (!string.IsNullOrEmpty(price) && price != "undefined") { if (price == "5000以上") where += "and sku_Price>=5000" + " and p_id not in(select p_id from skubase where sku_id in(select sku_id from GroupPurchaseBase where gp_pPric<5000 and sku_ID in(select sku_ID from skubase where p_ID in( select p_ID from ProductRecommendDetail where prt_ID=1 and prd_Status=0 and prd_IsDelete=0))))"; else { string[] prilist = price.Split('-'); where += " and sku_Price>=" + prilist[0] + " and sku_Price<=" + prilist[1] + " and p_id not in(select p_id from skubase where sku_id in(select sku_id from GroupPurchaseBase where gp_pPric<" + prilist[0] + " or gp_pPric>"+prilist[1] +" and sku_ID in(select sku_ID from skubase where p_ID in( select p_ID from ProductRecommendDetail where prt_ID=1 and prd_Status=0 and prd_IsDelete=0))))"; } } //排序 if (!string.IsNullOrEmpty(sort) && sort != "undefined") { if (sort == "sku") sortby = " order by sku_ID desc"; if (sort == "xliang") sortby = " order by sku_SalesCount desc "; if (sort == "spric") sortby = " order by sku_Price desc"; if (sort == "pinglun") sortby = " order by pinglun desc"; if (sort == "selltime") sortby = " order by p_ModifyOn desc"; } var model = new ListModel(); if (!string.IsNullOrWhiteSpace(tui) && tui != "undefined") { model.blist = bbll.GetModelList(" b_IsDel=0 and b_StatusCode=0 and b_ID in(select b_ID from ProductTypeBrandBase where pt_ID in(select pt_ID from productbase where p_ID in(select p_ID from ProductRecommendDetail where prt_ID=" + tui + " and prd_IsDelete=0 and prd_Status=0)))"); model.ptlist = ptbll.GetModelList(" pt_IsDel=0 and pt_StatusCode=0 and pt_ID in(select pt_ID from productbase where p_ID in(select p_ID from ProductRecommendDetail where prt_ID=" + tui + " and prd_IsDelete=0 and prd_Status=0))"); ViewData["typename"] = new BLL.ProductRecommendTypeBase().GetModel(int.Parse(tui)).prt_Name; } else { model.blist = new List<BrandBase>(); model.ptlist = new List<ProductTypeBase>(); ViewData["typename"] = ""; } model.vmpinfolist = new BLL.vw_PInfo().GetModelList(" p_IsDel=0 and p_StatusCode=0 and p_SellStatus=1 " + where, int.Parse(page), pagerows, sortby); List<Model.vw_PInfo> list = new BLL.vw_PInfo().GetModelList(" p_IsDel=0 and p_SellStatus=1 and p_StatusCode=0 " + where); ViewData["count"] = list.Count; ViewData["pagerows"] = pagerows; ViewData["page"] = page; ViewData["pagecount"] = Math.Ceiling((double)list.Count / (double)pagerows); return View(model); } else return View(); }
private object GetProductRecommend(int id, string viewName, string ptIds = "") { BLL.ProductRecommendTypeBase proRecType = new BLL.ProductRecommendTypeBase(); var model = proRecType.GetModel(id); ViewData[viewName] = model.prt_Name; ViewData[viewName + "list"] = GetProductsList(id, ptIds); return ViewData[viewName]; }