예제 #1
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));
        }
예제 #2
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));
        }