Пример #1
0
        public ApiResult <PagedList <OrderListOutput> > Index([FromQuery] OrderListInput parameter)
        {
            parameter.OrderType = OrderType.Normal;
            var orderPageList = Resolve <IOrderService>().GetPageList(parameter);

            return(ApiResult.Success(orderPageList));
        }
Пример #2
0
        public ApiResult <PagedList <OrderListOutput> > VirtualOrderList([FromQuery] OrderListInput parameter)
        {
            parameter.UserId    = parameter.LoginUserId;
            parameter.OrderType = OrderType.VirtualOrder;
            var orderPageList = Resolve <IOrderService>().GetPageList(parameter);

            return(ApiResult.Success(orderPageList));
        }
Пример #3
0
        /// <summary>
        ///     获取订单列表,包括供应商订单,会员订单,后台订单
        /// </summary>
        /// <param name="orderInput"></param>
        public PagedList <OrderListOutput> GetPageList(OrderListInput orderInput)
        {
            var query = new ExpressionQuery <Order>();

            if (orderInput.OrderStatus > 0)
            {
                query.And(e => e.OrderStatus == orderInput.OrderStatus);
            }

            if (orderInput.OrderType.HasValue)
            {
                query.And(e => e.OrderType == orderInput.OrderType);
            }

            if (!orderInput.StoreId.IsObjectIdNullOrEmpty())
            {
                query.And(e => e.StoreId == orderInput.StoreId.ToString());
            }

            if (orderInput.DeliverUserId > 0) // 发货记录
            {
                query.And(e => e.DeliverUserId == orderInput.DeliverUserId);
            }

            if (orderInput.UserId > 0) //订单记录
            {
                query.And(e => e.UserId == orderInput.UserId);
            }
            else if (orderInput.UserId > 0)   //订单记录
            {
                query.And(e => e.UserId == orderInput.UserId);
            }

            if (orderInput.OrderType > 0)
            {
                query.And(e => e.OrderType == orderInput.OrderType);
            }

            query.PageIndex    = (int)orderInput.PageIndex;
            query.PageSize     = (int)orderInput.PageSize;
            query.EnablePaging = true;
            query.OrderByDescending(e => e.Id);
            var orders = Resolve <IOrderService>().GetPagedList(query);

            if (orders.Count < 0)
            {
                return(new PagedList <OrderListOutput>());
            }

            var model = new List <OrderListOutput>();

            foreach (var item in orders)
            {
                var listOutput = new OrderListOutput {
                    CreateTime     = item?.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    Id             = item.Id,
                    OrderStatuName = item?.OrderStatus.GetDisplayName(),
                    User           = item?.OrderExtension?.User,
                    Address        = item?.OrderExtension?.UserAddress?.Address
                };
                if (item.OrderExtension != null)
                {
                    if (item.OrderExtension.UserAddress != null)
                    {
                        listOutput.RegionName = Resolve <IRegionService>()
                                                .GetRegionNameById(item.OrderExtension.UserAddress.RegionId);
                    }
                }
                else
                {
                    listOutput.RegionName = null;
                }

                listOutput = AutoMapping.SetValue(item, listOutput);
                var orderExtension = item.Extension.DeserializeJson <OrderExtension>();
                if (orderExtension != null && orderExtension.Store != null)
                {
                    listOutput.StoreName     = orderExtension.Store.Name;
                    listOutput.ExpressAmount = orderExtension.OrderAmount.ExpressAmount;
                }

                if (item.OrderStatus == OrderStatus.WaitingBuyerPay)
                {
                    var proids = orderExtension.ProductSkuItems.Select(s => s.ProductId);

                    var productNotOnline = Resolve <IProductService>().GetList(s =>
                                                                               s.ProductStatus != GoodsStatus.Online && proids.Contains(s.Id));
                    foreach (var product in productNotOnline)
                    {
                        var ext = orderExtension.ProductSkuItems.SingleOrDefault(s => s.ProductId == product.Id);
                        if (ext != null)
                        {
                            ext.ProductStatus      = product.ProductStatus;
                            listOutput.OrderStatus = OrderStatus.UnderShelf; //标识为下架订单
                        }
                    }
                }

                listOutput.OutOrderProducts = orderExtension.ProductSkuItems;
                listOutput.OutOrderProducts?.ToList().ForEach(c => {
                    c.ThumbnailUrl = Resolve <IApiService>().ApiImageUrl(c.ThumbnailUrl);
                });
                model.Add(listOutput);
            }

            return(PagedList <OrderListOutput> .Create(model, orders.RecordCount, orders.PageSize, orders.PageIndex));
        }