Browse Source

Merge pull request #53 from abpframework/gterdem/ordering_refactor

Create Order flow
pull/54/head
Galip Tolga Erdem 5 years ago
committed by GitHub
parent
commit
20be360938
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj
  2. 9
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicAutoMapperProfile.cs
  3. 3
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs
  4. 28
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs
  5. 14
      services/basket/src/EShopOnAbp.BasketService.Domain/Orders/OrderPlacedEventHandler.cs
  6. 5
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs
  7. 2
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs
  8. 10
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/BuyerDto.cs
  9. 11
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs
  10. 12
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderAddressDto.cs
  11. 10
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderCreateDto.cs
  12. 17
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderDto.cs
  13. 14
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderItemCreateDto.cs
  14. 14
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderItemDto.cs
  15. 14
      services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceAppService.cs
  16. 15
      services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationAutoMapperProfile.cs
  17. 85
      services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs
  18. 4
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en.json
  19. 4
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/tr.json
  20. 21
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceErrorCodes.cs
  21. 11
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/BuyerEto.cs
  22. 3
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderAcceptedEto.cs
  23. 4
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderConstants.cs
  24. 7
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderItemEto.cs
  25. 15
      services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderPlacedEto.cs
  26. 24
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Buyers/Buyer.cs
  27. 13
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/Address.cs
  28. 31
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/Buyer.cs
  29. 8
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/IOrderRepository.cs
  30. 38
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/Order.cs
  31. 5
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/OrderItem.cs
  32. 123
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/OrderManager.cs
  33. 4
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/OrderStatus.cs
  34. 46
      services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/PaymentType.cs
  35. 31
      services/ordering/src/EShopOnAbp.OrderingService.Domain/PaymentRequests/PaymentRequestEventHandler.cs
  36. 4
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs
  37. 22
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderServiceDataSeedContributor.cs
  38. 68
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContext.cs
  39. 240
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.Designer.cs
  40. 94
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.cs
  41. 244
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231135901_Added-ProductCode.Designer.cs
  42. 26
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231135901_Added-ProductCode.cs
  43. 248
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104093641_Added_Order_PaymentRequest_Info.Designer.cs
  44. 47
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104093641_Added_Order_PaymentRequest_Info.cs
  45. 230
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104115822_Removed_Buyer_Domain.Designer.cs
  46. 137
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104115822_Removed_Buyer_Domain.cs
  47. 95
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/OrderingServiceDbContextModelSnapshot.cs
  48. 34
      services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Orders/EfCoreOrderRepository.cs
  49. 34
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs
  50. 8
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.cs
  51. 106
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/Ordering-generate-proxy.json
  52. 53
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderingService-generate-proxy.json
  53. 15
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/SampleClientProxy.Generated.cs
  54. 8
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/SampleClientProxy.cs
  55. 6
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs
  56. 12
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs
  57. 42
      services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/Orders/OrderManager_Tests.cs
  58. 1
      services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs
  59. 2
      services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductDto.cs
  60. 16
      services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentRequests/PaymentRequestProduct.cs

1
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj

@ -28,6 +28,7 @@
<ProjectReference Include="..\..\..\..\services\catalog\src\EShopOnAbp.CatalogService.HttpApi.Client\EShopOnAbp.CatalogService.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\services\basket\src\EShopOnAbp.BasketService.HttpApi.Client\EShopOnAbp.BasketService.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\services\payment\src\EShopOnAbp.PaymentService.HttpApi.Client\EShopOnAbp.PaymentService.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\services\ordering\src\EShopOnAbp.OrderingService.HttpApi.Client\EShopOnAbp.OrderingService.HttpApi.Client.csproj" />
<!-- <ProjectReference Include="..\..\..\..\services\product\src\MyCompanyName.MyProjectName.ProductService.HttpApi.Client\MyCompanyName.MyProjectName.ProductService.HttpApi.Client.csproj" />-->
</ItemGroup>

9
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicAutoMapperProfile.cs

@ -1,6 +1,8 @@
using AutoMapper;
using EShopOnAbp.BasketService;
using EShopOnAbp.OrderingService.Orders;
using EShopOnAbp.PaymentService.PaymentRequests;
using Volo.Abp.AutoMapper;
namespace EShopOnAbp.PublicWeb
{
@ -10,9 +12,16 @@ namespace EShopOnAbp.PublicWeb
{
CreateMap<BasketItemDto, PaymentRequestProductCreationDto>()
.ForMember(p => p.ReferenceId, opts => opts.MapFrom(p => p.ProductId.ToString()))
.ForMember(p => p.Code, opts => opts.MapFrom(p => p.ProductCode))
.ForMember(p => p.Name, opts => opts.MapFrom(p => p.ProductName))
.ForMember(p => p.UnitPrice, opts => opts.MapFrom(p => p.TotalPrice / p.Count))
.ForMember(p => p.Quantity, opts => opts.MapFrom(p => p.Count));
CreateMap<BasketItemDto, OrderItemCreateDto>()
.ForMember(p => p.UnitPrice, opts => opts.MapFrom(q => q.TotalPrice))
.ForMember(p => p.Units, opts => opts.MapFrom(q => q.Count))
.ForMember(p => p.PictureUrl, opts => opts.MapFrom(q => q.ImageName))
.Ignore(q => q.Discount);
}
}
}

3
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs

@ -13,6 +13,7 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using StackExchange.Redis;
using System;
using System.Net.Http.Headers;
using EShopOnAbp.OrderingService;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.AspNetCore.Authentication.OpenIdConnect;
@ -48,6 +49,7 @@ namespace EShopOnAbp.PublicWeb
typeof(EShopOnAbpSharedLocalizationModule),
typeof(CatalogServiceHttpApiClientModule),
typeof(BasketServiceHttpApiClientModule),
typeof(OrderingServiceHttpApiClientModule),
typeof(AbpAspNetCoreSignalRModule),
typeof(PaymentServiceHttpApiClientModule),
typeof(AbpAutoMapperModule)
@ -125,6 +127,7 @@ namespace EShopOnAbp.PublicWeb
options.Scope.Add("BasketService");
options.Scope.Add("CatalogService");
options.Scope.Add("PaymentService");
options.Scope.Add("OrderingService");
});
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);

28
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs

