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<OrderCountStatisticsResponse> GetOrderCountStatistics(long shopId, DateTime startDate, DateTime endDate) + { + return SendRequest<OrderCountStatisticsResponse>(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<Order> OrderList { get; set; } @@ -137,6 +139,9 @@ namespace BBWY.Client.ViewModels /// </summary> 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<AfterSaleOrder>(EditAfterSaleOrderRefundPurchaseAmount); FindAfterSaleOrderCommand = new RelayCommand<object>(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 @@ </MultiBinding> </c:BButton.Foreground> </c:BButton> - <c:BButton Content="等待采购" Width="100" + <c:BButton Width="100" Background="{Binding OrderState,Converter={StaticResource objConverter},ConverterParameter=等待采购:#8080FF:#F2F2F2}" Foreground="{Binding OrderState,Converter={StaticResource objConverter},ConverterParameter=等待采购:White:#4A4A4A}" - Command="{Binding SetOrderStateCommand}" CommandParameter="{x:Static cmodel:OrderState.等待采购}"/> + Command="{Binding SetOrderStateCommand}" CommandParameter="{x:Static cmodel:OrderState.等待采购}"> + <c:BButton.Content> + <TextBlock> + <Run Text="等待采购"/> + <Run Text="{Binding WaitPurchaseOrderCount,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" + Foreground="{StaticResource Text.Pink}"/> + </TextBlock> + </c:BButton.Content> + </c:BButton> <c:BButton Content="待出库" Width="100" Background="{Binding OrderState,Converter={StaticResource objConverter},ConverterParameter=待出库:#8080FF:#F2F2F2}" Foreground="{Binding OrderState,Converter={StaticResource objConverter},ConverterParameter=待出库:White:#4A4A4A}" @@ -103,10 +111,18 @@ Background="{Binding OrderState,Converter={StaticResource objConverter},ConverterParameter=已取消:#8080FF:#F2F2F2}" Foreground="{Binding OrderState,Converter={StaticResource objConverter},ConverterParameter=已取消:White:#4A4A4A}" Command="{Binding SetOrderStateCommand}" CommandParameter="{x:Static cmodel:OrderState.已取消}"/> - <c:BButton Content="异常单" Width="100" + <c:BButton Width="100" Background="{Binding IncludeExceptionOrder,Converter={StaticResource objConverter},ConverterParameter=true:#8080FF:#F2F2F2}" Foreground="{Binding IncludeExceptionOrder,Converter={StaticResource objConverter},ConverterParameter=true:White:#4A4A4A}" - Command="{Binding SetIncludeExceptionOrderCommand}"/> + Command="{Binding SetIncludeExceptionOrderCommand}"> + <c:BButton.Content> + <TextBlock> + <Run Text="异常单"/> + <Run Text="{Binding ExceptionOrderCount,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" + Foreground="{StaticResource Text.Pink}"/> + </TextBlock> + </c:BButton.Content> + </c:BButton> <c:BButton Content="售后单" Width="100" Background="{Binding IncludeAfterOrder,Converter={StaticResource objConverter},ConverterParameter=true:#8080FF:#F2F2F2}" Foreground="{Binding IncludeAfterOrder,Converter={StaticResource objConverter},ConverterParameter=true:White:#4A4A4A}" diff --git a/BBWY.Server.API/Controllers/StatisticsController.cs b/BBWY.Server.API/Controllers/StatisticsController.cs index 1d999daa..e2f27126 100644 --- a/BBWY.Server.API/Controllers/StatisticsController.cs +++ b/BBWY.Server.API/Controllers/StatisticsController.cs @@ -2,6 +2,7 @@ using BBWY.Server.Model.Dto; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using System; using System.Collections.Generic; namespace BBWY.Server.API.Controllers @@ -48,5 +49,18 @@ namespace BBWY.Server.API.Controllers { return statisticsBusiness.XingXiangStatistics(xingXiangSearchOrderRequest); } + + /// <summary> + /// bbwy订单选项卡数量统计 + /// </summary> + /// <param name="shopId"></param> + /// <param name="startDate"></param> + /// <param name="endDate"></param> + /// <returns></returns> + [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 }; } + + /// <summary> + /// bbwy订单选项卡数量统计 + /// </summary> + /// <param name="shopId"></param> + /// <param name="startDate"></param> + /// <param name="endDate"></param> + /// <returns></returns> + 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<Order>().Where(o => o.ShopId == shopId && + o.StartTime >= startDate && + o.StartTime <= endDate && + o.OrderState == Enums.OrderState.等待采购).Count(); + + response.ExceptionCount = fsql.Select<Order, OrderCost>().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; } + } +}