Browse Source

Added GetPercentOfTotaPayment

Added an action named GetPercentOfTotaPayment for sales by payment method (Paypal, demo, etc). Still need development
pull/110/head
malik masis 5 years ago
parent
commit
fdf246661d
  1. 1
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs
  2. 10
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentDto.cs
  3. 7
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentInput.cs
  4. 5
      services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationAutoMapperProfile.cs
  5. 12
      services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs
  6. 4
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs
  7. 15
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs
  8. 8
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs
  9. 37
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json

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

@ -18,5 +18,6 @@ public interface IOrderAppService : IApplicationService
Task SetAsShippedAsync(Guid id);
Task<PagedResultDto<OrderDto>> GetListPagedAsync(PagedAndSortedResultRequestDto input);
Task<List<TopSellingDto>> GetTopSellingAsync(TopSellingInput input);
Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(PaymentInput input);
}

10
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentDto.cs

@ -0,0 +1,10 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EShopOnAbp.OrderingService.Orders;
public class PaymentDto : EntityDto<Guid>
{
public int CountOfPaymentMethod { get; set; }
public string PaymentMethod { get; set; }
}

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

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

5
services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationAutoMapperProfile.cs

@ -11,9 +11,10 @@ namespace EShopOnAbp.OrderingService
{
CreateMap<Address, OrderAddressDto>();
CreateMap<Buyer, BuyerDto>();
CreateMap<OrderItem, OrderItemDto>();
CreateMap<OrderItem, TopSellingDto > ();
CreateMap<OrderItem, TopSellingDto>();
CreateMap<Order, PaymentDto>();
CreateMap<Order, OrderDto>()
.Ignore(q => q.Address)

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

@ -78,6 +78,18 @@ public class OrderAppService : ApplicationService, IOrderAppService
return ObjectMapper.Map<List<OrderItem>, List<TopSellingDto>>(orderItems);
}
public async Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(PaymentInput input)
{
ISpecification<Order> specification = SpecificationFactory.Create(input.Filter);
var orderItems = await _orderRepository.GetPercentOfTotalPayment(specification);
var paymentList = new List<PaymentDto>();
foreach (var item in orderItems)
{
paymentList.Add(new PaymentDto() { PaymentMethod = item.PaymentMethod, CountOfPaymentMethod = orderItems.Count });
}
return paymentList;//TODO ObjectMapper.Map<List<Order>, List<PaymentDto>>(orderItems);
}
public async Task<OrderDto> GetByOrderNoAsync(int orderNo)
{
var order = await _orderRepository.GetByOrderNoAsync(orderNo);

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

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

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

@ -72,6 +72,21 @@ public class EfCoreOrderRepository : EfCoreRepository<OrderingServiceDbContext,
.ToList();
}
public async Task<List<Order>> GetPercentOfTotalPayment(
ISpecification<Order> spec,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(spec.ToExpression())
.GroupBy(p => p.PaymentMethod)
.Select(p=>p.OrderBy(p=>p.Id).FirstOrDefault())//TODO list
//TODO
//.SelectMany(p=>p)
//.Select(p => new PaymentDto { CountOfPaymentMethod = p.Count(), PaymentMethod = p.Key })
//.OrderBy(p => p.CountOfPaymentMethod)
.ToListAsync();
}
public async Task<Order> GetByOrderNoAsync(
int orderNo,
bool includeDetails = true,

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

@ -57,6 +57,14 @@ public partial class OrderClientProxy : ClientProxyBase<IOrderAppService>, IOrde
});
}
public virtual async Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(PaymentInput input)
{
return await RequestAsync<List<PaymentDto>>(nameof(GetPercentOfTotalPaymentAsync), new ClientProxyRequestTypeValue
{
{ typeof(PaymentInput), 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

@ -232,6 +232,43 @@
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"
},
"GetPercentOfTotalPaymentAsyncByInput": {
"uniqueName": "GetPercentOfTotalPaymentAsyncByInput",
"name": "GetPercentOfTotalPaymentAsync",
"httpMethod": "GET",
"url": "api/ordering/order/percent-of-total-payment",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "EShopOnAbp.OrderingService.Orders.PaymentInput, EShopOnAbp.OrderingService.Application.Contracts",
"type": "EShopOnAbp.OrderingService.Orders.PaymentInput",
"typeSimple": "EShopOnAbp.OrderingService.Orders.PaymentInput",
"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.PaymentDto>",
"typeSimple": "[EShopOnAbp.OrderingService.Orders.PaymentDto]"
},
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"
},
"GetByOrderNoAsyncByOrderNo": {
"uniqueName": "GetByOrderNoAsyncByOrderNo",
"name": "GetByOrderNoAsync",

Loading…
Cancel
Save