@ -6,7 +6,9 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.OrderingService.Orders;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Users;
@ -16,16 +18,22 @@ namespace EShopOnAbp.PublicWeb.Pages;
public class PaymentModel : AbpPageModel
{
private readonly IPaymentRequestAppService _paymentRequestAppService;
private readonly IOrderAppService _orderAppService;
private readonly UserBasketProvider _userBasketProvider;
private readonly UserAddressProvider _userAddressProvider;
private readonly EShopOnAbpPublicWebPaymentOptions _publicWebPaymentOptions;
public PaymentModel(
IPaymentRequestAppService paymentRequestAppService,
IOrderAppService orderAppService,
UserBasketProvider userBasketProvider,
UserAddressProvider userAddressProvider,
IOptions<EShopOnAbpPublicWebPaymentOptions> publicWebPaymentOptions)
{
_paymentRequestAppService = paymentRequestAppService;
_userBasketProvider = userBasketProvider;
_userAddressProvider = userAddressProvider;
_orderAppService = orderAppService;
_publicWebPaymentOptions = publicWebPaymentOptions.Value;
}
@ -40,9 +48,16 @@ public class PaymentModel : AbpPageModel
Logger.LogInformation($"PaymentId: {model.SelectedPaymentId}");
var basket = await _userBasketProvider.GetBasketAsync();
var placedOrder = await _orderAppService.CreateAsync(new OrderCreateDto()
{
PaymentTypeId = 1, // Paypal
Address = GetUserAddress(model.SelectedAddressId),
Products = ObjectMapper.Map<List<BasketItemDto>, List<OrderItemCreateDto>>(basket.Items)
});
var paymentRequest = await _paymentRequestAppService.CreateAsync(new PaymentRequestCreationDto
{
OrderId = placedOrder.Id.ToString(),
BuyerId = CurrentUser.GetId().ToString(),
Currency = EShopOnAbpPaymentConsts.Currency,
Products = ObjectMapper.Map<List<BasketItemDto>, List<PaymentRequestProductCreationDto>>(basket.Items)
@ -58,6 +73,19 @@ public class PaymentModel : AbpPageModel
return Redirect(response.CheckoutLink);
}
private OrderAddressDto GetUserAddress(int selectedAddressId)
{
var address = _userAddressProvider.GetDemoAddresses().First(q => q.Id == selectedAddressId);
return new OrderAddressDto
{
City = address.City,
Country = address.Country,
Description = address.Description,
Street = address.Street,
ZipCode = address.ZipCode
};
}
public class PaymentPageViewModel
{
public int SelectedAddressId { get; set; }

14
services/basket/src/EShopOnAbp.BasketService.Domain/Orders/OrderAcceptedEventHandler.cs → services/basket/src/EShopOnAbp.BasketService.Domain/Orders/OrderPlacedEventHandler.cs

@ -2,25 +2,25 @@
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Uow;
namespace EShopOnAbp.BasketService.Orders
{
public class OrderAcceptedEventHandler :
IDistributedEventHandler<OrderAcceptedEto>,
ITransientDependency
public class OrderPlacedEventHandler : IDistributedEventHandler<OrderPlacedEto>, ITransientDependency
{
private readonly IBasketRepository _basketRepository;
public OrderAcceptedEventHandler(IBasketRepository basketRepository)
public OrderPlacedEventHandler(IBasketRepository basketRepository)
{
_basketRepository = basketRepository;
}
public async Task HandleEventAsync(OrderAcceptedEto eventData)
[UnitOfWork]
public async Task HandleEventAsync(OrderPlacedEto eventData)
{
var basket = await _basketRepository.GetAsync(eventData.BuyerId);
var basket = await _basketRepository.GetAsync(eventData.Buyer.BuyerId.GetValueOrDefault());
basket.Clear();
await _basketRepository.UpdateAsync(basket);
}
}
}
}

5
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs

@ -217,9 +217,10 @@ namespace EShopOnAbp.IdentityService.DbMigrations
scopes: commonScopes.Union(new[]
{
"AdministrationService",
"CatalogService", // Consider removing this service
"CatalogService",
"BasketService",
"PaymentService"
"PaymentService",
"OrderingService"
}),
grantTypes: new[] { "hybrid" },
secret: "1q2w3e*".Sha256(),

2
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs

@ -2,6 +2,6 @@
{
public class OrderingServiceRemoteServiceConsts
{
public const string RemoteServiceName = "OrderingService";
public const string RemoteServiceName = "Ordering";
}
}

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

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

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

@ -0,0 +1,11 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
namespace EShopOnAbp.OrderingService.Orders;
public interface IOrderAppService : IApplicationService
{
Task<OrderDto> CreateAsync(OrderCreateDto input);
Task<OrderDto> GetAsync(Guid id);
}

12
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderAddressDto.cs

@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderAddressDto
{
public string Description { get; set; }
[Required]public string Street { get; set; }
[Required]public string City { get; set; }
[Required]public string Country { get; set; }
[Required]public string ZipCode { get; set; }
}

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

@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderCreateDto
{
public int PaymentTypeId { get; set; }
public OrderAddressDto Address { get; set; } = new();
public List<OrderItemCreateDto> Products { get; set; } = new();
}

17
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderDto.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderDto : EntityDto<Guid>
{
public DateTime OrderDate { get; set; }
public int OrderStatusId { get; set; }
public string OrderStatus { get; set; }
public int PaymentTypeId { get; set; }
public string PaymentType { get; set; }
public BuyerDto Buyer { get; set; }
public OrderAddressDto Address { get; set; } = new();
public List<OrderItemDto> Items { get; set; } = new();
}

14
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderItemCreateDto.cs

@ -0,0 +1,14 @@
using System;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderItemCreateDto
{
public Guid ProductId { get; set; }
public string ProductCode { get; set; }
public string ProductName { get; set; }
public string PictureUrl { get; set; }
public decimal UnitPrice { get; set; }
public decimal Discount { get; set; }
public int Units { get; set; }
}

14
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderItemDto.cs

@ -0,0 +1,14 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderItemDto : EntityDto<Guid>
{
public Guid ProductId { get; set; }
public string ProductName { get; set; }
public string PictureUrl { get; set; }
public decimal UnitPrice { get; set; }
public decimal Discount { get; set; }
public int Units { get; set; }
}

14
services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceAppService.cs

@ -1,14 +0,0 @@
using EShopOnAbp.OrderingService.Localization;
using Volo.Abp.Application.Services;
namespace EShopOnAbp.OrderingService
{
public abstract class OrderingServiceAppService : ApplicationService
{
protected OrderingServiceAppService()
{
LocalizationResource = typeof(OrderingServiceResource);
ObjectMapperContext = typeof(OrderingServiceApplicationModule);
}
}
}

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

@ -1,4 +1,7 @@
using AutoMapper;
using EShopOnAbp.OrderingService.Buyers;
using EShopOnAbp.OrderingService.Orders;
using Volo.Abp.AutoMapper;
namespace EShopOnAbp.OrderingService
{
@ -6,9 +9,15 @@ namespace EShopOnAbp.OrderingService
{
public OrderingServiceApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Address, OrderAddressDto>();
CreateMap<Buyer, BuyerDto>();
CreateMap<OrderItem, OrderItemDto>();
CreateMap<Order, OrderDto>()
.Ignore(q => q.Address)
.Ignore(q => q.Items)
.Ignore(q => q.Buyer);
}
}
}

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

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EShopOnAbp.OrderingService.Buyers;
using EShopOnAbp.OrderingService.Localization;
using Volo.Abp.Application.Services;
using Volo.Abp.Users;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderAppService : ApplicationService, IOrderAppService
{
private readonly OrderManager _orderManager;
private readonly IOrderRepository _orderRepository;
public OrderAppService(OrderManager orderManager,
IOrderRepository orderRepository
)
{
_orderManager = orderManager;
_orderRepository = orderRepository;
LocalizationResource = typeof(OrderingServiceResource);
ObjectMapperContext = typeof(OrderingServiceApplicationModule);
}
public async Task<OrderDto> GetAsync(Guid id)
{
var order = await _orderRepository.GetAsync(id);
return await CreateOrderDtoMappingAsync(order);
}
public async Task<OrderDto> CreateAsync(OrderCreateDto input)
{
var orderItems = GetProductListTuple(input.Products);
var placedOrder = await _orderManager.CreateOrderAsync
(
paymentTypeId: input.PaymentTypeId,
buyerId: CurrentUser.GetId(),
buyerName: CurrentUser.Name,
buyerEmail: CurrentUser.Email,
orderItems: orderItems,
addressStreet: input.Address.Street,
addressCity: input.Address.City,
addressCountry: input.Address.Country,
addressZipCode: input.Address.ZipCode,
addressDescription: input.Address.Description
);
return await CreateOrderDtoMappingAsync(placedOrder);
}
private List<(Guid productId, string productName, string productCode, decimal unitPrice, decimal discount, string
pictureUrl, int units
)> GetProductListTuple(List<OrderItemCreateDto> products)
{
var orderItems =
new List<(Guid productId, string productName, string productCode, decimal unitPrice, decimal discount,
string pictureUrl, int
units)>();
foreach (var product in products)
{
orderItems.Add((product.ProductId, product.ProductName, product.ProductCode, product.UnitPrice,
product.Discount, product.PictureUrl, product.Units));
}
return orderItems;
}
private async Task<OrderDto> CreateOrderDtoMappingAsync(Order placedOrder)
{
return new OrderDto()
{
Address = ObjectMapper.Map<Address, OrderAddressDto>(placedOrder.Address),
Items = ObjectMapper.Map<List<OrderItem>, List<OrderItemDto>>(placedOrder.OrderItems),
Buyer = ObjectMapper.Map<Buyer, BuyerDto>(placedOrder.Buyer),
Id = placedOrder.Id,
OrderDate = placedOrder.OrderDate,
OrderStatus = placedOrder.OrderStatus.Name,
OrderStatusId = placedOrder.OrderStatus.Id,
PaymentType = placedOrder.PaymentType.Name,
PaymentTypeId = placedOrder.PaymentType.Id
};
}
}

4
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en.json

@ -4,8 +4,10 @@
"MyAccount": "My account",
"SamplePageMessage": "A sample page for the OrderingService module",
"Ordering:00001": "Possible values for Order status: {0}",
"Ordering:00011": "Possible values for Payment types: {0}",
"Ordering:00002": "Invalid number of units",
"Ordering:00003": "Invalid discount",
"Ordering:00004": "The total of order item is lower than applied discount"
"Ordering:00004": "The total of order item is lower than applied discount",
"Ordering:01001": "Order with {0} id could not be found!"
}
}

4
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/tr.json

