Exemple #1
0
        public IEnumerable <VShopInfo> GetHotShop(VshopQuery vshopQuery, DateTime?startTime, DateTime?endTime, out int total)
        {
            IQueryable <VShopInfo> vShopInfo =
                from v in this.context.VShopInfo
                where v.VShopExtendInfo.Count > 0 && v.VShopExtendInfo.Any((VShopExtendInfo p) => (int)p.Type == 2)
                select v;

            if (!string.IsNullOrEmpty(vshopQuery.Name))
            {
                vShopInfo =
                    from a in vShopInfo
                    where a.Name.Contains(vshopQuery.Name)
                    select a;
            }
            if (startTime.HasValue && endTime.HasValue)
            {
                vShopInfo =
                    from a in vShopInfo
                    where a.VShopExtendInfo.Any((VShopExtendInfo item) => item.AddTime >= startTime && item.AddTime <= endTime)
                    select a;
            }
            total = vShopInfo.Count();
            return((
                       from a in vShopInfo
                       orderby a.CreateTime
                       select a).Skip((vshopQuery.PageNo - 1) * vshopQuery.PageSize).Take(vshopQuery.PageSize));
        }
Exemple #2
0
        public List <VShopInfo> GetHotShop(VshopQuery vshopQuery, DateTime?startTime, DateTime?endTime, out int total)
        {
            var vshops = DbFactory.Default
                         .Get <VShopInfo>()
                         .Where(e => e.State != VShopInfo.VShopStates.Close)
                         .InnerJoin <VShopExtendInfo>((vsi, vsei) => vsi.Id == vsei.VShopId && vsi.IsOpen == true)
                         .Where <VShopExtendInfo>(n => n.Type == VShopExtendInfo.VShopExtendType.HotVShop)
                         .OrderByDescending <VShopExtendInfo>(n => n.AddTime);

            if (!string.IsNullOrEmpty(vshopQuery.Name))
            {
                vshops.Where(a => a.Name.Contains(vshopQuery.Name));
            }
            if (startTime.HasValue)
            {
                vshops.Where <VShopExtendInfo>(item => item.AddTime >= startTime);
            }
            if (endTime.HasValue)
            {
                var end = endTime.Value.Date.AddDays(1);
                vshops.Where <VShopExtendInfo>(item => item.AddTime < end);
            }
            var rets = vshops.ToPagedList(vshopQuery.PageNo, vshopQuery.PageSize);

            total = rets.TotalRecordCount;
            return(rets);
        }
Exemple #3
0
        public IEnumerable <VShopInfo> GetVShopByParamete(VshopQuery vshopQuery, out int total)
        {
            IEnumerable <VShopInfo> allVshop = this.GetAllVshop();

            if (vshopQuery.VshopType.HasValue)
            {
                VShopExtendInfo.VShopExtendType?vshopType = vshopQuery.VshopType;
                allVshop = ((vshopType.GetValueOrDefault() != 0 ? false : vshopType.HasValue) ?
                            from a in this.context.VShopInfo
                            where a.VShopExtendInfo.Count() == 0
                            select a :
                            from a in this.context.VShopInfo
                            where a.VShopExtendInfo.Where((VShopExtendInfo b) => (int?)b.Type == (int?)vshopQuery.VshopType).Select <VShopExtendInfo, long>((VShopExtendInfo b) => b.VShopId).Contains <long>(a.Id)
                            select a);
            }
            if (!string.IsNullOrEmpty(vshopQuery.Name))
            {
                allVshop =
                    from a in allVshop
                    where a.Name.Contains(vshopQuery.Name)
                    select a;
            }
            allVshop =
                from e in allVshop
                where e.State == VShopInfo.VshopStates.Normal
                select e;

            total = allVshop.Count();
            return((
                       from a in allVshop
                       orderby a.CreateTime
                       select a).Skip((vshopQuery.PageNo - 1) * vshopQuery.PageSize).Take(vshopQuery.PageSize));
        }
