李昊 4 years ago
parent
commit
29d6e44f98

+ 33 - 0
gx_api/GxPress/Model/GxPress.Request/Order/OrderRequest.cs

@@ -0,0 +1,33 @@
+namespace GxPress.Request.Order
+{
+    public class OrderRequest
+    {
+
+    }
+    /// <summary>
+    /// 订单查询
+    /// </summary>
+    public class OrderSearchRequest:Common.Page.PageParameter
+    {
+        /// <summary>
+        /// 搜索字段
+        /// </summary>
+        /// <value></value>
+        public string KeyWord { get; set; }
+        /// <summary>
+        /// 支付方式 1 微信 2 支付宝
+        /// </summary>
+        /// <value></value>
+        public int PayWay { get; set; }
+        /// <summary>
+        /// 开始日期
+        /// </summary>
+        /// <value></value>
+        public string BeginTime { get; set; }
+        /// <summary>
+        /// 结束时间
+        /// </summary>
+        /// <value></value>
+        public string EndTime { get; set; }
+    }
+}

+ 29 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/Order/OrderRepository.cs

@@ -1,9 +1,13 @@
+using System;
 using System.Collections.Generic;
+using System.Threading.Tasks;
 using AutoMapper;
 using Datory;
 using GxPress.Common.AppOptions;
+using GxPress.Common.Page;
 using GxPress.Common.Tools;
 using GxPress.Repository.Interface.Order;
+using GxPress.Request.Order;
 using Microsoft.Extensions.Options;
 
 namespace GxPress.Repository.Implement.Order
@@ -23,5 +27,30 @@ namespace GxPress.Repository.Implement.Order
         public IDatabase Database => _repository.Database;
         public string TableName => _repository.TableName;
         public List<TableColumn> TableColumns => _repository.TableColumns;
+        /// <summary>
+        /// 查询订单
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<PagedList<Entity.Order.Order>> GetAllOrderAsync(OrderSearchRequest request)
+        {
+            var result = new PagedList<Entity.Order.Order>();
+            var query = Q.NewQuery();
+            if (!string.IsNullOrEmpty(request.KeyWord))
+                query.WhereLike(nameof(Entity.Order.Order.OrderNumber), $"%{request.KeyWord}%");
+            if (request.PayWay > 0)
+                query.Where(nameof(Entity.Order.Order.PayWay), request.PayWay);
+            if (!string.IsNullOrEmpty(request.BeginTime) && !string.IsNullOrEmpty(request.EndTime))
+            {
+                if (DateTime.TryParse(request.BeginTime, out var BeginTime) && DateTime.TryParse(request.EndTime, out var EndTime))
+                {
+                    query.WhereTime(nameof(Entity.Order.Order.CreatedDate), ">", BeginTime);
+                    query.WhereTime(nameof(Entity.Order.Order.CreatedDate), "<", EndTime);
+                }
+            }
+            result.Total = await _repository.CountAsync(query);
+            result.Items = await _repository.GetAllAsync(query.ForPage(request.Page, request.PerPage));
+            return result;
+        }
     }
 }

+ 1 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/UserRepository.cs

@@ -900,7 +900,7 @@ namespace GxPress.Repository.Implement
             if (request.DisableTypeId > 0)
                 query.Where(nameof(User.IsDisable), request.VipTypeId == 1);
             result.Total = await _repository.CountAsync(query);
-            var items = await _repository.GetAllAsync(query);
+            var items = await _repository.GetAllAsync(query.ForPage(request.Page, request.PerPage));
             result.Items = items.Select(n => _mapper.Map<UserDetail>(n));
             return result;
         }