@ -4,8 +4,10 @@
"MyAccount": "Hesabım",
"SamplePageMessage": "OrderingService modulünden örnek bir sayfa",
"Ordering:00001": "Muhtemel Sipariş durum değerleri: {0}",
"Ordering:00011": "Muhtemel Ödeme türleri: {0}",
"Ordering:00002": "Ürün adedi negatif olamaz",
"Ordering:00003": "Geçersiz indirim",
"Ordering:00004": "Ürünlerin toplam bedeli, uygulanan indirimden daha az olamaz"
"Ordering:00004": "Ürünlerin toplam bedeli, uygulanan indirimden daha az olamaz",
"Ordering:01001": "{0} ID numaralı ürün bulunamadı!"
}
}

21
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceErrorCodes.cs

@ -1,11 +1,12 @@
namespace EShopOnAbp.OrderingService
namespace EShopOnAbp.OrderingService;
public static class OrderingServiceErrorCodes
{
public static class OrderingServiceErrorCodes
{
public const string OrderingStatusNotFound = "Ordering:00001";
public const string InvalidUnits = "Ordering:00002";
public const string InvalidDiscount = "Ordering:00003";
public const string InvalidTotalForDiscount = "Ordering:00004";
}
}
public const string OrderingStatusNotFound = "Ordering:00001";
public const string PaymentTypeNotFound = "Ordering:00011";
public const string InvalidUnits = "Ordering:00002";
public const string InvalidDiscount = "Ordering:00003";
public const string InvalidTotalForDiscount = "Ordering:00004";
public const string OrderIdIdNotGuid = "Ordering:01000";
public const string OrderWithIdNotFound = "Ordering:01001";
}

11
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/BuyerEto.cs

@ -0,0 +1,11 @@
using System;
using Volo.Abp.Domain.Entities.Events.Distributed;
namespace EShopOnAbp.OrderingService.Orders;
public class BuyerEto : EtoBase
{
public Guid? BuyerId { get; set; }
public string BuyerEmail { get; set; }
public string BuyerName { get; set; }
}

3
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderAcceptedEto.cs

@ -10,7 +10,8 @@ namespace EShopOnAbp.OrderingService.Orders
public class OrderAcceptedEto : EtoBase
{
public Guid OrderId { get; set; }
public Guid BuyerId { get; set; }
public string PaymentStatus { get; set; }
public BuyerEto Buyer { get; set; }
public List<OrderItemEto> Items { get; set; }
}
}

4
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderConstants.cs

@ -2,6 +2,8 @@
public static class OrderConstants
{
public const int OrderDescriptionMaxLength = 1024;
public const int OrderPaymentTypeNameMaxLength = 128;
public const int OrderStatusNameMaxLength = 256;
public const int PaymentStatusMaxLength = 256;
}

7
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderItemEto.cs

@ -1,15 +1,16 @@
using System;
using Volo.Abp.Domain.Entities.Events.Distributed;
namespace EShopOnAbp.OrderingService.Orders
{
public class OrderItemEto
public class OrderItemEto : EtoBase
{
public Guid ProductId { get; set; }
public string ProductCode { get; set; }
public string ProductName { get; set; }
public string PictureUrl { get; set; }
public decimal UnitPrice { get; set; }
public decimal Discount { get; set; }
public int Units { get; set; }
}
}
}

15
services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Orders/OrderPlacedEto.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus;
namespace EShopOnAbp.OrderingService.Orders;
[EventName("EShopOnAbp.Order.Placed")]
public class OrderPlacedEto : EtoBase
{
public Guid OrderId { get; set; }
public DateTime OrderDate { get; set; }
public BuyerEto Buyer { get; set; }
public List<OrderItemEto> Items { get; set; } = new();
}

24
services/ordering/src/EShopOnAbp.OrderingService.Domain/Buyers/Buyer.cs

@ -1,24 +0,0 @@
using System;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
namespace EShopOnAbp.OrderingService.Buyers;
public class Buyer : AggregateRoot<Guid>
{
public string UserName { get; private set; }
public string Name { get; private set; }
public string PaymentId { get; private set; }
private Buyer()
{
}
public Buyer(Guid id, [NotNull] string userName, [NotNull] string name, [NotNull] string paymentId) : base(id)
{
UserName = Check.NotNullOrEmpty(userName, nameof(userName));
Name = Check.NotNullOrEmpty(name, nameof(name));
PaymentId = Check.NotNullOrEmpty(paymentId, nameof(paymentId));
}
}

13
services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/Address.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Volo.Abp;
using Volo.Abp.Domain.Values;
namespace EShopOnAbp.OrderingService.Orders;
@ -15,21 +16,21 @@ public class Address : ValueObject
{
}
public Address(string street, string city, string description, string country, string zipcode)
public Address(string street, string city, string country, string zipcode, string description)
{
Street = street;
City = city;
Street = Check.NotNullOrEmpty(street, nameof(street));
City = Check.NotNullOrEmpty(city, nameof(city));
Country = Check.NotNullOrEmpty(country, nameof(country));
ZipCode = Check.NotNullOrEmpty(zipcode, nameof(zipcode));
Description = description;
Country = country;
ZipCode = zipcode;
}
protected override IEnumerable<object> GetAtomicValues()
{
yield return Street;
yield return City;
yield return Description;
yield return Country;
yield return ZipCode;
yield return Description;
}
}

31
services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/Buyer.cs

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using Volo.Abp;
using Volo.Abp.Domain.Values;
namespace EShopOnAbp.OrderingService.Orders;
public class Buyer: ValueObject
{
public Guid? Id { get; private set; }
public string Name { get; private set; }
public string Email { get; private set; }
private Buyer()
{
}
public Buyer(string email, string name, Guid? id)
{
Name = Check.NotNullOrEmpty(name, nameof(name));
Email = Check.NotNullOrEmpty(email, nameof(email));
Id = id;
}
protected override IEnumerable<object> GetAtomicValues()
{
yield return Id;
yield return Name;
yield return Email;
}
}

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

@ -0,0 +1,8 @@
using System;
using Volo.Abp.Domain.Repositories;
namespace EShopOnAbp.OrderingService.Orders;
public interface IOrderRepository : IRepository<Order, Guid>
{
}

38
services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/Order.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EShopOnAbp.OrderingService.Buyers;
using Volo.Abp.Domain.Entities;
namespace EShopOnAbp.OrderingService.Orders;
@ -8,10 +9,13 @@ namespace EShopOnAbp.OrderingService.Orders;
public class Order : AggregateRoot<Guid>
{
private int _orderStatusId;
private int _paymentTypeId;
public DateTime OrderDate { get; private set; }
public Guid? BuyerId { get; private set; }
public string Description { get; private set; }
public string PaymentMethodToken { get; private set; } // PaymentId or token for validation
public PaymentType PaymentType { get; private set; }
public Guid? PaymentRequestId { get; private set; }
public string PaymentStatus { get; private set; }
public Buyer Buyer { get; private set; }
public Address Address { get; private set; }
public OrderStatus OrderStatus { get; private set; }
public List<OrderItem> OrderItems { get; private set; }
@ -20,18 +24,29 @@ public class Order : AggregateRoot<Guid>
{
}
public Order(Guid id, Address address, Guid? buyerId = null, string paymentMethodToken = null) : base()
internal Order(Guid id, Buyer buyer, Address address,PaymentType paymentType, Guid? paymentRequestId = null) : base(id)
{
_orderStatusId = OrderStatus.Submitted.Id;
_orderStatusId = OrderStatus.Placed.Id;
_paymentTypeId = paymentType.Id;
OrderDate = DateTime.UtcNow;
Buyer = buyer;
Address = address;
BuyerId = buyerId;
PaymentMethodToken = paymentMethodToken;
PaymentRequestId = paymentRequestId;
PaymentStatus = "Waiting"; // TODO: magic string
OrderItems = new List<OrderItem>();
}
public void AddOrderItem(Guid productId, string productName, decimal unitPrice, decimal discount, string pictureUrl,
int units = 1)
internal Order SetOrderAccepted(Guid paymentRequestId, string paymentRequestStatus)
{
PaymentRequestId = paymentRequestId;
PaymentStatus = paymentRequestStatus;
OrderStatus = OrderStatus.Paid;
return this;
}
public Order AddOrderItem(Guid id, Guid productId, string productName, string productCode, decimal unitPrice,
decimal discount, string pictureUrl, int units = 1)
{
var existingOrderForProduct = OrderItems.SingleOrDefault(o => o.ProductId == productId);
@ -46,9 +61,12 @@ public class Order : AggregateRoot<Guid>
}
else
{
var orderItem = new OrderItem(productId, productName, unitPrice, discount, pictureUrl, units);
var orderItem = new OrderItem(id, productId, productName, productCode, unitPrice, discount, pictureUrl,
units);
OrderItems.Add(orderItem);
}
return this;
}
public decimal GetTotal()

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

