/// <summary> /// (已缓存)查询最近7天下单最多的前5个商品 /// </summary> /// <param name="c3SysNo">前台三级类别sysno</param> /// <param name="languageCode"></param> /// <param name="companyCode"></param> /// <returns></returns> public static List <RecommendProduct> QueryWeekRankingForC3(int c3SysNo, string languageCode = "zh-CN", string companyCode = "8601") { string cacheKey = CommonFacade.GenerateKey("QueryWeekRankingForC3", c3SysNo.ToString(), languageCode, companyCode); if (HttpRuntime.Cache[cacheKey] != null) { return((List <RecommendProduct>)HttpRuntime.Cache[cacheKey]); } const int count = 8; var p1 = CategoryDA.QueryWeekRankingForC3(Convert.ToInt32(c3SysNo)); if (p1.Count < 8) { var p2 = RecommendDA.QuerySuperSpecialProductForC3(Convert.ToInt32(c3SysNo), 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); }
/// <summary> /// 一级类别新品上架 /// </summary> /// <param name="c1SysNo">前台一级类别</param> /// <param name="languageCode"></param> /// <param name="companyCode"></param> /// <returns></returns> public static List <RecommendProduct> QueryNewProductForC1(int c1SysNo, string languageCode = "zh-CN", string companyCode = "8601") { string cacheKey = CommonFacade.GenerateKey("QueryNewProductForC1", 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_NewProduct, count, languageCode, companyCode); if (p1.Count < count) { var p2 = RecommendDA.QueryNewProductForC1(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); }
/// <summary> /// 获取首页所有相关Banner /// </summary> /// <returns></returns> public static HomBannersVM GetHomeBanners(int sliderCount = 5, int middleItemCount = 5, int bottomItemCount = 5) { PageType pageType = PageType.Home; int pageID = 0; string cacheKey = CommonFacade.GenerateKey("GetBannerInfoOfHome", pageType.ToString(), pageID.ToString()); if (HttpRuntime.Cache[cacheKey] != null) { return((HomBannersVM)HttpRuntime.Cache[cacheKey]); } List <BannerInfo> bannerInfoList = RecommendDA.GetBannerInfoByPositionID(pageID, pageType, null); HomBannersVM result = new HomBannersVM(); //首页轮播广告 result.Sliders = bannerInfoList.Where(item => item.PositionID == BannerPosition.HomePage_Top_Slider).Take(sliderCount).ToList(); //新闻公告下部 result.UnderNews = bannerInfoList.FirstOrDefault(item => item.PositionID == BannerPosition.HomePage_UnderNews); //首页底部精选品牌 result.Bottom = bannerInfoList.Where(item => item.PositionID == BannerPosition.HomePage_Bottom).Take(bottomItemCount).ToList(); HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(result); }
/// <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); }
/// <summary> /// 获取推荐品牌 /// </summary> /// <returns></returns> public static List <RecommendBrandInfo> GetRecommendBrands(PageType pageType, int pageID) { string cacheKey = CommonFacade.GenerateKey("GetRecommendBrands", pageType.ToString(), pageID.ToString()); if (HttpRuntime.Cache[cacheKey] != null) { return((List <RecommendBrandInfo>)HttpRuntime.Cache[cacheKey]); } List <RecommendBrandInfo> result = RecommendDA.GetRecommendBrands(pageType, pageID); HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(result); }
public static List <BannerInfo> GetBannerInfoByPositionID(int pageID, PageType pageType, BannerPosition positionID) { string cacheKey = CommonFacade.GenerateKey("GetBannerInfoByPositionID", pageType.ToString(), pageID.ToString(), positionID.ToString()); if (HttpRuntime.Cache[cacheKey] != null) { return((List <BannerInfo>)HttpRuntime.Cache[cacheKey]); } List <BannerInfo> bannerInfoList = RecommendDA.GetBannerInfoByPositionID(pageID, pageType, positionID); HttpRuntime.Cache.Insert(cacheKey, bannerInfoList, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(bannerInfoList); }
public static List <RecommendProduct> QueryWeeklyHotProduct(string languageCode = "zh-CN", string companyCode = "8601") { string cacheKey = CommonFacade.GenerateKey("QueryWeeklyHotProduct"); if (HttpRuntime.Cache[cacheKey] != null) { return((List <RecommendProduct>)HttpRuntime.Cache[cacheKey]); } var result = RecommendDA.QueryWeeklyHotProduct(languageCode, companyCode); HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(result); }
/// <summary> /// 获取推荐商品 /// </summary> /// <param name="pageID">类别sysno/其他sysno</param> /// <param name="pageType">页面类型,如:一级类别页面,二级类别页等</param> /// <param name="posID">页面位置</param> /// <param name="count">数量</param> /// <param name="languageCode"></param> /// <param name="companyCode"></param> /// <returns></returns> public static List <RecommendProduct> QueryRecommendProduct(int pageID, int pageType, int posID, int count, string languageCode = "zh-CN", string companyCode = "8601") { string cacheKey = CommonFacade.GenerateKey("QueryRecommendProduct", pageType.ToString(), pageID.ToString() , posID.ToString(), count.ToString(), languageCode, companyCode); if (HttpRuntime.Cache[cacheKey] != null) { return((List <RecommendProduct>)HttpRuntime.Cache[cacheKey]); } List <RecommendProduct> result = RecommendDA.QueryRecommendProduct(pageID, pageType, posID, count, languageCode, companyCode); HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(result); }
/// <summary> /// 获取楼层信息 /// </summary> /// <param name="pageCode"></param> /// <returns></returns> public static List <FloorEntity> GetFloorInfo(PageCodeType pageType, int pageCode) { string cacheKey = CommonFacade.GenerateKey("GetFloorInfo", pageType.ToString(), pageCode.ToString()); if (HttpRuntime.Cache[cacheKey] != null) { return((List <FloorEntity>)HttpRuntime.Cache[cacheKey]); } #region 获取信息 //获取基本信息 List <FloorEntity> floorEntitys = RecommendDA.GetFloorInfo(pageType, pageCode); //获取 Tab 信息 foreach (FloorEntity entity in floorEntitys) { //获取 Tab 信息 entity.FloorSections = RecommendDA.GetFloorSections(entity.FloorSysNo); List <FloorItemBase> originalItem = RecommendDA.GetFloorSectionItems(entity.FloorSysNo); entity.FloorSectionItems = new List <FloorItemBase>(); //转换XML信息 to 实体 foreach (FloorItemBase item in originalItem) { FloorItemBase objItem = null; switch (item.ItemType) { case FloorItemType.Product: FloorItemProduct entityProduct = CreateObject <FloorItemProduct>(item.ItemValue); ProductItemInfo productInfo = ProductFacade.GetProductShortInfoBySysNo(entityProduct.ProductSysNo); if (productInfo != null && productInfo.Status == 1) { entityProduct.DefaultImage = productInfo.DefaultImage; entityProduct.RealPrice = productInfo.RealPrice; entityProduct.BasicPrice = productInfo.MarketPrice; entityProduct.ProductPrice = productInfo.CurrentPrice; entityProduct.PromotionTitle = productInfo.PromotionTitle; entityProduct.ProductSubTitle = productInfo.PromotionTitle; entityProduct.CashRebate = productInfo.CashRebate; entityProduct.ProductTitle = productInfo.ProductTitle; objItem = entityProduct; } break; case FloorItemType.Banner: objItem = CreateObject <FloorItemBanner>(item.ItemValue); break; case FloorItemType.Brand: objItem = CreateObject <FloorItemBrand>(item.ItemValue); break; case FloorItemType.TextLink: objItem = CreateObject <FloorItemTextLink>(item.ItemValue); break; } if (objItem != null) { objItem.CloneFloorItemBase(item); entity.FloorSectionItems.Add(objItem); } } } #endregion HttpRuntime.Cache.Insert(cacheKey, floorEntitys, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(floorEntitys); }