示例#1
0
        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <StoreOrderDto> > GetOrders(GetOrderInput input)
        {
            var products = await _productRepository.GetAllListAsync();

            var orders = await _storeRepository.GetAll()
                         .Where(c => c.OpenId.Equals(input.Device) &&
                                c.PayState.HasValue && c.PayState.Value)
                         .Where(c => c.PayType == PayType.BalancePay || c.PayType == PayType.LinePay)
                         .Where(c => c.OrderState.HasValue && c.OrderState.Value)
                         .ToListAsync();

            var count = orders.Count;
            var temp  = orders.OrderByDescending(c => c.CreationTime).Skip(input.SkipCount).Take(input.MaxResultCount);

            var result = from c in temp
                         join d in products on c.ProductId equals d.ProductId
                         select new StoreOrderDto()
            {
                Description = "",
                FastCode    = c.FastCode,
                Id          = c.Id,
                ImageUrl    = d.ImageUrl,
                ProductName = d.ProductName,
                OpenId      = c.OpenId
            };

            return(new PagedResultDto <StoreOrderDto>(count, result.ToList()));
        }