@ -7,6 +7,7 @@ namespace EShopOnAbp.OrderingService.Orders;
public class OrderItem : Entity<Guid>
{
public string ProductCode { get; private set; }
public string ProductName { get; private set; }
public string PictureUrl { get; private set; }
public decimal UnitPrice { get; private set; }
@ -16,7 +17,8 @@ public class OrderItem : Entity<Guid>
protected OrderItem() { }
public OrderItem(Guid productId, [NotNull]string productName, decimal unitPrice, decimal discount, [CanBeNull]string pictureUrl, int units = 1)
public OrderItem(Guid id, Guid productId, [NotNull]string productName, [NotNull]string productCode, decimal unitPrice, decimal discount, [CanBeNull]string pictureUrl, int units = 1)
: base(id)
{
if (units <= 0)
{
@ -30,6 +32,7 @@ public class OrderItem : Entity<Guid>
ProductId = productId;
ProductName = Check.NotNullOrEmpty(productName, nameof(productName));
ProductCode = Check.NotNullOrEmpty(productCode, nameof(productCode));
UnitPrice = unitPrice;
Discount = discount;
Units = units;

123
services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/OrderManager.cs

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EShopOnAbp.OrderingService.Buyers;
using Volo.Abp;
using Volo.Abp.Domain.Services;
using Volo.Abp.EventBus.Distributed;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderManager : DomainService
{
private readonly IOrderRepository _orderRepository;
private readonly IDistributedEventBus _distributedEventBus;
public OrderManager(
IOrderRepository orderRepository,
IDistributedEventBus distributedEventBus)
{
_orderRepository = orderRepository;
_distributedEventBus = distributedEventBus;
}
public async Task<Order> CreateOrderAsync(
int paymentTypeId,
Guid buyerId,
string buyerName,
string buyerEmail,
List<(Guid productId, string productName, string productCode, decimal unitPrice, decimal discount, string
pictureUrl, int units)>
orderItems,
string addressStreet,
string addressCity,
string addressCountry,
string addressZipCode,
string addressDescription = null
)
{
// Create new order
Order order = new Order(
id: GuidGenerator.Create(),
buyer: new Buyer(buyerEmail, buyerName, buyerId),
address: new Address(street: addressStreet,
city: addressCity,
country: addressCountry,
zipcode: addressZipCode,
description: addressDescription),
paymentType: PaymentType.From(paymentTypeId)
);
// Add new order items
foreach (var orderItem in orderItems)
{
order.AddOrderItem(
id: GuidGenerator.Create(),
productId: orderItem.productId,
productName: orderItem.productName,
productCode: orderItem.productCode,
unitPrice: orderItem.unitPrice,
discount: orderItem.discount,
pictureUrl: orderItem.pictureUrl,
units: orderItem.units
);
}
var placedOrder = await _orderRepository.InsertAsync(order, true);
// Publish Order placed event
await _distributedEventBus.PublishAsync(new OrderPlacedEto
{
OrderId = placedOrder.Id,
OrderDate = placedOrder.OrderDate,
Buyer = GetBuyerEto(order.Buyer),
Items = GetProductItemEtoList(order.OrderItems)
});
return placedOrder;
}
public async Task<Order> AcceptOrderAsync(Guid orderId, Guid paymentRequestId, string paymentRequestStatus)
{
var order = await _orderRepository.GetAsync(orderId);
if (order == null)
{
throw new BusinessException(OrderingServiceErrorCodes.OrderWithIdNotFound)
.WithData("OrderId", orderId);
}
order.SetOrderAccepted(paymentRequestId, paymentRequestStatus);
return await _orderRepository.UpdateAsync(order, autoSave: true);
}
private BuyerEto GetBuyerEto(Buyer buyer)
{
return new BuyerEto
{
BuyerEmail = buyer.Email,
BuyerName = buyer.Name,
BuyerId = buyer.Id
};
}
private List<OrderItemEto> GetProductItemEtoList(List<OrderItem> orderItems)
{
List<OrderItemEto> etoList = new List<OrderItemEto>();
foreach (var oItem in orderItems)
{
etoList.Add(new OrderItemEto()
{
Discount = oItem.Discount,
PictureUrl = oItem.PictureUrl,
ProductCode = oItem.ProductCode,
ProductId = oItem.ProductId,
ProductName = oItem.ProductName,
UnitPrice = oItem.UnitPrice,
Units = oItem.Units
});
}
return etoList;
}
}

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

@ -7,7 +7,7 @@ namespace EShopOnAbp.OrderingService.Orders;
public class OrderStatus: Enumeration
{
public static OrderStatus Submitted = new OrderStatus(1, nameof(Submitted).ToLowerInvariant());
public static OrderStatus Placed = new OrderStatus(1, nameof(Placed).ToLowerInvariant());
public static OrderStatus AwaitingValidation = new OrderStatus(2, nameof(AwaitingValidation).ToLowerInvariant());
public static OrderStatus StockConfirmed = new OrderStatus(3, nameof(StockConfirmed).ToLowerInvariant());
public static OrderStatus Paid = new OrderStatus(4, nameof(Paid).ToLowerInvariant());
@ -20,7 +20,7 @@ public class OrderStatus: Enumeration
}
public static IEnumerable<OrderStatus> List() =>
new[] { Submitted, AwaitingValidation, StockConfirmed, Paid, Shipped, Cancelled };
new[] { Placed, AwaitingValidation, StockConfirmed, Paid, Shipped, Cancelled };
public static OrderStatus FromName(string name)
{

46
services/ordering/src/EShopOnAbp.OrderingService.Domain/Orders/PaymentType.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp;
namespace EShopOnAbp.OrderingService.Buyers;
public class PaymentType : Enumeration
{
public static PaymentType Paypal = new PaymentType(1, nameof(Paypal).ToLowerInvariant());
public static PaymentType Demo = new PaymentType(2, nameof(Paypal).ToLowerInvariant());
public PaymentType(int id, string name) : base(id, name)
{
}
public static IEnumerable<PaymentType> List() =>
new[] {Paypal, Demo};
public static PaymentType FromName(string name)
{
var state = List()
.SingleOrDefault(s => String.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase));
if (state == null)
{
throw new BusinessException(OrderingServiceErrorCodes.PaymentTypeNotFound)
.WithData("PaymentType", String.Join(",", List().Select(s => s.Name)));
}
return state;
}
public static PaymentType From(int id)
{
var state = List().SingleOrDefault(s => s.Id == id);
if (state == null)
{
throw new BusinessException(OrderingServiceErrorCodes.PaymentTypeNotFound)
.WithData("PaymentType", String.Join(",", List().Select(s => s.Name)));
}
return state;
}
}

31
services/ordering/src/EShopOnAbp.OrderingService.Domain/PaymentRequests/PaymentRequestEventHandler.cs

@ -3,33 +3,46 @@ using EShopOnAbp.PaymentService.PaymentRequests;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus.Distributed;
namespace EShopOnAbp.OrderingService.PaymentRequests
{
public class PaymentRequestEventHandler :
IDistributedEventHandler<PaymentRequestCompletedEto>,
public class PaymentRequestEventHandler : IDistributedEventHandler<PaymentRequestCompletedEto>,
ITransientDependency
{
private readonly IDistributedEventBus _eventBus;
private readonly OrderManager _orderManager;
public PaymentRequestEventHandler(IDistributedEventBus eventBus)
public PaymentRequestEventHandler(IDistributedEventBus eventBus, OrderManager orderManager)
{
_eventBus = eventBus;
_orderManager = orderManager;
}
public async Task HandleEventAsync(PaymentRequestCompletedEto eventData)
{
// TODO: Insert Order here.
//throw new NotImplementedException();
if (!Guid.TryParse(eventData.OrderId, out var orderId))
{
throw new BusinessException(OrderingServiceErrorCodes.OrderIdIdNotGuid);
}
var acceptedOrder = await _orderManager.AcceptOrderAsync(
orderId, eventData.PaymentRequestId, eventData.State.ToString()
);
await _eventBus.PublishAsync(new OrderAcceptedEto
{
Items = eventData.Products.Select(MapProductToOrderItem).ToList(),
BuyerId = Guid.Parse(eventData.BuyerId),
OrderId = Guid.Empty, // TODO: Inserted OrderId,
PaymentStatus = acceptedOrder.PaymentStatus,
Buyer = new BuyerEto
{
BuyerId = acceptedOrder.Buyer.Id,
BuyerEmail = acceptedOrder.Buyer.Email,
BuyerName = acceptedOrder.Buyer.Name
},
OrderId = acceptedOrder.Id
});
}
@ -42,4 +55,4 @@ namespace EShopOnAbp.OrderingService.PaymentRequests
};
}
}
}
}

