Пример #1
0
        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));
        }
Пример #2
0
        public ActionResult AppRecommendProductList()
        {
            XMLReturnClassLists             result          = new XMLReturnClassLists();
            Parameters                      param           = new Parameters();
            AppRecommendService             zhao            = new AppRecommendService();
            List <AppRecommendProductModle> saveProductList = zhao.GetAppRecommendProductList();

            for (int i = 0; i < saveProductList.Count; i = i + 10)
            {
                string productNoStr = "";
                for (int j = 0; j < 10; j++)
                {
                    if (i + j < saveProductList.Count)
                    {
                        productNoStr = productNoStr + saveProductList[i + j].ProductNo + ",";
                    }
                }

                if (productNoStr != "")
                {
                    productNoStr.TrimEnd(',');
                }
                param.productNO = productNoStr;
                XMLReturnClassLists model = zhao.GetLists(param);//接口查询 商品列表
                foreach (InterfaceProductInfo item in model.ListProducts)
                {
                    if (item.stock == 0)
                    {
                        zhao.DelAppRecommendProductById(item.ProductNo);
                    }
                    else
                    {
                        result.ListProducts.Add(item);
                    }
                }

                for (int j = 0; j < productNoStr.Split(',').Length; j++)
                {
                    if (model.ListProducts.Where(p => p.ProductNo == productNoStr.Split(',')[j]).Count() == 0)
                    {
                        zhao.DelAppRecommendProductById(productNoStr.Split(',')[j]);
                    }
                }
            }

            return(View(result));
        }
Пример #3
0
        public ActionResult Index(int pageIndex = 1, int pageSize = 10)
        {
            Parameters param = CreateParam(pageIndex, pageSize);

            AppRecommendService dal   = new AppRecommendService();
            XMLReturnClassLists model = dal.GetLists(param);//接口查询 商品列表

            AppRecommendService zhao = new AppRecommendService();
            string categoryNo        = string.Empty;

            if (!string.IsNullOrEmpty(param.categoryNO))
            {
                categoryNo = param.categoryNO;
            }
            else
            {
                categoryNo = param.brandNO;
            }
            List <AppRecommendProductModle> saveProductList = zhao.GetAppRecommendProductList();

            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)
                    {
                        //库存为零时删除
                        //if (model.ListProducts.Where(p => p.ProductNo == saveProductList[i].ProductNo && p.stock < 1).Count() > 0)
                        //{
                        //    zhao.DelAppRecommendProductById(saveProductList[i].Id);
                        //}
                        model.ListProducts.ElementAt(i).IsSelected = 1;
                    }
                }
            }
            List <SearchResultCategorys> result = new List <SearchResultCategorys>();

            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();

            return(View(model));
        }
Пример #4
0
        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));
        }
