Esempio n. 1
0
        public BaseApiResponse StoreOrders(StoreOrdersRequest request)
        {
            request.CheckNotNull(nameof(request));

            //获取数据
            int pageSize    = 10;
            var storeOrders = _storeOrderQueryService.StoreStoreOrderDetails(request.Id);
            var total       = storeOrders.Count();
            var totalSum    = 0M;

            //筛选数据
            if (request.Status != StoreOrderStatus.All)
            {
                storeOrders = storeOrders.Where(x => x.Status == request.Status);
            }
            if (!string.IsNullOrEmpty(request.OrderNumber))
            {
                storeOrders = storeOrders.Where(x => x.Number.Contains(request.OrderNumber));
            }
            if (!request.ExpressRegion.IsNullOrEmpty())
            {
                storeOrders = storeOrders.Where(x => x.ExpressRegion.Contains(request.ExpressRegion));
            }
            if (request.DateRegion != null && request.DateRegion.Length == 2)
            {
                storeOrders = storeOrders.Where(x => x.CreatedOn.IsBetween(request.DateRegion[0], request.DateRegion[1]));
            }
            total    = storeOrders.Count();
            totalSum = storeOrders.Sum(x => x.Total);
            //分页
            storeOrders = storeOrders.OrderByDescending(x => x.CreatedOn).Skip(pageSize * (request.Page - 1)).Take(pageSize);

            return(new StoreOrdersResponse
            {
                Total = total,
                TotalSum = totalSum,
                StoreOrders = storeOrders.Select(x => new StoreOrder
                {
                    Id = x.Id,
                    StoreId = x.StoreId,
                    Region = x.Region,
                    Number = x.Number,
                    Remark = x.Remark,
                    ExpressAddress = x.ExpressAddress,
                    ExpressRegion = x.ExpressRegion,
                    ExpressMobile = x.ExpressMobile,
                    ExpressName = x.ExpressName,
                    ExpressZip = x.ExpressZip,
                    CreatedOn = x.CreatedOn,
                    Total = x.Total,
                    ShopCash = x.ShopCash,
                    Status = x.Status.ToDescription(),

                    DeliverExpressName = x.DeliverExpressName,
                    DeliverExpressCode = x.DeliverExpressCode,
                    DeliverExpressNumber = x.DeliverExpressNumber,

                    ReturnDeliverExpressName = x.ReturnDeliverExpressName,
                    ReturnDeliverExpressCode = x.ReturnDeliverExpressCode,
                    ReturnDeliverExpressNumber = x.ReturnDeliverExpressNumber,

                    Reason = x.Reason,
                    RefundAmount = x.RefundAmount.HasValue? x.RefundAmount.Value : 0,
                    StoreRemark = x.StoreRemark,

                    StoreOrderGoodses = x.StoreOrderGoodses.Select(z => new StoreOrderGoods
                    {
                        Id = z.Id,
                        GoodsId = z.GoodsId,
                        SpecificationId = z.SpecificationId,
                        SpecificationName = z.SpecificationName,
                        GoodsName = z.GoodsName,
                        GoodsPic = z.GoodsPic,
                        Quantity = z.Quantity,
                        Price = z.Price,
                        Total = z.Total
                    }).ToList()
                }).ToList()
            });
        }
        public BaseApiResponse StoreOrders(StoreOrdersRequest request)
        {
            request.CheckNotNull(nameof(request));

            TryInitUserModel();

            //获取数据
            int pageSize    = 10;
            var storeOrders = _storeOrderQueryService.StoreStoreOrderDetails(request.Id);
            var total       = storeOrders.Count();

            //筛选数据
            if (request.Status != StoreOrderStatus.All)
            {
                storeOrders = storeOrders.Where(x => x.Status == request.Status);
            }
            //订单号查询
            if (!string.IsNullOrEmpty(request.OrderNumber))
            {
                storeOrders = storeOrders.Where(x => x.Number.Contains(request.OrderNumber));
            }
            total = storeOrders.Count();
            //分页
            storeOrders = storeOrders.OrderByDescending(x => x.CreatedOn).Skip(pageSize * (request.Page - 1)).Take(pageSize);

            return(new UserOrdersResponse
            {
                Total = total,
                StoreOrders = storeOrders.Select(x => new StoreOrder
                {
                    Id = x.Id,
                    StoreId = x.StoreId,
                    Region = x.Region,
                    Number = x.Number,
                    Remark = x.Remark,
                    ExpressAddress = x.ExpressAddress,
                    ExpressRegion = x.ExpressRegion,
                    ExpressMobile = x.ExpressMobile,
                    ExpressName = x.ExpressName,
                    ExpressZip = x.ExpressZip,
                    CreatedOn = x.CreatedOn,
                    Total = x.Total,
                    Status = x.Status.ToDescription(),

                    DeliverExpressName = x.DeliverExpressName,
                    DeliverExpressCode = x.DeliverExpressCode,
                    DeliverExpressNumber = x.DeliverExpressNumber,

                    StoreOrderGoodses = x.StoreOrderGoodses.Select(z => new StoreOrderGoods
                    {
                        Id = z.Id,
                        GoodsId = z.GoodsId,
                        SpecificationId = z.SpecificationId,
                        SpecificationName = z.SpecificationName,
                        GoodsName = z.GoodsName,
                        GoodsPic = z.GoodsPic,
                        Quantity = z.Quantity,
                        Price = z.Price,
                        Total = z.Total
                    }).ToList()
                }).ToList()
            });
        }