4
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs

@ -1,5 +1,4 @@
using EShopOnAbp.OrderingService.Buyers;
using EShopOnAbp.OrderingService.Orders;
using EShopOnAbp.OrderingService.Orders;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
@ -12,7 +11,6 @@ namespace EShopOnAbp.OrderingService.EntityFrameworkCore
/* Add DbSet for each Aggregate Root here. Example:
* DbSet<Question> Questions { get; }
*/
DbSet<Buyer> Buyers { get; }
DbSet<Order> Orders { get; }
}
}

22
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderServiceDataSeedContributor.cs

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.OrderingService.Buyers;
using EShopOnAbp.OrderingService.Orders;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
@ -24,27 +25,24 @@ public class OrderServiceDataSeedContributor : IDataSeedContributor, ITransientD
public async Task SeedAsync(DataSeedContext context)
{
await SeedOrderStatusAsync();
await SeedPaymentTypesAsync();
}
private async Task SeedOrderStatusAsync()
private async Task SeedPaymentTypesAsync()
{
if (!await _dbContext.Set<OrderStatus>().AnyAsync())
if (!await _dbContext.Set<PaymentType>().AnyAsync())
{
_dbContext.Set<OrderStatus>().AddRange(GetOrderStatusList());
await _dbContext.Set<PaymentType>().AddRangeAsync(PaymentType.List());
await _dbContext.SaveChangesAsync();
}
}
private List<OrderStatus> GetOrderStatusList()
private async Task SeedOrderStatusAsync()
{
return new List<OrderStatus>
if (!await _dbContext.Set<OrderStatus>().AnyAsync())
{
OrderStatus.Submitted,
OrderStatus.AwaitingValidation,
OrderStatus.StockConfirmed,
OrderStatus.Paid,
OrderStatus.Shipped,
OrderStatus.Cancelled
};
await _dbContext.Set<OrderStatus>().AddRangeAsync(OrderStatus.List());
await _dbContext.SaveChangesAsync();
}
}
}

68
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContext.cs

@ -11,7 +11,6 @@ namespace EShopOnAbp.OrderingService.EntityFrameworkCore
[ConnectionStringName(OrderingServiceDbProperties.ConnectionStringName)]
public class OrderingServiceDbContext : AbpDbContext<OrderingServiceDbContext>, IOrderingServiceDbContext
{
public virtual DbSet<Buyer> Buyers { get; set; }
public virtual DbSet<Order> Orders { get; set; }
public OrderingServiceDbContext(DbContextOptions<OrderingServiceDbContext> options)
@ -27,36 +26,48 @@ namespace EShopOnAbp.OrderingService.EntityFrameworkCore
builder.ConfigureOrderingService();
/* Configure your own tables/entities inside here */
builder.Entity<Buyer>(b =>
{
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "Buyers", OrderingServiceDbProperties.DbSchema);
b.ConfigureByConvention(); //auto configure for the base class props
b.Property(q => q.UserName).IsRequired();
b.Property(q => q.Name).IsRequired();
b.Property(q => q.PaymentId).IsRequired();
});
builder.Entity<Order>(b =>
{
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "Orders", OrderingServiceDbProperties.DbSchema);
b.ConfigureByConvention(); //auto configure for the base class props
b.Property(q => q.PaymentStatus).HasMaxLength(OrderConstants.PaymentStatusMaxLength);
b.OwnsOne(o => o.Address, a => { a.WithOwner(); });
b.OwnsOne(o => o.Buyer, a => { a.WithOwner(); });
b.Property<int>("_orderStatusId").UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("OrderStatusId")
.IsRequired();
b.Property(q => q.Description).HasMaxLength(OrderConstants.OrderDescriptionMaxLength).IsRequired(false);
b.Property<int>("_paymentTypeId").UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("PaymentTypeId")
.IsRequired();
b.HasOne<Buyer>().WithMany().HasForeignKey(q => q.BuyerId).IsRequired(false);
b.HasOne(q => q.OrderStatus).WithMany().HasForeignKey("_orderStatusId");
b.HasOne(q => q.PaymentType).WithMany().HasForeignKey("_paymentTypeId");
b.Navigation(q => q.OrderItems).UsePropertyAccessMode(PropertyAccessMode.Property);
});
b.HasIndex(q => q.Id);
b.HasIndex(q => q.BuyerId);
builder.Entity<OrderItem>(b =>
{
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "OrderItems",
OrderingServiceDbProperties.DbSchema);
b.ConfigureByConvention(); //auto configure for the base class props
b.Property<Guid>("OrderId").IsRequired();
b.Property(q => q.ProductId).IsRequired();
b.Property(q => q.ProductCode).IsRequired();
b.Property(q => q.ProductName).IsRequired();
b.Property(q => q.Discount).IsRequired();
b.Property(q => q.UnitPrice).IsRequired();
b.Property(q => q.Units).IsRequired();
b.Property(q => q.PictureUrl).IsRequired(false);
});
// Consider removing persistancy to db or seeding
builder.Entity<OrderStatus>(b =>
{
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "OrderStatus",
@ -64,28 +75,33 @@ namespace EShopOnAbp.OrderingService.EntityFrameworkCore
b.ConfigureByConvention(); //auto configure for the base class props
b.HasKey(q => q.Id);
b.Property(q => q.Id)
.HasDefaultValue(1)
.ValueGeneratedNever()
.IsRequired();
b.Property(o => o.Name)
.HasMaxLength(OrderConstants.OrderStatusNameMaxLength)
.IsRequired();
});
builder.Entity<OrderItem>(b =>
builder.Entity<PaymentType>(b =>
{
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "OrderItems",
b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "PaymentTypes",
OrderingServiceDbProperties.DbSchema);
b.ConfigureByConvention(); //auto configure for the base class props
b.Property<Guid>("OrderId").IsRequired();
b.Property(q => q.ProductId).IsRequired();
b.Property(q => q.ProductName).IsRequired();
b.Property(q => q.Discount).IsRequired();
b.Property(q => q.UnitPrice).IsRequired();
b.Property(q => q.Units).IsRequired();
b.Property(q => q.PictureUrl).IsRequired(false);
b.HasKey(q => q.Id);
b.Property(q => q.Id)
.HasDefaultValue(1)
.ValueGeneratedNever()
.IsRequired();
b.Property(o => o.Name)
.HasMaxLength(OrderConstants.OrderPaymentTypeNameMaxLength)
.IsRequired();
});
}
}

240
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.Designer.cs

@ -0,0 +1,240 @@
// <auto-generated />
using System;
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Volo.Abp.EntityFrameworkCore;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
[DbContext(typeof(OrderingServiceDbContext))]
[Migration("20211231094501_Updated-Order-and-Buyer")]
partial class UpdatedOrderandBuyer
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql)
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("_paymentTypeId")
.HasColumnType("integer")
.HasColumnName("PaymentTypeId");
b.HasKey("Id");
b.HasIndex("_paymentTypeId");
b.ToTable("Buyers", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.PaymentType", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id");
b.ToTable("PaymentTypes", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<Guid?>("BuyerId")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("PaymentMethodToken")
.HasColumnType("text");
b.Property<int>("_orderStatusId")
.HasColumnType("integer")
.HasColumnName("OrderStatusId");
b.HasKey("Id");
b.HasIndex("BuyerId");
b.HasIndex("Id");
b.HasIndex("_orderStatusId");
b.ToTable("Orders", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<decimal>("Discount")
.HasColumnType("numeric");
b.Property<Guid>("OrderId")
.HasColumnType("uuid");
b.Property<string>("PictureUrl")
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("UnitPrice")
.HasColumnType("numeric");
b.Property<int>("Units")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.ToTable("OrderItems", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderStatus", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.ToTable("OrderStatus", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.PaymentType", "PaymentType")
.WithMany()
.HasForeignKey("_paymentTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PaymentType");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.Buyer", null)
.WithMany()
.HasForeignKey("BuyerId");
b.HasOne("EShopOnAbp.OrderingService.Orders.OrderStatus", "OrderStatus")
.WithMany()
.HasForeignKey("_orderStatusId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Address", "Address", b1 =>
{
b1.Property<Guid>("OrderId")
.HasColumnType("uuid");
b1.Property<string>("City")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnType("text");
b1.Property<string>("Description")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnType("text");
b1.Property<string>("ZipCode")
.HasColumnType("text");
b1.HasKey("OrderId");
b1.ToTable("Orders");
b1.WithOwner()
.HasForeignKey("OrderId");
});
b.Navigation("Address");
b.Navigation("OrderStatus");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Orders.Order", null)
.WithMany("OrderItems")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Navigation("OrderItems");
});
#pragma warning restore 612, 618
}
}
}