Пример #5
0
        /// <summary>
        /// 解析xml
        /// </summary>
        /// <param name="xmlStr"></param>
        /// <param name="docCount">返回总条数</param>
        /// <returns>返回所有集合对象</returns>
        private XMLReturnClassLists XmlParsing(string xmlStr)
        {
            XMLReturnClassLists xmlclass = new XMLReturnClassLists();
            XmlDocument         xmlDoc   = new XmlDocument();

            xmlDoc.InnerXml = xmlStr;
            int Status = int.Parse(xmlDoc.SelectSingleNode("/result/Total").InnerText);//获取总查询条数

            xmlclass.docCount = Status;
            if (Status == 0)//没有查询到数据
            {
                return(xmlclass);
            }
            List <SearchResultBrands>    listBrand    = new List <SearchResultBrands>();
            List <SearchResultCategorys> listCategory = new List <SearchResultCategorys>();
            List <ProductPrimaryColors>  listColor    = new List <ProductPrimaryColors>();
            List <InterfaceProductInfo>  listprod     = new List <InterfaceProductInfo>();
            XmlNodeList docs_nodeList = xmlDoc.SelectNodes("/result/docs/doc");

            foreach (XmlNode item_doc in docs_nodeList)
            {
                InterfaceProductInfo prod = new InterfaceProductInfo();
                foreach (XmlNode item_field in item_doc.ChildNodes)
                {
                    switch (item_field.Attributes["name"].Value)
                    {
                    case "ProductNo":
                        prod.ProductNo = item_field.InnerText;
                        break;

                    case "ProductName":
                        prod.ProductName = item_field.InnerText;
                        break;

                    case "MarketPrice":
                        prod.MarketPrice = decimal.Parse(string.IsNullOrEmpty(item_field.InnerText)?"0":item_field.InnerText);
                        break;

                    case "LimitedPrice":
                        prod.LimitedPrice = decimal.Parse(string.IsNullOrEmpty(item_field.InnerText) ? "0" : item_field.InnerText);
                        break;

                    case "PromotionPrice":
                        prod.PromotionPrice = decimal.Parse(string.IsNullOrEmpty(item_field.InnerText)?"0":item_field.InnerText);
                        break;

                    case "ProductPicFile":
                        prod.ProductPicFile = item_field.InnerText;
                        break;

                    case "GoodsNo":
                        prod.GoodsNo = item_field.InnerText;
                        break;

                    case "DiscountRate":
                        prod.DiscountRate = item_field.InnerText;
                        break;

                    case "BrandNo":
                        prod.BrandNo = item_field.InnerText;
                        break;

                    case "BrandCnName":
                        if (item_field.InnerText != null && item_field.InnerText != "")
                        {
                            prod.BrandCnName = item_field.InnerText;
                        }
                        break;

                    case "BrandEnName":
                        prod.BrandEnName = item_field.InnerText;
                        break;

                    case "DateShelf":
                        prod.DateShelf = item_field.InnerText;
                        break;

                    case "Stock":
                        prod.stock = int.Parse(item_field.InnerText);
                        break;

                    case "Hot":
                        prod.Hot = int.Parse(!string.IsNullOrEmpty(item_field.InnerText)?item_field.InnerText:"0");
                        break;

                    case "SevenHot":
                        prod.SevenHot = int.Parse(!string.IsNullOrEmpty(item_field.InnerText)?item_field.InnerText:"0");
                        break;

                    case "Category":
                        for (int i = 0; i < item_field.ChildNodes.Count; i++)
                        {
                            if (i == item_field.ChildNodes.Count - 1)
                            {
                                prod.Category = item_field.ChildNodes[i].InnerText.Split('|')[1];
                            }
                            else
                            {
                                prod.Category = item_field.ChildNodes[i].InnerText.Split('|')[1] + "|";
                            }
                        }
                        break;

                    case "ProductPrimaryColor":
                        for (int i = 0; i < item_field.ChildNodes.Count; i++)
                        {
                            if (i == item_field.ChildNodes.Count - 1)
                            {
                                prod.ProductPrimaryColor     = prod.ProductPrimaryColor + item_field.ChildNodes[i].InnerText.Split('|')[0];
                                prod.ProductPrimaryColorName = prod.ProductPrimaryColorName + item_field.ChildNodes[i].InnerText.Split('|')[1];
                            }
                            else
                            {
                                prod.ProductPrimaryColor     = prod.ProductPrimaryColor + item_field.ChildNodes[i].InnerText.Split('|')[0] + "|";
                                prod.ProductPrimaryColorName = prod.ProductPrimaryColorName + item_field.ChildNodes[i].InnerText.Split('|')[1] + "|";
                            }
                        }
                        break;
                    }
                }
                listprod.Add(prod);
            }

            XmlNodeList facets_nodeList = xmlDoc.SelectNodes("/result/facets");

            if (facets_nodeList != null && facets_nodeList.Count > 0)
            {
                foreach (XmlNode item_facets in facets_nodeList)
                {
                    foreach (XmlNode fList in item_facets.ChildNodes)   //节点facet
                    {
                        if (fList.Attributes["name"].Value == "Brand")  //取name=brand的子节点
                        {
                            XmlNodeList brandsXMl   = fList.ChildNodes; //获取item节点
                            string      brandString = "";
                            string[]    attribute   = null;
                            foreach (XmlNode item_brand in brandsXMl)
                            {
                                SearchResultBrands brand = new SearchResultBrands();
                                brandString        = item_brand.Attributes["name"].Value;
                                brand.ProductCount = int.Parse(item_brand.InnerText);
                                attribute          = brandString.Split('|');
                                brand.BrandNO      = attribute[0];
                                brand.BrandEnName  = attribute[1];
                                brand.BrandChName  = attribute[2];
                                listBrand.Add(brand);
                            }
                        }
                        if (fList.Attributes["name"].Value == "ProductPrimaryColors")
                        {
                            XmlNodeList ColorsXMl   = fList.ChildNodes;//获取item节点
                            string      colorString = "";
                            string[]    attribute   = null;
                            foreach (XmlNode item_color in ColorsXMl)
                            {
                                ProductPrimaryColors color = new ProductPrimaryColors();
                                colorString             = item_color.Attributes["name"].Value;
                                color.ColorProductCount = int.Parse(item_color.InnerText);
                                attribute          = colorString.Split('|');
                                color.ColorNO      = attribute[0];
                                color.ColorName    = attribute[1];
                                color.ColorPicFile = attribute[2];
                                listColor.Add(color);
                            }
                        }
                        if (fList.Attributes["name"].Value == "CLv2")      //二级分类
                        {
                            XmlNodeList CategoryXMl    = fList.ChildNodes; //获取item节点
                            string      categoryString = "";
                            string[]    attribute      = null;
                            foreach (XmlNode item_category in CategoryXMl)
                            {
                                SearchResultCategorys cagegory = new SearchResultCategorys();
                                categoryString = item_category.Attributes["name"].Value;
                                cagegory.CategoryProductCount = int.Parse(item_category.InnerText);
                                attribute              = categoryString.Split('|');
                                cagegory.CategoryNo    = attribute[0];
                                cagegory.CateGoryName  = attribute[1];
                                cagegory.PrentNo       = attribute[2];
                                cagegory.State         = int.Parse(attribute[3]);
                                cagegory.CategorySort  = int.Parse(attribute[4]);
                                cagegory.CateGoryLevel = 2;
                                listCategory.Add(cagegory);
                            }
                        }
                        if (fList.Attributes["name"].Value == "CLv3")      //二级分类
                        {
                            XmlNodeList CategoryXMl    = fList.ChildNodes; //获取item节点
                            string      categoryString = "";
                            string[]    attribute      = null;
                            foreach (XmlNode item_category in CategoryXMl)
                            {
                                SearchResultCategorys cagegory = new SearchResultCategorys();
                                categoryString = item_category.Attributes["name"].Value;
                                cagegory.CategoryProductCount = int.Parse(item_category.InnerText);
                                attribute              = categoryString.Split('|');
                                cagegory.CategoryNo    = attribute[0];
                                cagegory.CateGoryName  = attribute[1];
                                cagegory.PrentNo       = attribute[2];
                                cagegory.State         = int.Parse(attribute[3]);
                                cagegory.CategorySort  = int.Parse(attribute[4]);
                                cagegory.CateGoryLevel = 3;
                                listCategory.Add(cagegory);
                            }
                        }
                        if (fList.Attributes["name"].Value == "CLv4")      //二级分类
                        {
                            XmlNodeList CategoryXMl    = fList.ChildNodes; //获取item节点
                            string      categoryString = "";
                            string[]    attribute      = null;
                            foreach (XmlNode item_category in CategoryXMl)
                            {
                                SearchResultCategorys cagegory = new SearchResultCategorys();
                                categoryString = item_category.Attributes["name"].Value;
                                cagegory.CategoryProductCount = int.Parse(item_category.InnerText);
                                attribute              = categoryString.Split('|');
                                cagegory.CategoryNo    = attribute[0];
                                cagegory.CateGoryName  = attribute[1];
                                cagegory.PrentNo       = attribute[2];
                                cagegory.State         = int.Parse(attribute[3]);
                                cagegory.CategorySort  = int.Parse(attribute[4]);
                                cagegory.CateGoryLevel = 4;
                                listCategory.Add(cagegory);
                            }
                        }
                    }
                }
            }

            xmlclass.ListBrands    = listBrand.OrderBy(p => p.BrandEnName).ToList();
            xmlclass.ListCategorys = listCategory;
            xmlclass.ListProducts  = listprod;
            xmlclass.ListColors    = listColor;
            return(xmlclass);
        }