Exemple #4
0
        public JsonResult GetHotShop(int page, int rows, string vshopName, DateTime?startTime = null, DateTime?endTime = null)
        {
            int        total;
            VshopQuery vshopQuery = new VshopQuery()
            {
                PageNo   = page,
                PageSize = rows,
                Name     = vshopName
            };
            var vshops = _iVShopService.GetHotShop(vshopQuery, startTime, endTime, out total).ToList();

            total = vshops.Count();
            var model = vshops.Select(item => new
            {
                id        = item.Id,
                name      = item.Name,
                squence   = item.VShopExtendInfo.FirstOrDefault().Sequence,
                addTime   = item.VShopExtendInfo.FirstOrDefault().AddTime.ToString(),
                creatTime = item.CreateTime.ToString(),
                visiteNum = item.VisitNum,
                buyNum    = item.buyNum
            });

            return(Json(new { rows = model, total = total }));
        }
        public JsonResult GetVshops(int page, int rows, string vshopName, int?vshopType = null, long?oldVShopId = null, bool?vshopIsOpen = null)
        {
            int        total      = 0;
            VshopQuery vshopQuery = new VshopQuery()
            {
                Name           = vshopName,
                PageNo         = page,
                PageSize       = rows,
                ExcepetVshopId = oldVShopId,
                IsAsc          = false,
                IsOpen         = vshopIsOpen,
            };

            if (vshopType == 1)
            {
                vshopQuery.VshopType = Entities.VShopExtendInfo.VShopExtendType.TopShow;
            }
            if (vshopType == 2)
            {
                vshopQuery.VshopType = Entities.VShopExtendInfo.VShopExtendType.HotVShop;
            }
            if (vshopType == 0)
            {
                vshopQuery.VshopType = 0;
            }

            var pmdata = _iVShopService.GetVShopByParamete(vshopQuery);
            var vshops = pmdata.Models.ToList();

            total = pmdata.Total;
            var categoryService = _iCategoryService;
            var shopService     = _iShopCategoryService;
            var extend          = _iVShopService.GetExtends(vshops.Select(p => p.Id).ToList());
            var model           = vshops.Select(item => new
            {
                id         = item.Id,
                name       = item.Name,
                creatTime  = item.CreateTime.ToString(),
                vshopTypes = extend.Any(t => t.VShopId == item.Id && t.Type == VShopExtendInfo.VShopExtendType.TopShow) ? "主推微店" :
                             extend.Any(t => t.VShopId == item.Id && t.Type == VShopExtendInfo.VShopExtendType.HotVShop) ? "热门微店" : "普通微店",
                categoryName = shopService.GetBusinessCategory(item.ShopId).FirstOrDefault() != null ? categoryService.GetCategory(long.Parse(shopService.GetBusinessCategory(item.ShopId).FirstOrDefault().Path.Split('|').First())).Name : "",
                visiteNum    = item.VisitNum,
                buyNum       = item.buyNum,
                StateStr     = item.State.ToDescription(),
                IsOpenStr    = item.IsOpen ? "已开启" : "已关闭",
                IsOpen       = item.IsOpen,
            });

            return(Json(new { rows = model, total = total }));
        }
