From aa1fa7f20e316bda9d668418888ece9b4130201b Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sun, 11 Sep 2022 15:42:17 +0800 Subject: [PATCH] 1 --- BBWY.Client/APIServices/StatisticsService.cs | 5 ++++ .../OrderCountStatisticsResponse.cs | 9 ++++++ .../ViewModels/Order/OrderListViewModel.cs | 21 ++++++++++++-- BBWY.Client/Views/Order/OrderList.xaml | 24 ++++++++++++--- .../Controllers/StatisticsController.cs | 14 +++++++++ BBWY.Server.Business/Order/OrderBusiness.cs | 2 +- .../Statistics/StatisticsBusiness.cs | 29 +++++++++++++++++++ .../OrderCountStatisticsResponse.cs | 9 ++++++ 8 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 BBWY.Client/Models/APIModel/Response/Statistics/OrderCountStatisticsResponse.cs create mode 100644 BBWY.Server.Model/Dto/Response/Statistics/OrderCountStatisticsResponse.cs diff --git a/BBWY.Client/APIServices/StatisticsService.cs b/BBWY.Client/APIServices/StatisticsService.cs index 22d7d3c7..5d81087e 100644 --- a/BBWY.Client/APIServices/StatisticsService.cs +++ b/BBWY.Client/APIServices/StatisticsService.cs @@ -27,5 +27,10 @@ namespace BBWY.Client.APIServices }, null, HttpMethod.Post); } + + public ApiResponse GetOrderCountStatistics(long shopId, DateTime startDate, DateTime endDate) + { + return SendRequest(globalContext.BBYWApiHost, "Api/Statistics/GetOrderCountStatistics", $"shopId={shopId}&startDate={startDate:yyyy-MM-dd}&endDate={endDate:yyyy-MM-dd}", null, HttpMethod.Get); + } } } diff --git a/BBWY.Client/Models/APIModel/Response/Statistics/OrderCountStatisticsResponse.cs b/BBWY.Client/Models/APIModel/Response/Statistics/OrderCountStatisticsResponse.cs new file mode 100644 index 00000000..0be31401 --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/Statistics/OrderCountStatisticsResponse.cs @@ -0,0 +1,9 @@ +namespace BBWY.Client.Models +{ + public class OrderCountStatisticsResponse + { + public long WaitPurchaseCount { get; set; } + + public long ExceptionCount { get; set; } + } +} diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs index 1b823f25..436982dd 100644 --- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs +++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs @@ -50,6 +50,8 @@ namespace BBWY.Client.ViewModels private bool includeExceptionOrder; private decimal currentConditionsTotalProfit; private string searchServiceId; + private long waitPurchaseOrderCount; + private long exceptionOrderCount; public IList OrderList { get; set; } @@ -137,6 +139,9 @@ namespace BBWY.Client.ViewModels /// public bool IncludeExceptionOrder { get => includeExceptionOrder; set { Set(ref includeExceptionOrder, value); } } + public long WaitPurchaseOrderCount { get => waitPurchaseOrderCount; set { Set(ref waitPurchaseOrderCount, value); } } + public long ExceptionOrderCount { get => exceptionOrderCount; set { Set(ref exceptionOrderCount , value); } } + public OrderListViewModel(OrderService orderService, StatisticsService statisticsService, AfterOrderService afterOrderService, GlobalContext globalContext, ChoosePurchaseSchemeViewModel choosePurchaseSchemeViewModel) { random = new Random(); @@ -200,6 +205,7 @@ namespace BBWY.Client.ViewModels EditAfterSaleOrderRefundPurchaseAmountCommand = new RelayCommand(EditAfterSaleOrderRefundPurchaseAmount); FindAfterSaleOrderCommand = new RelayCommand(FindAfterSaleOrder); SearchOrderCommand.Execute(null); + Task.Factory.StartNew(LoadOrderCount); } private void InitSearchParam() @@ -239,8 +245,7 @@ namespace BBWY.Client.ViewModels { InitSearchParam(); this.OrderState = orderState; - //if (orderState != null) - // IncludeAfterOrder = false; + Task.Factory.StartNew(LoadOrderCount); Task.Factory.StartNew(() => LoadOrder(1)); //选择状态查询订单 } @@ -248,6 +253,7 @@ namespace BBWY.Client.ViewModels { InitSearchParam(); IncludeExceptionOrder = true; + Task.Factory.StartNew(LoadOrderCount); Task.Factory.StartNew(() => LoadOrder(1)); } @@ -255,6 +261,7 @@ namespace BBWY.Client.ViewModels { InitSearchParam(); IncludeAfterOrder = true; + Task.Factory.StartNew(LoadOrderCount); Task.Factory.StartNew(() => LoadOrder(1)); } @@ -333,7 +340,6 @@ namespace BBWY.Client.ViewModels LoadNormalOrder(pageIndex); } - private void LoadNormalOrder(int pageIndex) { IsLoading = true; @@ -419,6 +425,15 @@ namespace BBWY.Client.ViewModels _ = response.Data.Map(ToDayOrderAchievement); } + private void LoadOrderCount() + { + var response = statisticsService.GetOrderCountStatistics(globalContext.User.Shop.ShopId, DateTime.Now.Date.AddMonths(-1), DateTime.Now.Date); + if (!response.Success) + return; + WaitPurchaseOrderCount = response.Data.WaitPurchaseCount; + ExceptionOrderCount = response.Data.ExceptionCount; + } + private void DecodeConsignee(Order order) { var plaintextMobile = string.Empty; diff --git a/BBWY.Client/Views/Order/OrderList.xaml b/BBWY.Client/Views/Order/OrderList.xaml index f25e672f..8c146025 100644 --- a/BBWY.Client/Views/Order/OrderList.xaml +++ b/BBWY.Client/Views/Order/OrderList.xaml @@ -75,10 +75,18 @@ - + Command="{Binding SetOrderStateCommand}" CommandParameter="{x:Static cmodel:OrderState.等待采购}"> + + + + + + + - + Command="{Binding SetIncludeExceptionOrderCommand}"> + + + + + + + + /// bbwy订单选项卡数量统计 + /// + /// + /// + /// + /// + [HttpGet] + public OrderCountStatisticsResponse GetOrderCountStatistics([FromQuery]long shopId, [FromQuery]DateTime startDate, [FromQuery]DateTime endDate) + { + return statisticsBusiness.GetOrderCountStatistics(shopId, startDate, endDate); + } } } diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs index a28f565a..c7ad6641 100644 --- a/BBWY.Server.Business/Order/OrderBusiness.cs +++ b/BBWY.Server.Business/Order/OrderBusiness.cs @@ -62,7 +62,7 @@ namespace BBWY.Server.Business .WhereIf(searchOrderRequest.EndDate != null, (o, ocs, oct) => o.StartTime <= searchOrderRequest.EndDate) .WhereIf(searchOrderRequest.IncludeExceptionOrder, (o, ocs, oct) => o.StorageType != null && o.StorageType != Enums.StorageType.SD && (oct.PurchaseAmount == 0M || - oct.PurchaseAmount + oct.DeliveryExpressFreight < o.OrderSellerPrice + o.FreightPrice)) + oct.PurchaseAmount + oct.DeliveryExpressFreight > o.OrderSellerPrice + o.FreightPrice)) //.WhereIf(searchOrderRequest.IsContainsAfterSaleOrder != null, (o, ocs, oct) => o.IsAfterSaleOrder == searchOrderRequest.IsContainsAfterSaleOrder) .WhereIf(searchOrderRequest.OnlyDF, (o, ocs, oct) => o.StorageType == Enums.StorageType.代发) .WhereIf(searchOrderRequest.ExcludeCanceled, (o, ocs, oct) => o.OrderState != Enums.OrderState.已取消) diff --git a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs index a1f6eac0..02b3b003 100644 --- a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs +++ b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs @@ -244,5 +244,34 @@ namespace BBWY.Server.Business }; } + + /// + /// bbwy订单选项卡数量统计 + /// + /// + /// + /// + /// + public OrderCountStatisticsResponse GetOrderCountStatistics(long shopId, DateTime startDate, DateTime endDate) + { + startDate = startDate.Date; + endDate = endDate.Date.AddDays(1).AddSeconds(-1); + var response = new OrderCountStatisticsResponse(); + response.WaitPurchaseCount = fsql.Select().Where(o => o.ShopId == shopId && + o.StartTime >= startDate && + o.StartTime <= endDate && + o.OrderState == Enums.OrderState.等待采购).Count(); + + response.ExceptionCount = fsql.Select().LeftJoin((o, oc) => o.Id == oc.OrderId) + .Where((o, oc) => o.StartTime >= startDate && + o.StartTime <= endDate && + o.StorageType != null && o.StorageType != Enums.StorageType.SD && + (oc.PurchaseAmount == 0M || + oc.PurchaseAmount + + oc.DeliveryExpressFreight > + o.OrderSellerPrice + + o.FreightPrice)).Count(); + return response; + } } } diff --git a/BBWY.Server.Model/Dto/Response/Statistics/OrderCountStatisticsResponse.cs b/BBWY.Server.Model/Dto/Response/Statistics/OrderCountStatisticsResponse.cs new file mode 100644 index 00000000..74409229 --- /dev/null +++ b/BBWY.Server.Model/Dto/Response/Statistics/OrderCountStatisticsResponse.cs @@ -0,0 +1,9 @@ +namespace BBWY.Server.Model.Dto +{ + public class OrderCountStatisticsResponse + { + public long WaitPurchaseCount { get; set; } + + public long ExceptionCount { get; set; } + } +}