Beispiel #1
0
        public object GetLismitBuyList(int pageNo, int pageSize, string cateName = "")
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                ItemName           = cateName,
                IsPreheat          = true,
                PageNo             = pageNo,
                PageSize           = pageSize,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true,
                OrderKey           = 5 /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
            };

            #endregion
            var obj = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetAll(query);

            var list = obj.Models.ToList().Select(item => new
            {
                Id          = item.Id,
                ProductId   = item.ProductId,
                ProductImg  = Core.HimallIO.GetRomoteProductSizeImage(item.Himall_Products.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350),
                ProductName = item.Himall_Products.ProductName,
                MinPrice    = item.MinPrice,
                EndDate     = item.EndDate
            }).ToList();

            return(Json(new { Total = obj.Total, List = list }));
        }
        /// <summary>
        /// 获取限时购列表接口
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public object GetLimitBuyList(int pageIndex, int pageSize)
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                PageNo             = pageIndex,
                PageSize           = pageSize,
                CheckProductStatus = true,
                OrderKey           = 5, /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing
            };

            #endregion
            var obj = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetAll(query);

            var list = obj.Models.ToList().Select(item => new
            {
                CountDownId     = item.Id,
                ProductId       = item.ProductId,
                ProductName     = item.Himall_Products.ProductName,
                SalePrice       = item.Himall_Products.MinSalePrice.ToString("0.##"), //市场价
                CountDownPrice  = item.MinPrice,
                CountDownType   = DateTime.Now < item.BeginDate ? 1 : 2,              //1=即将开始,2=立即抢购
                ThumbnailUrl160 = Core.HimallIO.GetRomoteProductSizeImage(item.Himall_Products.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220)
            }).ToList();
            var json = new
            {
                Status = "OK",
                Data   = list
            };
            return(json);
        }
        /// <summary>
        /// 获取限时购列表接口
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetLimitBuyList(int pageIndex, int pageSize)
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                PageNo             = pageIndex,
                PageSize           = pageSize,
                IsPreheat          = true,
                CheckProductStatus = true,
                OrderKey           = 5, /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing
            };

            #endregion
            var data = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetAll(query);

            var products = ProductManagerApplication.GetProducts(data.Models.Select(p => p.ProductId));
            var list     = data.Models.ToList().Select(item => {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                return(new
                {
                    CountDownId = item.Id,
                    ProductId = item.ProductId,
                    ProductName = product.ProductName,
                    SalePrice = product.MarketPrice.ToString("0.##"),      //各端统一取商品市场价
                    CountDownPrice = item.MinPrice,
                    CountDownType = DateTime.Now < item.BeginDate ? 1 : 2, //1=即将开始,2=立即抢购
                    ThumbnailUrl160 = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220)
                });
            });
            return(JsonResult <dynamic>(list));
        }
Beispiel #4
0
        public ActionResult Home(string catename = "")
        {
            Func <SelectListItem, bool> predicate = null;
            List <SelectListItem>       source    = new List <SelectListItem>();

            string[] serviceCategories = this._iLimitTimeBuyService.GetServiceCategories();
            foreach (string str in serviceCategories)
            {
                SelectListItem item = new SelectListItem
                {
                    Selected = false,
                    Text     = str,
                    Value    = str
                };
                source.Add(item);
            }
            if (!string.IsNullOrWhiteSpace(catename))
            {
                if (predicate == null)
                {
                    predicate = c => c.Text.Equals(catename);
                }
                SelectListItem item2 = source.FirstOrDefault <SelectListItem>(predicate);
                if (item2 != null)
                {
                    item2.Selected = true;
                }
            }
            FlashSaleConfigModel config = this._iLimitTimeBuyService.GetConfig();

            ((dynamic)base.ViewBag).Preheat = config.Preheat;
            ((dynamic)base.ViewBag).Cate    = source;
            FlashSaleQuery query = new FlashSaleQuery
            {
                CategoryName       = catename,
                OrderKey           = 5,
                IsPreheat          = true,
                PageNo             = 1,
                PageSize           = 10,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };
            ObsoletePageModel <FlashSaleInfo> all = this._iLimitTimeBuyService.GetAll(query);

            return(base.View(all));
        }
