Exemple #1
0
        public static List <RecommendProduct> QueryGroupBuyingRecommendProductList()
        {
            string cacheKey = CommonFacade.GenerateKey("QueryGroupBuyingRecommendProductList");

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return((List <RecommendProduct>)HttpRuntime.Cache[cacheKey]);
            }

            var count = 8;
            var p1    = RecommendFacade.QueryRecommendProduct(0, (int)PageType.GroupBuying, (int)RecommendPosition.GroupBuy_HotSalesProduct, count);
            //泰隆银行商品很少,可能有些分类下面就没有商品,这样补位 就会出现 有时能补上,有时补不上;这样还照常客户困惑和质疑;所有暂时去掉补位逻辑
            //if (p1.Count < count)
            //{
            //    Random rand = new Random();
            //    var allCategory = CategoryFacade.QueryCategoryInfosForHomePage();
            //    var c1SysNoList = allCategory.FindAll(x => x.CategoryType == CategoryType.TabStore).Select(x => x.CategoryID).ToList();
            //    int c1SysNo = c1SysNoList[rand.Next(0, c1SysNoList.Count)];
            //    var p2 = RecommendDA.QueryHotProductForC1(c1SysNo, ConstValue.LanguageCode, ConstValue.CompanyCode);
            //    p2.ForEach(p =>
            //    {
            //        if (p1.All(f => f.SysNo != p.SysNo))
            //        {
            //            p1.Add(p);
            //        }
            //    });
            //}
            List <RecommendProduct> result = p1.Take(count).ToList();

            HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration);

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 购物车热卖推荐(推荐位补位)
        /// </summary>
        /// <returns></returns>
        public static List <RecommendProduct> QueryShoppingCartList()
        {
            string cacheKey = CommonFacade.GenerateKey("QueryShoppingCartList");

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return((List <RecommendProduct>)HttpRuntime.Cache[cacheKey]);
            }

            var count = 4;
            var p1    = RecommendFacade.QueryRecommendProduct(0, (int)PageType.ShoppingCart, 5001, count);

            if (p1.Count < count)
            {
                var p2 = RecommendDA.QueryNewProduct(ConstValue.LanguageCode, ConstValue.CompanyCode);
                p2.ForEach(p =>
                {
                    if (p1.All(f => f.SysNo != p.SysNo))
                    {
                        p1.Add(p);
                    }
                });
            }
            List <RecommendProduct> result = p1.Take(count).ToList();

            HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration);

            return(result);
        }