Ejemplo n.º 1
0
        public static PageModel <StoreEntity> GetStoreRecommend(StoreEntityQuery query)
        {
            PageModel <StoreEntity> pageModel = new PageModel <StoreEntity>();

            if (query.Position.Latitude == 0.0 || query.Position.Longitude == 0.0)
            {
                return(pageModel);
            }
            StoreProductDao storeProductDao = new StoreProductDao();
            DbQueryResult   storeRecommend  = storeProductDao.GetStoreRecommend(query);
            DataTable       data            = storeRecommend.Data;

            pageModel.Total = storeRecommend.TotalRecords;
            string                      tempAllRegions = default(string);
            string                      storeIds       = default(string);
            List <StoreEntity>          list           = StoreListHelper.AdapterDs2Store(data, out tempAllRegions, out storeIds);
            Dictionary <string, string> regionDic      = RegionHelper.GetRegionName(tempAllRegions);
            Dictionary <int, List <StoreProductEntity> > pdRecommDic = StoreListHelper.GetStoreProductRecommend(storeIds, query.ProductType);
            MemberInfo memberInfo = null;
            int        gradeId    = 0;

            if (HiContext.Current != null && HiContext.Current.UserId > 0)
            {
                memberInfo = HiContext.Current.User;
            }
            if (memberInfo != null)
            {
                gradeId = memberInfo.GradeId;
            }
            Dictionary <int, List <StoreActivityEntity> > activitityDic = PromoteHelper.GetStoreActivityEntity(storeIds, gradeId);

            list.ForEach(delegate(StoreEntity item)
            {
                item.AddressSimply = StoreListHelper.ProcessAddress(regionDic, item.FullRegionPath, item.Address);
                item.ProductList   = (pdRecommDic.ContainsKey(item.StoreId) ? pdRecommDic[item.StoreId] : new List <StoreProductEntity>());
                item.Activity      = PromoteHelper.ProcessActivity(activitityDic, item.StoreId);
                item.StoreImages   = Globals.FullPath(item.StoreImages.Split(',')[0]);
            });
            pageModel.Models = list;
            return(pageModel);
        }