Beispiel #5
0
        public ActionResult GetData(int index, int size, string cname)
        {
            FlashSaleQuery query = new FlashSaleQuery
            {
                ItemName           = cname,
                IsPreheat          = true,
                PageNo             = index,
                PageSize           = size,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };
            ObsoletePageModel <FlashSaleInfo> all  = this._iLimitTimeBuyService.GetAll(query);
            List <FlashSaleModel>             list = new List <FlashSaleModel>();

            foreach (FlashSaleInfo info in all.Models.ToList <FlashSaleInfo>())
            {
                FlashSaleModel item = new FlashSaleModel
                {
                    Id                    = info.Id,
                    Title                 = info.Title,
                    ShopId                = info.ShopId,
                    ProductId             = info.ProductId,
                    Status                = info.Status,
                    ProductName           = info.Himall_Products.ProductName,
                    ProductImg            = HimallIO.GetProductSizeImage(info.Himall_Products.RelativePath, 1, 0),
                    MarketPrice           = info.Himall_Products.MarketPrice,
                    BeginDate             = info.BeginDate.ToString("yyyy-MM-dd HH:mm"),
                    EndDate               = info.EndDate.ToString("yyyy-MM-dd HH:mm"),
                    LimitCountOfThePeople = info.LimitCountOfThePeople,
                    SaleCount             = info.SaleCount,
                    CategoryName          = info.CategoryName,
                    MinPrice              = info.MinPrice
                };
                list.Add(item);
            }
            DataGridModel <FlashSaleModel> data = new DataGridModel <FlashSaleModel>
            {
                total = all.Total,
                rows  = list
            };

            return(base.Json(data));
        }
Beispiel #6
0
        public ActionResult Home(string catename = "")
        {
            List <SelectListItem> CateSelItem = new List <SelectListItem>();
            var cateArray = _iLimitTimeBuyService.GetServiceCategories();

            foreach (var cate in cateArray)
            {
                CateSelItem.Add(new SelectListItem {
                    Selected = false, Text = cate, Value = cate
                });
            }
            if (!string.IsNullOrWhiteSpace(catename))
            {
                var _tmp = CateSelItem.FirstOrDefault(c => c.Text.Equals(catename));
                if (_tmp != null)
                {
                    _tmp.Selected = true;
                }
            }
            var flashSaleConfig = _iLimitTimeBuyService.GetConfig();

            ViewBag.Preheat = flashSaleConfig.Preheat;
            ViewBag.Cate    = CateSelItem;
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                CategoryName       = catename,
                OrderKey           = 5, /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
                IsPreheat          = true,
                PageNo             = 1,
                PageSize           = 14,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion
            var model = _iLimitTimeBuyService.GetAll(query);

            ViewBag.Products = ProductManagerApplication.GetProducts(model.Models.Select(p => p.ProductId));
            return(View(model));
        }
        public ActionResult GetData(int index, int size, string cname)
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                ItemName           = cname,
                IsPreheat          = true,
                PageNo             = index,
                PageSize           = size,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion
            var obj = _iLimitTimeBuyService.GetAll(query);

            List <FlashSaleModel> list = new List <FlashSaleModel>();
            foreach (var model in obj.Models.ToList())
            {
                FlashSaleModel result = new FlashSaleModel();
                result.Id                    = model.Id;
                result.Title                 = model.Title;
                result.ShopId                = model.ShopId;
                result.ProductId             = model.ProductId;
                result.Status                = model.Status;
                result.ProductName           = model.Himall_Products.ProductName;
                result.ProductImg            = Himall.Core.HimallIO.GetProductSizeImage(model.Himall_Products.RelativePath, 1);
                result.MarketPrice           = model.Himall_Products.MarketPrice;
                result.BeginDate             = model.BeginDate.ToString("yyyy-MM-dd HH:mm");
                result.EndDate               = model.EndDate.ToString("yyyy-MM-dd HH:mm");
                result.LimitCountOfThePeople = model.LimitCountOfThePeople;
                result.SaleCount             = model.SaleCount;
                result.CategoryName          = model.CategoryName;
                result.MinPrice              = model.MinPrice;
                list.Add(result);
            }
            DataGridModel <FlashSaleModel> x = new DataGridModel <FlashSaleModel>();
            x.total = obj.Total;
            x.rows  = list;
            return(Json(x));
        }