94
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231094501_Updated-Order-and-Buyer.cs

@ -0,0 +1,94 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
public partial class UpdatedOrderandBuyer : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Description",
table: "Orders");
migrationBuilder.DropColumn(
name: "PaymentId",
table: "Buyers");
migrationBuilder.RenameColumn(
name: "UserName",
table: "Buyers",
newName: "Email");
migrationBuilder.AddColumn<int>(
name: "PaymentTypeId",
table: "Buyers",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "PaymentTypes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PaymentTypes", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Buyers_PaymentTypeId",
table: "Buyers",
column: "PaymentTypeId");
migrationBuilder.AddForeignKey(
name: "FK_Buyers_PaymentTypes_PaymentTypeId",
table: "Buyers",
column: "PaymentTypeId",
principalTable: "PaymentTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Buyers_PaymentTypes_PaymentTypeId",
table: "Buyers");
migrationBuilder.DropTable(
name: "PaymentTypes");
migrationBuilder.DropIndex(
name: "IX_Buyers_PaymentTypeId",
table: "Buyers");
migrationBuilder.DropColumn(
name: "PaymentTypeId",
table: "Buyers");
migrationBuilder.RenameColumn(
name: "Email",
table: "Buyers",
newName: "UserName");
migrationBuilder.AddColumn<string>(
name: "Description",
table: "Orders",
type: "character varying(1024)",
maxLength: 1024,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "PaymentId",
table: "Buyers",
type: "text",
nullable: false,
defaultValue: "");
}
}
}

244
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231135901_Added-ProductCode.Designer.cs

@ -0,0 +1,244 @@
// <auto-generated />
using System;
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Volo.Abp.EntityFrameworkCore;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
[DbContext(typeof(OrderingServiceDbContext))]
[Migration("20211231135901_Added-ProductCode")]
partial class AddedProductCode
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql)
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("_paymentTypeId")
.HasColumnType("integer")
.HasColumnName("PaymentTypeId");
b.HasKey("Id");
b.HasIndex("_paymentTypeId");
b.ToTable("Buyers", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.PaymentType", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id");
b.ToTable("PaymentTypes", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<Guid?>("BuyerId")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("PaymentMethodToken")
.HasColumnType("text");
b.Property<int>("_orderStatusId")
.HasColumnType("integer")
.HasColumnName("OrderStatusId");
b.HasKey("Id");
b.HasIndex("BuyerId");
b.HasIndex("Id");
b.HasIndex("_orderStatusId");
b.ToTable("Orders", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<decimal>("Discount")
.HasColumnType("numeric");
b.Property<Guid>("OrderId")
.HasColumnType("uuid");
b.Property<string>("PictureUrl")
.HasColumnType("text");
b.Property<string>("ProductCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("UnitPrice")
.HasColumnType("numeric");
b.Property<int>("Units")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.ToTable("OrderItems", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderStatus", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.ToTable("OrderStatus", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.PaymentType", "PaymentType")
.WithMany()
.HasForeignKey("_paymentTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PaymentType");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.Buyer", null)
.WithMany()
.HasForeignKey("BuyerId");
b.HasOne("EShopOnAbp.OrderingService.Orders.OrderStatus", "OrderStatus")
.WithMany()
.HasForeignKey("_orderStatusId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Address", "Address", b1 =>
{
b1.Property<Guid>("OrderId")
.HasColumnType("uuid");
b1.Property<string>("City")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnType("text");
b1.Property<string>("Description")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnType("text");
b1.Property<string>("ZipCode")
.HasColumnType("text");
b1.HasKey("OrderId");
b1.ToTable("Orders");
b1.WithOwner()
.HasForeignKey("OrderId");
});
b.Navigation("Address");
b.Navigation("OrderStatus");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Orders.Order", null)
.WithMany("OrderItems")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Navigation("OrderItems");
});
#pragma warning restore 612, 618
}
}
}

26
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211231135901_Added-ProductCode.cs

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
public partial class AddedProductCode : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ProductCode",
table: "OrderItems",
type: "text",
nullable: false,
defaultValue: "");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProductCode",
table: "OrderItems");
}
}
}

248
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104093641_Added_Order_PaymentRequest_Info.Designer.cs

@ -0,0 +1,248 @@
// <auto-generated />
using System;
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Volo.Abp.EntityFrameworkCore;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
[DbContext(typeof(OrderingServiceDbContext))]
[Migration("20220104093641_Added_Order_PaymentRequest_Info")]
partial class Added_Order_PaymentRequest_Info
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql)
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("_paymentTypeId")
.HasColumnType("integer")
.HasColumnName("PaymentTypeId");
b.HasKey("Id");
b.HasIndex("_paymentTypeId");
b.ToTable("Buyers", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.PaymentType", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id");
b.ToTable("PaymentTypes", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<Guid?>("BuyerId")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("PaymentRequestId")
.HasColumnType("uuid");
b.Property<string>("PaymentStatus")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<int>("_orderStatusId")
.HasColumnType("integer")
.HasColumnName("OrderStatusId");
b.HasKey("Id");
b.HasIndex("BuyerId");
b.HasIndex("Id");
b.HasIndex("_orderStatusId");
b.ToTable("Orders", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<decimal>("Discount")
.HasColumnType("numeric");
b.Property<Guid>("OrderId")
.HasColumnType("uuid");
b.Property<string>("PictureUrl")
.HasColumnType("text");
b.Property<string>("ProductCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("UnitPrice")
.HasColumnType("numeric");
b.Property<int>("Units")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.ToTable("OrderItems", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderStatus", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.ToTable("OrderStatus", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.PaymentType", "PaymentType")
.WithMany()
.HasForeignKey("_paymentTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PaymentType");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.Buyer", null)
.WithMany()
.HasForeignKey("BuyerId");
b.HasOne("EShopOnAbp.OrderingService.Orders.OrderStatus", "OrderStatus")
.WithMany()
.HasForeignKey("_orderStatusId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Address", "Address", b1 =>
{
b1.Property<Guid>("OrderId")
.HasColumnType("uuid");
b1.Property<string>("City")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnType("text");
b1.Property<string>("Description")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnType("text");
b1.Property<string>("ZipCode")
.HasColumnType("text");
b1.HasKey("OrderId");
b1.ToTable("Orders");
b1.WithOwner()
.HasForeignKey("OrderId");
});
b.Navigation("Address");
b.Navigation("OrderStatus");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Orders.Order", null)
.WithMany("OrderItems")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Navigation("OrderItems");
});
#pragma warning restore 612, 618
}
}
}

47
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104093641_Added_Order_PaymentRequest_Info.cs

@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
public partial class Added_Order_PaymentRequest_Info : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PaymentMethodToken",
table: "Orders");
migrationBuilder.AddColumn<Guid>(
name: "PaymentRequestId",
table: "Orders",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "PaymentStatus",
table: "Orders",
type: "character varying(256)",
maxLength: 256,
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PaymentRequestId",
table: "Orders");
migrationBuilder.DropColumn(
name: "PaymentStatus",
table: "Orders");
migrationBuilder.AddColumn<string>(
name: "PaymentMethodToken",
table: "Orders",
type: "text",
nullable: true);
}
}
}

230
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104115822_Removed_Buyer_Domain.Designer.cs

