コード例 #1
0
        public BaseApiResponse Info()
        {
            TryInitUserModel();

            var storeInfo = _storeQueryService.InfoByUserId(_user.Id);

            if (storeInfo == null)
            {
                return(new BaseApiResponse());
            }
            //获取未发货订单
            var placedStoreOrderes = _storeOrderQueryService.StoreStoreOrderDetails(storeInfo.Id, StoreOrderStatus.Placed);

            if (storeInfo != null)
            {
                return(new StoreInfoResponse
                {
                    StoreInfo = new StoreInfo
                    {
                        Id = storeInfo.Id,
                        AccessCode = storeInfo.AccessCode,
                        Name = storeInfo.Name,
                        Description = storeInfo.Description,
                        Region = storeInfo.Region,
                        Address = storeInfo.Address,
                        Type = storeInfo.Type.ToDescription(),
                        Status = storeInfo.Status.ToDescription()
                    },
                    SubjectInfo = new SubjectInfo
                    {
                        SubjectName = storeInfo.SubjectName,
                        SubjectNumber = storeInfo.SubjectNumber,
                        SubjectPic = storeInfo.SubjectPic
                    },
                    StatisticsInfo = new StatisticsInfo
                    {
                        TodaySale = storeInfo.TodaySale,
                        TodayOrder = storeInfo.TodayOrder,
                        TotalSale = storeInfo.TotalSale,
                        TotalOrder = storeInfo.TotalOrder
                    },
                    StoreOrders = placedStoreOrderes.Select(x => new Models.Response.StoreOrders.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,
                        StoreTotal = x.StoreTotal,
                        Status = x.Status.ToDescription(),
                        StoreOrderGoodses = x.StoreOrderGoodses.Select(z => new Models.Response.StoreOrders.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,
                            OriginalPrice = z.OriginalPrice,
                            Total = z.Total,
                            StoreTotal = z.StoreTotal,
                        }).ToList()
                    }).ToList()
                });
            }
            else
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有店铺"
                });
            }
        }
コード例 #2
0
        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()
            });
        }