李昊 4 years ago
parent
commit
a7da978511

+ 2 - 2
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminAppStartPage.cs

@@ -12,10 +12,10 @@ namespace GxPress.Api.AdminControllers
     [Route("api/admin/app-start-page")]
     [ApiController]
     [Authorize]
-    public class AdminAppStartPage : Controller
+    public class AdminAppStartPageController : Controller
     {
         private readonly IAppStartPageRepository appStartPageRepository;
-        public AdminAppStartPage(IAppStartPageRepository appStartPageRepository)
+        public AdminAppStartPageController(IAppStartPageRepository appStartPageRepository)
         {
             this.appStartPageRepository = appStartPageRepository;
         }

+ 45 - 0
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminOrderController.cs

@@ -0,0 +1,45 @@
+using System.Threading.Tasks;
+using GxPress.Common.Page;
+using GxPress.Repository.Interface.Order;
+using GxPress.Request.Order;
+using GxPress.Result.Order;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace GxPress.Api.AdminControllers
+{
+    /// <summary>
+    /// 商务管理
+    /// </summary>
+    [Route("api/admin/admin")]
+    [ApiController]
+    [Authorize]
+    public class AdminOrderController : Controller
+    {
+        private readonly IOrderRepository orderRepository;
+        public AdminOrderController(IOrderRepository orderRepository)
+        {
+            this.orderRepository = orderRepository;
+        }
+        /// <summary>
+        /// 订单管理 查询订单
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("list")]
+        public async Task<PagedList<Entity.Order.Order>> GetAllOrderAsync(OrderSearchRequest request)
+        {
+            return await orderRepository.GetAllOrderAsync(request);
+        }
+        /// <summary>
+        /// 财务中心
+        /// </summary>
+        /// <param name="request"></param>
+        /// /// <returns></returns>
+        [HttpPost("finance-list")]
+        public async Task<OrderFinanceResult<Entity.Order.Order>> GetAllOrderFinnceAsync(OrderFinanceSearchRequest request)
+        {
+            return await orderRepository.GetAllOrderFinnceAsync(request);
+        }
+    }
+}

+ 6 - 0
gx_api/GxPress/Model/GxPress.Entity/Order/Order.cs

@@ -68,5 +68,11 @@ namespace GxPress.Entity.Order
         /// <value></value>
         [DataColumn]
         public int PayWay { get; set; }
+        /// <summary>
+        /// 1 商品付费 2会员开通
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int OrderType { get; set; }
     }
 }

+ 36 - 1
gx_api/GxPress/Model/GxPress.Request/Order/OrderRequest.cs

@@ -1,13 +1,48 @@
 namespace GxPress.Request.Order
 {
+    /// <summary>
+    /// 订单
+    /// </summary>
     public class OrderRequest
     {
 
     }
     /// <summary>
+    /// 财务中心
+    /// </summary>
+    public class OrderFinanceSearchRequest : 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; }
+        /// <summary>
+        /// 1 商品付费 2会员开通
+        /// </summary>
+        /// <value></value>
+        public int OrderType { get; set; }
+
+    }
+    /// <summary>
     /// 订单查询
     /// </summary>