@ -0,0 +1,230 @@
// <auto-generated />
using System;
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Volo.Abp.EntityFrameworkCore;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
[DbContext(typeof(OrderingServiceDbContext))]
[Migration("20220104115822_Removed_Buyer_Domain")]
partial class Removed_Buyer_Domain
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql)
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.PaymentType", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id");
b.ToTable("PaymentTypes", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("PaymentRequestId")
.HasColumnType("uuid");
b.Property<string>("PaymentStatus")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<int>("_orderStatusId")
.HasColumnType("integer")
.HasColumnName("OrderStatusId");
b.Property<int>("_paymentTypeId")
.HasColumnType("integer")
.HasColumnName("PaymentTypeId");
b.HasKey("Id");
b.HasIndex("_orderStatusId");
b.HasIndex("_paymentTypeId");
b.ToTable("Orders", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<decimal>("Discount")
.HasColumnType("numeric");
b.Property<Guid>("OrderId")
.HasColumnType("uuid");
b.Property<string>("PictureUrl")
.HasColumnType("text");
b.Property<string>("ProductCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("UnitPrice")
.HasColumnType("numeric");
b.Property<int>("Units")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.ToTable("OrderItems", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderStatus", b =>
{
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.ToTable("OrderStatus", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Orders.OrderStatus", "OrderStatus")
.WithMany()
.HasForeignKey("_orderStatusId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EShopOnAbp.OrderingService.Buyers.PaymentType", "PaymentType")
.WithMany()
.HasForeignKey("_paymentTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Address", "Address", b1 =>
{
b1.Property<Guid>("OrderId")
.HasColumnType("uuid");
b1.Property<string>("City")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnType("text");
b1.Property<string>("Description")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnType("text");
b1.Property<string>("ZipCode")
.HasColumnType("text");
b1.HasKey("OrderId");
b1.ToTable("Orders");
b1.WithOwner()
.HasForeignKey("OrderId");
});
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Buyer", "Buyer", b1 =>
{
b1.Property<Guid>("OrderId")
.HasColumnType("uuid");
b1.Property<string>("Email")
.HasColumnType("text");
b1.Property<Guid?>("Id")
.HasColumnType("uuid");
b1.Property<string>("Name")
.HasColumnType("text");
b1.HasKey("OrderId");
b1.ToTable("Orders");
b1.WithOwner()
.HasForeignKey("OrderId");
});
b.Navigation("Address");
b.Navigation("Buyer");
b.Navigation("OrderStatus");
b.Navigation("PaymentType");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Orders.Order", null)
.WithMany("OrderItems")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.Navigation("OrderItems");
});
#pragma warning restore 612, 618
}
}
}

137
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20220104115822_Removed_Buyer_Domain.cs

@ -0,0 +1,137 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopOnAbp.OrderingService.Migrations
{
public partial class Removed_Buyer_Domain : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Buyers_BuyerId",
table: "Orders");
migrationBuilder.DropTable(
name: "Buyers");
migrationBuilder.DropIndex(
name: "IX_Orders_BuyerId",
table: "Orders");
migrationBuilder.DropIndex(
name: "IX_Orders_Id",
table: "Orders");
migrationBuilder.RenameColumn(
name: "BuyerId",
table: "Orders",
newName: "Buyer_Id");
migrationBuilder.AddColumn<string>(
name: "Buyer_Email",
table: "Orders",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Buyer_Name",
table: "Orders",
type: "text",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "PaymentTypeId",
table: "Orders",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Orders_PaymentTypeId",
table: "Orders",
column: "PaymentTypeId");
migrationBuilder.AddForeignKey(
name: "FK_Orders_PaymentTypes_PaymentTypeId",
table: "Orders",
column: "PaymentTypeId",
principalTable: "PaymentTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_PaymentTypes_PaymentTypeId",
table: "Orders");
migrationBuilder.DropIndex(
name: "IX_Orders_PaymentTypeId",
table: "Orders");
migrationBuilder.DropColumn(
name: "Buyer_Email",
table: "Orders");
migrationBuilder.DropColumn(
name: "Buyer_Name",
table: "Orders");
migrationBuilder.DropColumn(
name: "PaymentTypeId",
table: "Orders");
migrationBuilder.RenameColumn(
name: "Buyer_Id",
table: "Orders",
newName: "BuyerId");
migrationBuilder.CreateTable(
name: "Buyers",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
PaymentTypeId = table.Column<int>(type: "integer", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
Email = table.Column<string>(type: "text", nullable: false),
ExtraProperties = table.Column<string>(type: "text", nullable: true),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Buyers", x => x.Id);
table.ForeignKey(
name: "FK_Buyers_PaymentTypes_PaymentTypeId",
column: x => x.PaymentTypeId,
principalTable: "PaymentTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Orders_BuyerId",
table: "Orders",
column: "BuyerId");
migrationBuilder.CreateIndex(
name: "IX_Orders_Id",
table: "Orders",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_Buyers_PaymentTypeId",
table: "Buyers",
column: "PaymentTypeId");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Buyers_BuyerId",
table: "Orders",
column: "BuyerId",
principalTable: "Buyers",
principalColumn: "Id");
}
}
}

95
services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/OrderingServiceDbContextModelSnapshot.cs

@ -24,36 +24,20 @@ namespace EShopOnAbp.OrderingService.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b =>
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.PaymentType", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
b.Property<int>("Id")
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PaymentId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.HasKey("Id");
b.ToTable("Buyers", (string)null);
b.ToTable("PaymentTypes", (string)null);
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
@ -61,19 +45,12 @@ namespace EShopOnAbp.OrderingService.Migrations
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<Guid?>("BuyerId")
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Description")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)");
b.Property<string>("ExtraProperties")
.HasColumnType("text")
.HasColumnName("ExtraProperties");
@ -81,21 +58,27 @@ namespace EShopOnAbp.OrderingService.Migrations
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("PaymentMethodToken")
.HasColumnType("text");
b.Property<Guid?>("PaymentRequestId")
.HasColumnType("uuid");
b.Property<string>("PaymentStatus")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<int>("_orderStatusId")
.HasColumnType("integer")
.HasColumnName("OrderStatusId");
b.HasKey("Id");
b.HasIndex("BuyerId");
b.Property<int>("_paymentTypeId")
.HasColumnType("integer")
.HasColumnName("PaymentTypeId");
b.HasIndex("Id");
b.HasKey("Id");
b.HasIndex("_orderStatusId");
b.HasIndex("_paymentTypeId");
b.ToTable("Orders", (string)null);
});
@ -113,6 +96,10 @@ namespace EShopOnAbp.OrderingService.Migrations
b.Property<string>("PictureUrl")
.HasColumnType("text");
b.Property<string>("ProductCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
@ -151,16 +138,18 @@ namespace EShopOnAbp.OrderingService.Migrations
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b =>
{
b.HasOne("EShopOnAbp.OrderingService.Buyers.Buyer", null)
.WithMany()
.HasForeignKey("BuyerId");
b.HasOne("EShopOnAbp.OrderingService.Orders.OrderStatus", "OrderStatus")
.WithMany()
.HasForeignKey("_orderStatusId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EShopOnAbp.OrderingService.Buyers.PaymentType", "PaymentType")
.WithMany()
.HasForeignKey("_paymentTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Address", "Address", b1 =>
{
b1.Property<Guid>("OrderId")
@ -189,9 +178,35 @@ namespace EShopOnAbp.OrderingService.Migrations
.HasForeignKey("OrderId");
});
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Buyer", "Buyer", b1 =>
{
b1.Property<Guid>("OrderId")
.HasColumnType("uuid");
b1.Property<string>("Email")
.HasColumnType("text");
b1.Property<Guid?>("Id")
.HasColumnType("uuid");
b1.Property<string>("Name")
.HasColumnType("text");
b1.HasKey("OrderId");
b1.ToTable("Orders");
b1.WithOwner()
.HasForeignKey("OrderId");
});
b.Navigation("Address");
b.Navigation("Buyer");
b.Navigation("OrderStatus");
b.Navigation("PaymentType");
});
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b =>

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

@ -0,0 +1,34 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace EShopOnAbp.OrderingService.Orders;
public class EfCoreOrderRepository : EfCoreRepository<OrderingServiceDbContext, Order, Guid>, IOrderRepository
{
public EfCoreOrderRepository(IDbContextProvider<OrderingServiceDbContext> dbContextProvider) : base(
dbContextProvider)
{
}
public override async Task<Order> InsertAsync(Order entity, bool autoSave = false,
CancellationToken cancellationToken = default)
{
var newEntity = await base.InsertAsync(entity, autoSave, GetCancellationToken(cancellationToken));
await EnsurePropertyLoadedAsync(newEntity, o => o.OrderStatus, GetCancellationToken(cancellationToken));
await EnsurePropertyLoadedAsync(newEntity, o => o.PaymentType, GetCancellationToken(cancellationToken));
return newEntity;
}
public override async Task<IQueryable<Order>> WithDetailsAsync()
{
return (await GetQueryableAsync())
.Include(q => q.OrderStatus)
.Include(q => q.PaymentType);
}
}

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

@ -0,0 +1,34 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using EShopOnAbp.OrderingService.Orders;
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.OrderingService.Orders.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IOrderAppService), typeof(OrderClientProxy))]
public partial class OrderClientProxy : ClientProxyBase<IOrderAppService>, IOrderAppService
{
public virtual async Task<OrderDto> GetAsync(Guid id)
{
return await RequestAsync<OrderDto>(nameof(GetAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), id }
});
}
public virtual async Task<OrderDto> CreateAsync(OrderCreateDto input)
{
return await RequestAsync<OrderDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue
{
{ typeof(OrderCreateDto), input }
});
}
}
}

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

