Exemplo n.º 1
0
        /// <summary>
        /// (已缓存)查询最近7天下单最多的前5个商品
        /// </summary>
        /// <param name="c1SysNo">前台一级类别sysno</param>
        /// <param name="languageCode"></param>
        /// <param name="companyCode"></param>
        /// <returns></returns>
        public static List <RecommendProduct> QueryWeekRankingForC1(string c1SysNo, string languageCode = "zh-CN", string companyCode = "8601")
        {
            string cacheKey = CommonFacade.GenerateKey("QueryWeekRankingForC1", c1SysNo.ToString(), languageCode, companyCode);

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

            const int count = 8;
            var       p1    = CategoryDA.QueryWeekRankingForC1(Convert.ToInt32(c1SysNo));

            if (p1.Count < 8)
            {
                var p2 = RecommendDA.QuerySuperSpecialProductForC1(Convert.ToInt32(c1SysNo), languageCode, 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 一级类别超级特惠(推荐位补位)
        /// </summary>
        /// <param name="c1SysNo">前台一级类别</param>
        /// <param name="languageCode"></param>
        /// <param name="companyCode"></param>
        /// <returns></returns>
        public static List <RecommendProduct> QuerySuperSpecialProductForC1(int c1SysNo, string languageCode = "zh-CN",
                                                                            string companyCode = "8601")
        {
            string cacheKey = CommonFacade.GenerateKey("QuerySuperSpecialProductForC1", c1SysNo.ToString(), languageCode, companyCode);

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

            var count = 4;
            var p1    = QueryRecommendProduct(c1SysNo, (int)PageType.TabStore,
                                              (int)RecommendPosition.TabStore_SuperSpecial, count, languageCode, companyCode);

            if (p1.Count < count)
            {
                var p2 = RecommendDA.QuerySuperSpecialProductForC1(c1SysNo, languageCode, 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);
        }