Exemple #6
0
        public JsonResult GetHotShop(int page, int rows, string vshopName, DateTime?startTime = null, DateTime?endTime = null)
        {
            int        num;
            VshopQuery vshopQuery = new VshopQuery()
            {
                PageNo   = page,
                PageSize = rows,
                Name     = vshopName
            };
            VshopQuery       vshopQuery1 = vshopQuery;
            List <VShopInfo> list        = ServiceHelper.Create <IVShopService>().GetHotShop(vshopQuery1, startTime, endTime, out num).ToList();

            num = list.Count();
            var variable =
                from item in list
                select new { id = item.Id, name = item.Name, squence = item.VShopExtendInfo.FirstOrDefault().Sequence, addTime = item.VShopExtendInfo.FirstOrDefault().AddTime.ToString(), creatTime = item.CreateTime.ToString(), visiteNum = item.VisitNum, buyNum = item.buyNum };

            return(Json(new { rows = variable, total = num }));
        }
        public ObsoletePageModel <VShopInfo> GetVShopByParamete(VshopQuery vshopQuery)
        {
            int total  = 0;
            var vshops = Context.VShopInfo.AsQueryable();

            if (vshopQuery.VshopType.HasValue)
            {
                if (vshopQuery.VshopType != 0)
                {
                    vshops = from a in Context.VShopInfo
                             where
                             (from b in a.VShopExtendInfo
                              where b.Type == vshopQuery.VshopType
                              select b.VShopId).Contains(a.Id)
                             select a;
                }
                else
                {
                    vshops = from a in Context.VShopInfo
                             where
                             a.VShopExtendInfo.Count() == 0
                             select a;
                }
            }
            if (!string.IsNullOrEmpty(vshopQuery.Name))
            {
                vshops = vshops.Where(a => a.Name.Contains(vshopQuery.Name));
            }
            if (vshopQuery.ExcepetVshopId.HasValue && vshopQuery.ExcepetVshopId.Value != 0)
            {
                vshops = vshops.Where(a => a.Id != vshopQuery.ExcepetVshopId.Value);
            }
            vshops = vshops.Where(e => e.State == VShopInfo.VshopStates.Normal || e.State == VShopInfo.VshopStates.Close);
            total  = vshops.Count();
            ObsoletePageModel <VShopInfo> result = new ObsoletePageModel <VShopInfo>();

            result.Models = vshops.OrderBy(a => a.CreateTime).Skip((vshopQuery.PageNo - 1) * vshopQuery.PageSize).Take(vshopQuery.PageSize).AsQueryable();
            result.Total  = total;
            return(result);
        }
        public IEnumerable <VShopInfo> GetHotShop(VshopQuery vshopQuery, DateTime?startTime, DateTime?endTime, out int total)
        {
            var vshops = (from s in Context.VShopInfo
                          join vs in Context.VShopExtendInfo on s.Id equals vs.VShopId
                          where vs.Type == VShopExtendInfo.VShopExtendType.HotVShop
                          orderby vs.Sequence, s.CreateTime
                          select s);

            if (!string.IsNullOrEmpty(vshopQuery.Name))
            {
                vshops = vshops.Where(a => a.Name.Contains(vshopQuery.Name));
            }
            if (startTime.HasValue)
            {
                vshops = vshops.Where(a => a.VShopExtendInfo.Any(item => item.AddTime >= startTime));
            }
            if (endTime.HasValue)
            {
                var end = endTime.Value.Date.AddDays(1);
                vshops = vshops.Where(a => a.VShopExtendInfo.Any(item => item.AddTime < end));
            }
            total = vshops.Count();
            return(vshops.Skip((vshopQuery.PageNo - 1) * vshopQuery.PageSize).Take(vshopQuery.PageSize));
        }
Exemple #9
0
 /// <summary>
 /// 获取热门微店
 /// </summary>
 /// <returns></returns>
 public static List <Entities.VShopInfo> GetHotShop(VshopQuery vshopQuery, DateTime?startTime, DateTime?endTime, out int total)
 {
     return(Service.GetHotShop(vshopQuery, startTime, endTime, out total));
 }
Exemple #10
0
 /// <summary>
 /// 根据条件查询所有微店
 /// </summary>
 /// <returns></returns>
 public static QueryPageModel <Entities.VShopInfo> GetVShopByParamete(VshopQuery vshopQuery)
 {
     return(Service.GetVShopByParamete(vshopQuery));
 }
Exemple #11
0
        public QueryPageModel <VShopInfo> GetVShopByParamete(VshopQuery vshopQuery)
        {
            var vshops = DbFactory.Default.Get <VShopInfo>();

            if (vshopQuery.VshopType.HasValue)
            {
                if (vshopQuery.VshopType != 0)
                {
                    var vshopex = DbFactory.Default
                                  .Get <VShopExtendInfo>()
                                  .Where <VShopInfo>((vsei, vsi) => vsei.VShopId == vsi.Id && vsei.Type == vshopQuery.VshopType)
                                  .Select(n => n.VShopId);

                    vshops.Where(n => n.ExExists(vshopex));
                }
                else
                {
                    var vshopex = DbFactory.Default
                                  .Get <VShopExtendInfo>()
                                  .Where <VShopInfo>((vsei, vsi) => vsei.VShopId == vsi.Id);
                    vshops.Where(n => n.ExNotExists(vshopex));
                }
            }
            if (!string.IsNullOrEmpty(vshopQuery.Name))
            {
                vshops.Where(a => a.Name.Contains(vshopQuery.Name));
            }
            if (vshopQuery.ExcepetVshopId.HasValue && vshopQuery.ExcepetVshopId.Value != 0)
            {
                vshops.Where(a => a.Id != vshopQuery.ExcepetVshopId.Value);
            }

            //微店状态判断
            if (vshopQuery.Status.HasValue)
            {
                vshops.Where(e => e.State == vshopQuery.Status.Value);
            }
            else
            {
                vshops.Where(e => e.State == VShopInfo.VShopStates.Normal || e.State == VShopInfo.VShopStates.Close);
            }

            //微店开启状态判断
            if (vshopQuery.IsOpen.HasValue)
            {
                vshops.Where(e => e.IsOpen == vshopQuery.IsOpen.Value);
            }

            QueryPageModel <VShopInfo> result = new QueryPageModel <VShopInfo>();

            if (vshopQuery.IsAsc)
            {
                vshops.OrderBy(a => a.CreateTime);
            }
            else
            {
                vshops.OrderByDescending(a => a.CreateTime);
            }

            var rets = vshops.ToPagedList(vshopQuery.PageNo, vshopQuery.PageSize);

            result.Models = rets;
            result.Total  = rets.TotalRecordCount;
            return(result);
        }