Beispiel #8
0
        public ActionResult GetData(int index, int size, string cname)
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                ItemName           = cname,
                OrderKey           = 5, /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
                IsPreheat          = true,
                PageNo             = index,
                PageSize           = size,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion
            var obj      = _iLimitTimeBuyService.GetAll(query);
            var products = ProductManagerApplication.GetProducts(obj.Models.Select(p => p.ProductId));
            List <FlashSaleModel> list = new List <FlashSaleModel>();
            foreach (var model in obj.Models)
            {
                var            product = products.FirstOrDefault(p => p.Id == model.ProductId);
                FlashSaleModel result  = new FlashSaleModel();
                result.Id                    = model.Id;
                result.Title                 = model.Title;
                result.ShopId                = model.ShopId;
                result.ProductId             = model.ProductId;
                result.Status                = model.Status;
                result.ProductName           = product.ProductName;
                result.ProductImg            = Mall.Core.MallIO.GetProductSizeImage(product.RelativePath, 1);
                result.MarketPrice           = product.MarketPrice;
                result.BeginDate             = model.BeginDate.ToString("yyyy-MM-dd HH:mm");
                result.EndDate               = model.EndDate.ToString("yyyy-MM-dd HH:mm");
                result.LimitCountOfThePeople = model.LimitCountOfThePeople;
                result.SaleCount             = model.SaleCount;
                result.CategoryName          = model.CategoryName;
                result.MinPrice              = model.MinPrice;
                list.Add(result);
            }
            return(Json(new { success = true, data = list, total = obj.Total }));
        }
Beispiel #9
0
        public object GetLismitBuyList(int pageNo, int pageSize, string cateName = "")
        {
            #region 初始化查询Model
            FlashSaleQuery query = new FlashSaleQuery()
            {
                ItemName           = cateName,
                IsPreheat          = true,
                PageNo             = pageNo,
                PageSize           = pageSize,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true,
                OrderKey           = 5 /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态 开始排前面) */
            };

            #endregion

            var data = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetAll(query);

            var products = ProductManagerApplication.GetProducts(data.Models.Select(p => p.ProductId));



            var list = data.Models.Select(item => {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                return(new
                {
                    Id = item.Id,
                    ProductId = item.ProductId,
                    ProductImg = MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_350),
                    ProductName = product.ProductName,
                    MinPrice = item.MinPrice,
                    EndDate = item.EndDate,
                    MarketPrice = product.MarketPrice
                });
            }).ToList();

            return(new { success = true, total = data.Total, List = list });
        }