@ -0,0 +1,8 @@
// This file is part of OrderClientProxy, you can customize it here
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.OrderingService.Orders.ClientProxies
{
public partial class OrderClientProxy
{
}
}

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

@ -0,0 +1,106 @@
{
"modules": {
"ordering": {
"rootPath": "ordering",
"remoteServiceName": "Ordering",
"controllers": {
"EShopOnAbp.OrderingService.Orders.OrderAppService": {
"controllerName": "Order",
"controllerGroupName": "Order",
"type": "EShopOnAbp.OrderingService.Orders.OrderAppService",
"interfaces": [
{
"type": "Volo.Abp.Validation.IValidationEnabled"
},
{
"type": "Volo.Abp.Auditing.IAuditingEnabled"
},
{
"type": "Volo.Abp.GlobalFeatures.IGlobalFeatureCheckingEnabled"
},
{
"type": "EShopOnAbp.OrderingService.Orders.IOrderAppService"
}
],
"actions": {
"GetAsyncById": {
"uniqueName": "GetAsyncById",
"name": "GetAsync",
"httpMethod": "GET",
"url": "api/ordering/order/{id}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "EShopOnAbp.OrderingService.Orders.OrderDto",
"typeSimple": "EShopOnAbp.OrderingService.Orders.OrderDto"
},
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"
},
"CreateAsyncByInput": {
"uniqueName": "CreateAsyncByInput",
"name": "CreateAsync",
"httpMethod": "POST",
"url": "api/ordering/order",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "EShopOnAbp.OrderingService.Orders.OrderCreateDto, EShopOnAbp.OrderingService.Application.Contracts",
"type": "EShopOnAbp.OrderingService.Orders.OrderCreateDto",
"typeSimple": "EShopOnAbp.OrderingService.Orders.OrderCreateDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "input",
"jsonName": null,
"type": "EShopOnAbp.OrderingService.Orders.OrderCreateDto",
"typeSimple": "EShopOnAbp.OrderingService.Orders.OrderCreateDto",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "EShopOnAbp.OrderingService.Orders.OrderDto",
"typeSimple": "EShopOnAbp.OrderingService.Orders.OrderDto"
},
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"
}
}
}
}
}
},
"types": {}
}

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

@ -1,53 +0,0 @@
{
"modules": {
"OrderingService": {
"rootPath": "OrderingService",
"remoteServiceName": "OrderingService",
"controllers": {
"EShopOnAbp.OrderingService.Samples.SampleController": {
"controllerName": "Sample",
"controllerGroupName": "Sample",
"type": "EShopOnAbp.OrderingService.Samples.SampleController",
"interfaces": [
{
"type": "EShopOnAbp.OrderingService.Samples.ISampleAppService"
}
],
"actions": {
"GetAsync": {
"uniqueName": "GetAsync",
"name": "GetAsync",
"httpMethod": "GET",
"url": "api/OrderingService/sample",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "EShopOnAbp.OrderingService.Samples.SampleDto",
"typeSimple": "EShopOnAbp.OrderingService.Samples.SampleDto"
},
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Samples.ISampleAppService"
},
"GetAuthorizedAsync": {
"uniqueName": "GetAuthorizedAsync",
"name": "GetAuthorizedAsync",
"httpMethod": "GET",
"url": "api/OrderingService/sample/authorized",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "EShopOnAbp.OrderingService.Samples.SampleDto",
"typeSimple": "EShopOnAbp.OrderingService.Samples.SampleDto"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.OrderingService.Samples.ISampleAppService"
}
}
}
}
}
},
"types": {}
}

15
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/SampleClientProxy.Generated.cs

@ -1,15 +0,0 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using EShopOnAbp.OrderingService.Samples;
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.OrderingService.Samples.ClientProxies
{
}

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

@ -1,8 +0,0 @@
// This file is part of SampleClientProxy, you can customize it here
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.OrderingService.Samples.ClientProxies
{
public partial class SampleClientProxy
{
}
}

6
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs

@ -10,18 +10,18 @@ namespace EShopOnAbp.OrderingService
typeof(AbpHttpClientModule))]
public class OrderingServiceHttpApiClientModule : AbpModule
{
public const string RemoteServiceName = "Ordering";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddStaticHttpClientProxies(
typeof(OrderingServiceApplicationContractsModule).Assembly,
OrderingServiceRemoteServiceConsts.RemoteServiceName
RemoteServiceName
);
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<OrderingServiceHttpApiClientModule>();
});
}
}
}
}

12
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs

@ -10,6 +10,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
@ -30,7 +31,6 @@ namespace EShopOnAbp.OrderingService
var configuration = context.Services.GetConfiguration();
JwtBearerConfigurationHelper.Configure(context, "OrderingService");
// SwaggerConfigurationHelper.Configure(context, "Catalog Service API");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
@ -60,6 +60,16 @@ namespace EShopOnAbp.OrderingService
.AllowCredentials();
});
});
// TODO: Crate controller instead of auto-controller configuration
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(OrderingServiceApplicationModule).Assembly, opts =>
{
opts.RootPath = "ordering";
opts.RemoteServiceName = "Ordering";
});
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)

42
services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/Orders/OrderManager_Tests.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EShopOnAbp.OrderingService.Buyers;
using Shouldly;
using Xunit;
namespace EShopOnAbp.OrderingService.Orders;
public class OrderManagerUnitTests : OrderingServiceDomainTestBase
{
private readonly OrderManager _orderManager;
public OrderManagerUnitTests()
{
_orderManager = GetRequiredService<OrderManager>();
}
[Fact]
public async Task Should_CreateOrderAsync()
{
var orderItems =
new List<(Guid productId, string productName, string productCode, decimal unitPrice, decimal discount,
string pictureUrl, int
units)>();
orderItems.Add((Guid.NewGuid(), "Test product", "Code:001", 15, 0, "", 1));
var createdOrder = await _orderManager.CreateOrderAsync(
1,
Guid.Parse("11CA0F6D-208E-441A-9F9B-3611C96E4383"),
"gterdem",
"gterdem@volosoft.com",
orderItems,
"Test Street",
"Test City",
"Test Country",
"Test zipCode");
createdOrder.ShouldNotBeNull();
createdOrder.OrderStatus.ShouldBe(OrderStatus.Placed);
createdOrder.PaymentType.ShouldBe(PaymentType.Paypal);
}
}

1
services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs

@ -3,7 +3,6 @@ using System.Net.Http;
using System.Threading.Tasks;
using IdentityModel.Client;
using Microsoft.Extensions.Configuration;
using EShopOnAbp.OrderingService.Samples;
using Volo.Abp.DependencyInjection;
using Volo.Abp.IdentityModel;

2
services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProduct.cs → services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestProductDto.cs

@ -5,7 +5,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests
{
public class PaymentRequestProductDto : EntityDto<Guid>
{
public Guid PaymentRequestId { get; private set; }
public Guid PaymentRequestId { get; set; }
public string ReferenceId { get; set; }

16
services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentRequests/PaymentRequestProduct.cs

@ -8,12 +8,12 @@ namespace EShopOnAbp.PaymentService.PaymentRequests
public class PaymentRequestProduct : Entity<Guid>
{
public Guid PaymentRequestId { get; private set; }
public string ReferenceId { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public decimal UnitPrice { get; set; }
public int Quantity { get; set; }
public decimal TotalPrice { get; set; }
public string ReferenceId { get; private set; }
public string Code { get; private set; }
public string Name { get; private set; }
public decimal UnitPrice { get; private set; }
public int Quantity { get; private set; }
public decimal TotalPrice { get; private set; }
public PaymentRequestProduct(
Guid id,
@ -26,8 +26,8 @@ namespace EShopOnAbp.PaymentService.PaymentRequests
[CanBeNull] string referenceId = null) : base(id)
{
PaymentRequestId = paymentRequestId;
Code = Check.NotNullOrEmpty(code, nameof(code));
Name = Check.NotNullOrEmpty(name, nameof(name));
Code = Check.NotNullOrEmpty(code, nameof(code), maxLength: PaymentRequestConsts.MaxCodeLength);
Name = Check.NotNullOrEmpty(name, nameof(name), maxLength: PaymentRequestConsts.MaxNameLength);
UnitPrice = unitPrice;
Quantity = quantity;
TotalPrice = totalPrice;

Loading…
Cancel
Save