Exemple #12
0
        public JsonResult GetVshops(int page, int rows, string vshopName, int?vshopType = null)
        {
            Func <VShopExtendInfo, bool> func  = null;
            Func <VShopExtendInfo, bool> func1 = null;
            int        num        = 0;
            VshopQuery vshopQuery = new VshopQuery()
            {
                Name     = vshopName,
                PageNo   = page,
                PageSize = rows
            };
            VshopQuery nullable  = vshopQuery;
            int?       nullable1 = vshopType;

            if ((nullable1.GetValueOrDefault() != 1 ? false : nullable1.HasValue))
            {
                nullable.VshopType = new VShopExtendInfo.VShopExtendType?(VShopExtendInfo.VShopExtendType.TopShow);
            }
            int?nullable2 = vshopType;

            if ((nullable2.GetValueOrDefault() != 2 ? false : nullable2.HasValue))
            {
                nullable.VshopType = new VShopExtendInfo.VShopExtendType?(VShopExtendInfo.VShopExtendType.HotVShop);
            }
            int?nullable3 = vshopType;

            if ((nullable3.GetValueOrDefault() != 0 ? false : nullable3.HasValue))
            {
                nullable.VshopType = new VShopExtendInfo.VShopExtendType?(0);
            }
            List <VShopInfo> list = ServiceHelper.Create <IVShopService>().GetVShopByParamete(nullable, out num).ToList();

            num = list.Count();
            ICategoryService     categoryService     = ServiceHelper.Create <ICategoryService>();
            IShopCategoryService shopCategoryService = ServiceHelper.Create <IShopCategoryService>();
            var collection = list.ToArray().Select((VShopInfo item) => {
                string str;
                long id     = item.Id;
                string name = item.Name;
                string str1 = item.CreateTime.ToString();
                ICollection <VShopExtendInfo> vShopExtendInfo = item.VShopExtendInfo;
                if (func == null)
                {
                    func = (VShopExtendInfo t) => t.Type == VShopExtendInfo.VShopExtendType.TopShow;
                }
                if (vShopExtendInfo.Any(func))
                {
                    str = "主推微店";
                }
                else
                {
                    ICollection <VShopExtendInfo> vShopExtendInfos = item.VShopExtendInfo;
                    if (func1 == null)
                    {
                        func1 = (VShopExtendInfo t) => t.Type == VShopExtendInfo.VShopExtendType.HotVShop;
                    }
                    str = (vShopExtendInfos.Any(func1) ? "热门微店" : "普通微店");
                }
                return(new { id = id, name = name, creatTime = str1, vshopTypes = str, categoryName = (shopCategoryService.GetBusinessCategory(item.ShopId).FirstOrDefault() != null ? categoryService.GetCategory(long.Parse(shopCategoryService.GetBusinessCategory(item.ShopId).FirstOrDefault().Path.Split(new char[] { '|' }).First <string>())).Name : ""), visiteNum = item.VisitNum, buyNum = item.buyNum });
            });

            return(Json(new { rows = collection, total = num }));
        }
 /// <summary>
 /// 获取热门微店
 /// </summary>
 /// <returns></returns>
 public static IEnumerable <VShopInfo> GetHotShop(VshopQuery vshopQuery, DateTime?startTime, DateTime?endTime, out int total)
 {
     return(_iVShopService.GetHotShop(vshopQuery, startTime, endTime, out total));
 }
 /// <summary>
 /// 根据条件查询所有微店
 /// </summary>
 /// <returns></returns>
 public static ObsoletePageModel <VShopInfo> GetVShopByParamete(VshopQuery vshopQuery)
 {
     return(_iVShopService.GetVShopByParamete(vshopQuery));
 }