Beispiel #10
0
        public QueryPageModel <FlashSaleInfo> GetAll(FlashSaleQuery query)
        {
            ExpiredDataChangeStatus();
            var db = DbFactory.Default.Get <FlashSaleInfo>()
                     .LeftJoin <ProductInfo>((fsi, pi) => fsi.ProductId == pi.Id)
                     .LeftJoin <ShopInfo>((fsi, si) => fsi.ShopId == si.Id);

            var config = GetConfig();

            if (query.IsStart == 1)//已开始
            {
                db.Where(p => p.BeginDate < DateTime.Now && p.Status == FlashSaleInfo.FlashSaleStatus.Ongoing);
            }
            else if (query.IsStart == 2)  //即将开始
            {
                var date = DateTime.Now.AddHours(config.Preheat);
                db.Where(p => p.BeginDate <date && p.BeginDate> DateTime.Now && p.Status == FlashSaleInfo.FlashSaleStatus.Ongoing);
            }
            else
            {
                if (query.IsPreheat)
                {
                    //if (config.Preheat > 0)
                    //{
                    var date = DateTime.Now.AddHours(config.Preheat);
                    db.Where(p => p.BeginDate < date);
                    //}
                }
            }

            if (query.OrderType != 0)
            {
                db.Where(item => item.EndDate > DateTime.Now);
            }
            if (query.ShopId.HasValue)
            {
                db.Where(item => query.ShopId == item.ShopId);
            }
            if (!string.IsNullOrWhiteSpace(query.ItemName))
            {
                db.Where <ProductInfo>(item => item.ProductName.Contains(query.ItemName));
            }
            if (!string.IsNullOrWhiteSpace(query.ShopName))
            {
                db.Where <ShopInfo>(item => item.ShopName.Contains(query.ShopName));
            }
            if (!string.IsNullOrWhiteSpace(query.CategoryName))
            {
                db.Where(d => d.CategoryName == query.CategoryName);
            }
            var Date = DateTime.Now;

            if (query.AuditStatus.HasValue)
            {
                var status = query.AuditStatus;
                FlashSaleInfo.FlashSaleStatus s = (FlashSaleInfo.FlashSaleStatus)status;
                db.Where(p => p.Status == s);
            }
            //db.Where<ProductInfo>(p => p.AuditStatus == ProductInfo.ProductAuditStatus.Audited && p.IsDeleted == false);
            if (query.CheckProductStatus)
            {
                db.Where <ProductInfo>(p => p.SaleStatus == ProductInfo.ProductSaleStatus.OnSale);
            }


            switch (query.OrderKey)
            {
            case 2:
                if (query.OrderType == 1)
                {
                    db.OrderBy(item => item.SaleCount);
                }
                else
                {
                    db.OrderByDescending(item => item.SaleCount);
                }
                break;

            //case 3:
            //    if( query.OrderType == 2 )
            //        orderby = limit.GetOrderBy( d => d.OrderBy( item => item.Price ) );
            //    else
            //        orderby = limit.GetOrderBy( d => d.OrderByDescending( item => item.Price ) );
            //    break;
            case 4:
                if (query.OrderType == 1)
                {
                    db.OrderBy(item => item.EndDate);
                }
                else
                {
                    db.OrderByDescending(item => item.EndDate);
                }
                break;

            case 5:
                if (query.OrderType == 1)
                {
                    db.OrderBy(item => item.BeginDate);
                }
                else
                {
                    db.OrderByDescending(item => item.BeginDate);
                }
                break;

            default:
                db.OrderByDescending(item => item.Id);
                break;
            }
            var data = db.ToPagedList(query.PageNo, query.PageSize);

            return(new QueryPageModel <FlashSaleInfo>()
            {
                Models = data, Total = data.TotalRecordCount
            });
        }
        // GET: Web/LimitTimeBuy
        public ActionResult Home(
            string keywords = "", /* 搜索关键字 */
            string catename = "", /* 分类名*/
            int orderKey    = 5,  /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态) */
            int orderType   = 1,  /* 排序方式(1:升序,2:降序) */
            int isStart     = 0,  /*是否开始( 1 : 开始 , 2 : 未开始 )*/
            int pageNo      = 1,  /*页码*/
            int pageSize    = 60  /*每页显示数据量*/
            )
        {
            #region 初始化查询Model
            FlashSaleQuery model = new FlashSaleQuery()
            {
                ItemName           = keywords,
                OrderKey           = orderKey,
                OrderType          = orderType,
                CategoryName       = catename,
                IsStart            = isStart,
                IsPreheat          = true,
                PageNo             = pageNo,
                PageSize           = pageSize,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion

            #region ViewBag

            List <SelectListItem> CateSelItem = new List <SelectListItem>();
            var cateArray = _iLimitTimeBuyService.GetServiceCategories();
            foreach (var cate in cateArray)
            {
                CateSelItem.Add(new SelectListItem {
                    Selected = false, Text = cate, Value = cate
                });
            }
            if (!string.IsNullOrWhiteSpace(catename))
            {
                var _tmp = CateSelItem.FirstOrDefault(c => c.Text.Equals(catename));
                if (_tmp != null)
                {
                    _tmp.Selected = true;
                }
            }

            ViewBag.Cate      = CateSelItem;
            ViewBag.keywords  = keywords;
            ViewBag.orderKey  = orderKey;
            ViewBag.orderType = orderType;
            ViewBag.catename  = catename;
            ViewBag.Logined   = (null != CurrentUser) ? 1 : 0;
            ViewBag.isStart   = isStart;
            ViewBag.Slide     = _iSlideAdsService.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.PlatformLimitTime);

            #endregion


            #region 查询商品

            //var itemsModel = _iLimitTimeBuyService.GetItemList(model);
            var itemsModel = _iLimitTimeBuyService.GetAll(model);
            int total      = itemsModel.Total;
            var items      = itemsModel.Models.ToArray();


            if (itemsModel.Total == 0)
            {
                ViewBag.keywords = keywords;
                return(View());
            }

            ViewBag.Products = ProductManagerApplication.GetProducts(items.Select(p => p.ProductId));
            #endregion


            #region 分页控制
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = model.PageNo,
                ItemsPerPage = pageSize,
                TotalItems   = total
            };
            ViewBag.pageInfo = info;
            #endregion

            return(View(items ?? new FlashSaleInfo[] { }));
        }