-    public class OrderSearchRequest:Common.Page.PageParameter
+    public class OrderSearchRequest : Common.Page.PageParameter
     {
         /// <summary>
         /// 搜索字段

+ 58 - 0
gx_api/GxPress/Model/GxPress.Result/Order/OrderResult.cs

@@ -0,0 +1,58 @@
+using System.Collections.Generic;
+
+namespace GxPress.Result.Order
+{
+    /// <summary>
+    /// 订单返回
+    /// </summary>
+    public class OrderResult
+    {
+
+    }
+    /// <summary>
+    /// 财务中心
+    /// </summary>
+    public class OrderFinanceResult<T>
+    {
+        /// <summary>
+        /// 数据集合
+        /// </summary>
+        /// <value></value>
+        public IEnumerable<T> Items { get; set; }
+        /// <summary>
+        /// 显示价格
+        /// </summary>
+        /// <value></value>
+        public decimal ShowPrice { get; set; }
+        /// <summary>
+        /// 总额
+        /// </summary>
+        /// <value></value>
+        public decimal AllPrice { get; set; }
+        /// <summary>
+        /// 订单数量
+        /// </summary>
+        /// <value></value>
+        public int AllOrderCount { get; set; }
+        /// <summary>
+        /// VIP用户数
+        /// </summary>
+        /// <value></value>
+        public int VipUserCount { get; set; }
+        /// <summary>
+        /// Vip总额
+        /// </summary>
+        /// <value></value>
+        public decimal VipAllPrice { get; set; }
+        /// <summary>
+        /// Vip订单数量
+        /// </summary>
+        /// <value></value>
+        public int VipAllOrderCount { get; set; }
+        /// <summary>
+        /// 总数量
+        /// </summary>
+        /// <value></value>
+        public int Total { get; set; }
+    }
+}

+ 52 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/Order/OrderRepository.cs

@@ -2,12 +2,14 @@ using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
 using AutoMapper;
+using Dapper;
 using Datory;
 using GxPress.Common.AppOptions;
 using GxPress.Common.Page;
 using GxPress.Common.Tools;
 using GxPress.Repository.Interface.Order;
 using GxPress.Request.Order;
+using GxPress.Result.Order;
 using Microsoft.Extensions.Options;
 
 namespace GxPress.Repository.Implement.Order
@@ -15,10 +17,13 @@ namespace GxPress.Repository.Implement.Order
     public class OrderRepository : IOrderRepository
     {
         private readonly Repository<Entity.Order.Order> _repository;
-
         private readonly IMapper _mapper;
+        private readonly string _connectionString;
+        private readonly string _databaseTypestr;
         public OrderRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
         {
+            _databaseTypestr = dbOptionsAccessor.CurrentValue.DatabaseType;
+            _connectionString = dbOptionsAccessor.CurrentValue.ConnectionString;
             var databaseType = StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
             var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
             _repository = new Repository<Entity.Order.Order>(database);
@@ -52,5 +57,51 @@ namespace GxPress.Repository.Implement.Order
             result.Items = await _repository.GetAllAsync(query.ForPage(request.Page, request.PerPage));
             return result;
         }
+        /// <summary>
+        /// 财务中心
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<OrderFinanceResult<Entity.Order.Order>> GetAllOrderFinnceAsync(OrderFinanceSearchRequest request)
+        {
+            var result = new OrderFinanceResult<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 (request.OrderType > 0)
+                query.Where(nameof(Entity.Order.Order.OrderType), request.OrderType);
+            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.ShowPrice = await _repository.SumAsync(nameof(Entity.Order.Order.Price), query);
+            //集合
+            result.Items = await _repository.GetAllAsync(query.ForPage(request.Page, request.PerPage));
+            //所有价格
+            result.AllPrice = await _repository.SumAsync(nameof(Entity.Order.Order.Price));
+            //订单数
+            result.AllOrderCount = await _repository.CountAsync(Q.Where(nameof(Entity.Order.Order.Id), ">", 0));
+            //VIP人数
+            var databaseType = _databaseTypestr.ToEnum<DatabaseType>(DatabaseType.MySql);
+            var database = new Database(databaseType, _connectionString);
+            var connection = database.GetConnection();
+            var sql = $"select count(1) from tede_user where IsVip=1 and id in(select userid from tede_order)";
+            result.VipUserCount = await connection.ExecuteScalarAsync<int>(sql);
+            // Vip总额
+            sql = $" select Sum(Price) from tede_order where UserId IN(select Id from tede_user where  IsVip=1)";
+            result.VipAllPrice = await connection.ExecuteScalarAsync<int>(sql);
+            //VIP订单数
+            sql = $" select count(1) from tede_order where UserId IN(select Id from tede_user where  IsVip=1)";
+            result.VipAllOrderCount = await connection.ExecuteScalarAsync<int>(sql);
+            return result;
+        }
     }
 }

+ 17 - 2
gx_api/GxPress/Repository/GxPress.Repository.Interface/Order/IOrderRepository.cs

@@ -1,9 +1,24 @@
+using System.Threading.Tasks;
 using Datory;
+using GxPress.Common.Page;
+using GxPress.Request.Order;
+using GxPress.Result.Order;
 
 namespace GxPress.Repository.Interface.Order
 {
-    public interface IOrderRepository: IRepository
+    public interface IOrderRepository : IRepository
     {
-         
+        /// <summary>
+        /// 查询订单
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        Task<PagedList<Entity.Order.Order>> GetAllOrderAsync(OrderSearchRequest request);
+        /// <summary>
+        /// 财务中心
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        Task<OrderFinanceResult<Entity.Order.Order>> GetAllOrderFinnceAsync(OrderFinanceSearchRequest request);
     }
 }