From 7804a59bcc39adf496344c8e47d052a3a98938d6 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 19 Feb 2022 18:39:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8A=E6=97=A5=E4=B8=9A=E7=BB=A9=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=B8=9A=E7=BB=A9=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWY.Client/APIServices/StatisticsService.cs | 9 ++++++--- BBWY.Client/ViewModels/Order/OrderListViewModel.cs | 10 +++++----- BBWY.Client/Views/Order/OrderList.xaml | 4 ++-- BBWY.Server.API/Controllers/StatisticsController.cs | 4 ++-- BBWY.Server.Business/Statistics/StatisticsBusiness.cs | 9 +++++---- .../Request/Statistics/ToDayOrderAchievementRequest.cs | 10 ++++++++-- ...ievementResponse.cs => OrderAchievementResponse.cs} | 2 +- 7 files changed, 29 insertions(+), 19 deletions(-) rename BBWY.Server.Model/Dto/Response/Statistics/{ToDayOrderAchievementResponse.cs => OrderAchievementResponse.cs} (96%) diff --git a/BBWY.Client/APIServices/StatisticsService.cs b/BBWY.Client/APIServices/StatisticsService.cs index df806421..22d7d3c7 100644 --- a/BBWY.Client/APIServices/StatisticsService.cs +++ b/BBWY.Client/APIServices/StatisticsService.cs @@ -1,6 +1,7 @@ using BBWY.Client.Models; using BBWY.Common.Http; using BBWY.Common.Models; +using System; using System.Net.Http; namespace BBWY.Client.APIServices @@ -16,11 +17,13 @@ namespace BBWY.Client.APIServices /// 今日业绩统计 /// /// - public ApiResponse GetTodayAchievementStatistics() + public ApiResponse GetTodayAchievementStatistics(DateTime startTime, DateTime endTime) { - return SendRequest(globalContext.BBYWApiHost, "Api/Statistics/GetTodayAchievementStatistics", new + return SendRequest(globalContext.BBYWApiHost, "Api/Statistics/GetOrderAchievementStatistics", new { - ShopId = globalContext.User.Shop.ShopId + globalContext.User.Shop.ShopId, + startTime, + endTime }, null, HttpMethod.Post); } diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs index d7afa335..2d73a25c 100644 --- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs +++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs @@ -108,7 +108,7 @@ namespace BBWY.Client.ViewModels { PageIndex = 1; Task.Factory.StartNew(() => LoadOrder(1)); - Task.Factory.StartNew(LoadTodayAchievement); + Task.Factory.StartNew(() => LoadTodayAchievement(StartDate, EndDate)); }); CopyTextCommand = new RelayCommand(s => Clipboard.SetText(s)); CopyOrderWaybillCommand = new RelayCommand(o => Clipboard.SetText(o.WaybillNo)); @@ -118,12 +118,12 @@ namespace BBWY.Client.ViewModels StartDate = DateTime.Now.Date.AddDays(d * -1); PageIndex = 1; Task.Factory.StartNew(() => LoadOrder(1)); - Task.Factory.StartNew(LoadTodayAchievement); + Task.Factory.StartNew(() => LoadTodayAchievement(StartDate, EndDate)); }); OrderPageIndexChangedCommand = new RelayCommand(p => { Task.Factory.StartNew(() => LoadOrder(p.PageIndex)); - Task.Factory.StartNew(LoadTodayAchievement); + Task.Factory.StartNew(() => LoadTodayAchievement(StartDate, EndDate)); }); DecodeConsigneeCommand = new RelayCommand(DecodeConsignee); ChooseStorageTypeCommand = new RelayCommand(ChooseStorageType); @@ -187,9 +187,9 @@ namespace BBWY.Client.ViewModels IsLoading = false; } - private void LoadTodayAchievement() + private void LoadTodayAchievement(DateTime startTime, DateTime endTime) { - var response = statisticsService.GetTodayAchievementStatistics(); + var response = statisticsService.GetTodayAchievementStatistics(startTime, endTime); if (!response.Success) return; _ = response.Data.Map(ToDayOrderAchievement); diff --git a/BBWY.Client/Views/Order/OrderList.xaml b/BBWY.Client/Views/Order/OrderList.xaml index 04b5194f..bf1028aa 100644 --- a/BBWY.Client/Views/Order/OrderList.xaml +++ b/BBWY.Client/Views/Order/OrderList.xaml @@ -154,9 +154,9 @@ - - + + diff --git a/BBWY.Server.API/Controllers/StatisticsController.cs b/BBWY.Server.API/Controllers/StatisticsController.cs index 77e453cd..9aebfb87 100644 --- a/BBWY.Server.API/Controllers/StatisticsController.cs +++ b/BBWY.Server.API/Controllers/StatisticsController.cs @@ -21,9 +21,9 @@ namespace BBWY.Server.API.Controllers /// /// [HttpPost] - public ToDayOrderAchievementResponse GetTodayAchievementStatistics(ToDayOrderAchievementRequest request) + public OrderAchievementResponse GetOrderAchievementStatistics([FromBody] OrderAchievementRequest request) { - return statisticsBusiness.GetTodayAchievementStatistics(request); + return statisticsBusiness.GetOrderAchievementStatistics(request); } } } diff --git a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs index 6312178e..1e886422 100644 --- a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs +++ b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs @@ -17,15 +17,16 @@ namespace BBWY.Server.Business invalidOrderStateList = new List() { Enums.OrderState.待付款, Enums.OrderState.已取消 }; } - public ToDayOrderAchievementResponse GetTodayAchievementStatistics(ToDayOrderAchievementRequest request) + public OrderAchievementResponse GetOrderAchievementStatistics(OrderAchievementRequest request) { - var today = DateTime.Now.Date; + request.EndTime = request.EndTime.Date.AddDays(1); var response = fsql.Select().LeftJoin((o, oc) => o.Id == oc.OrderId) .Where((o, oc) => o.ShopId == request.ShopId && o.OrderState != null && !invalidOrderStateList.Contains(o.OrderState.Value) && - o.StartTime >= today) - .ToAggregate((o, oc) => new ToDayOrderAchievementResponse() + o.StartTime >= request.StartTime && + o.StartTime < request.EndTime) + .ToAggregate((o, oc) => new OrderAchievementResponse() { OrderCount = o.Count(), Profit = oc.Sum(oc.Key.Profit), diff --git a/BBWY.Server.Model/Dto/Request/Statistics/ToDayOrderAchievementRequest.cs b/BBWY.Server.Model/Dto/Request/Statistics/ToDayOrderAchievementRequest.cs index f73c1444..bbf9408e 100644 --- a/BBWY.Server.Model/Dto/Request/Statistics/ToDayOrderAchievementRequest.cs +++ b/BBWY.Server.Model/Dto/Request/Statistics/ToDayOrderAchievementRequest.cs @@ -1,7 +1,13 @@ -namespace BBWY.Server.Model.Dto +using System; + +namespace BBWY.Server.Model.Dto { - public class ToDayOrderAchievementRequest + public class OrderAchievementRequest { public long ShopId { get; set; } + + public DateTime StartTime { get; set; } + + public DateTime EndTime { get; set; } } } diff --git a/BBWY.Server.Model/Dto/Response/Statistics/ToDayOrderAchievementResponse.cs b/BBWY.Server.Model/Dto/Response/Statistics/OrderAchievementResponse.cs similarity index 96% rename from BBWY.Server.Model/Dto/Response/Statistics/ToDayOrderAchievementResponse.cs rename to BBWY.Server.Model/Dto/Response/Statistics/OrderAchievementResponse.cs index 4160fbd3..075f6a3b 100644 --- a/BBWY.Server.Model/Dto/Response/Statistics/ToDayOrderAchievementResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Statistics/OrderAchievementResponse.cs @@ -2,7 +2,7 @@ namespace BBWY.Server.Model.Dto { - public class ToDayOrderAchievementResponse + public class OrderAchievementResponse { ///