Browse Source

Added a new action named GetCountOfTotalOrderStatus

Returns count of total order status for each one
pull/110/head
malik masis 5 years ago
parent
commit
f231d11b38
  1. 1
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs
  2. 11
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusDto.cs
  3. 7
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs
  4. 18
      services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs
  5. 5
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs
  6. 11
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs
  7. 8
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs
  8. 37
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json

1
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs

@ -19,5 +19,6 @@ public interface IOrderAppService : IApplicationService
Task<PagedResultDto<OrderDto>> GetListPagedAsync(PagedAndSortedResultRequestDto input);
Task<List<TopSellingDto>> GetTopSellingAsync(TopSellingInput input);
Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(PaymentInput input);
Task<List<OrderStatusDto>> GetCountOfTotalOrderStatusAsync(OrderStatusInput input);
}

11
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusDto.cs

@ -0,0 +1,11 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderStatusDto : EntityDto<Guid>
{
public int CountOfStatusOrder { get; set; }
public string OrderStatus { get; set; }
public int OrderStatusId { get; set; }
}

7
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs

@ -0,0 +1,7 @@
namespace EShopOnAbp.OrderingService.Orders
{
public class OrderStatusInput
{
public string Filter { get; set; }
}
}

18
services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs

@ -85,6 +85,13 @@ public class OrderAppService : ApplicationService, IOrderAppService
return CreatePaymentDtoMapping(orders);
}
public async Task<List<OrderStatusDto>> GetCountOfTotalOrderStatusAsync(OrderStatusInput input)
{
ISpecification<Order> specification = SpecificationFactory.Create(input.Filter);
var orders = await _orderRepository.GetCountOfTotalOrderStatus(specification, true);
return CreateOrderStatusDtoMapping(orders);
}
public async Task<OrderDto> GetByOrderNoAsync(int orderNo)
{
var order = await _orderRepository.GetByOrderNoAsync(orderNo);
@ -183,4 +190,15 @@ public class OrderAppService : ApplicationService, IOrderAppService
payments.ForEach(p => p.RateOfPaymentMethod *= rate);
return payments;
}
private List<OrderStatusDto> CreateOrderStatusDtoMapping(List<Order> orders)
{
var orderStatus = orders
.GroupBy(p => p.OrderStatus.Name)
.Select(p => new OrderStatusDto { CountOfStatusOrder = p.Count(), OrderStatus = p.Key, OrderStatusId = OrderStatus.FromName(p.Key).Id })
.OrderBy(p => p.CountOfStatusOrder)
.ToList();
return orderStatus;
}
}

5
services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs

@ -29,6 +29,11 @@ public interface IOrderRepository : IRepository<Order, Guid>
ISpecification<Order> spec,
CancellationToken cancellationToken = default);
Task<List<Order>> GetCountOfTotalOrderStatus(
ISpecification<Order> spec,
bool includeDetails = true,
CancellationToken cancellationToken = default);
Task<Order> GetByOrderNoAsync(int orderNo,
bool includeDetails = true,
CancellationToken cancellationToken = default);

11
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs

@ -81,6 +81,17 @@ public class EfCoreOrderRepository : EfCoreRepository<OrderingServiceDbContext,
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<Order>> GetCountOfTotalOrderStatus(
ISpecification<Order> spec,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(spec.ToExpression())
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<Order> GetByOrderNoAsync(
int orderNo,
bool includeDetails = true,

8
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs

@ -65,6 +65,14 @@ public partial class OrderClientProxy : ClientProxyBase<IOrderAppService>, IOrde
});
}
public virtual async Task<List<OrderStatusDto>> GetCountOfTotalOrderStatusAsync(OrderStatusInput input)
{
return await RequestAsync<List<OrderStatusDto>>(nameof(GetCountOfTotalOrderStatusAsync), new ClientProxyRequestTypeValue
{
{ typeof(OrderStatusInput), input }
});
}
public virtual async Task<OrderDto> GetByOrderNoAsync(int orderNo)
{
return await RequestAsync<OrderDto>(nameof(GetByOrderNoAsync), new ClientProxyRequestTypeValue

37
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json

@ -269,6 +269,43 @@
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"
},
"GetCountOfTotalOrderStatusAsyncByInput": {
"uniqueName": "GetCountOfTotalOrderStatusAsyncByInput",
"name": "GetCountOfTotalOrderStatusAsync",
"httpMethod": "GET",
"url": "api/ordering/order/count-of-total-order-status",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "EShopOnAbp.OrderingService.Orders.OrderStatusInput, EShopOnAbp.OrderingService.Application.Contracts",
"type": "EShopOnAbp.OrderingService.Orders.OrderStatusInput",
"typeSimple": "EShopOnAbp.OrderingService.Orders.OrderStatusInput",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "Filter",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
}
],
"returnValue": {
"type": "System.Collections.Generic.List<EShopOnAbp.OrderingService.Orders.OrderStatusDto>",
"typeSimple": "[EShopOnAbp.OrderingService.Orders.OrderStatusDto]"
},
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"
},
"GetByOrderNoAsyncByOrderNo": {
"uniqueName": "GetByOrderNoAsyncByOrderNo",
"name": "GetByOrderNoAsync",

Loading…
Cancel
Save