Пример #1
0
        public JsonResult List(LimitTimeQuery query)
        {
            var result   = _iLimitTimeBuyService.GetFlashSaleInfos(query);
            var products = ProductManagerApplication.GetProducts(result.Models.Select(p => p.ProductId));
            var shops    = ShopApplication.GetShops(result.Models.Select(p => p.ShopId));

            var market = result.Models.Select(item =>
            {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                var shop    = shops.FirstOrDefault(p => p.Id == item.ShopId);
                var m       = new FlashSaleModel
                {
                    Id          = item.Id,
                    Title       = item.Title,
                    BeginDate   = item.BeginDate.ToString("yyyy-MM-dd"),
                    EndDate     = item.EndDate.ToString("yyyy-MM-dd"),
                    ShopName    = shop.ShopName,
                    ProductName = product.ProductName,
                    ProductId   = item.ProductId,
                    StatusStr   = item.Status.ToDescription()
                };
                if (item.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && item.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && item.BeginDate > DateTime.Now && item.EndDate < DateTime.Now)
                {
                    m.StatusStr = "进行中";
                }
                else if (item.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && item.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && item.BeginDate > DateTime.Now)
                {
                    m.StatusStr = "未开始";
                }
                m.SaleCount   = item.SaleCount;
                m.MinPrice    = item.MinPrice;
                m.MarketPrice = product.MarketPrice;
                m.ProductImg  = Mall.Core.MallIO.GetProductSizeImage(product.ImagePath, 1, (int)ImageSize.Size_350);
                return(m);
            });
            var dataGrid = new DataGridModel <FlashSaleModel>()
            {
                rows = market, total = result.Total
            };

            return(Json(dataGrid));
        }