From 1044a41da3d114e6cce2cbe0dc69945fc9ea729b Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Fri, 7 Jan 2022 16:58:00 +0300 Subject: [PATCH] payment service: added OrderNo --- .../PaymentRequestCreationDto.cs | 3 + .../PaymentRequestAppService.cs | 2 +- .../PaymentRequestByPassAppService.cs | 8 +- .../PaymentRequestCompletedEto.cs | 1 + .../PaymentRequestFailedEto.cs | 1 + .../PaymentRequests/PaymentRequest.cs | 5 + ...ServiceDbContextModelCreatingExtensions.cs | 2 + .../20220107135728_Added-OrderNo.Designer.cs | 140 ++++++++++++++++++ .../20220107135728_Added-OrderNo.cs | 26 ++++ .../PaymentServiceDbContextModelSnapshot.cs | 3 + 10 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.Designer.cs create mode 100644 services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.cs diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs index 0dcce09f..5584c680 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs @@ -16,6 +16,9 @@ namespace EShopOnAbp.PaymentService.PaymentRequests [MaxLength(PaymentRequestConsts.MaxOrderIdLength)] public string OrderId { get; set; } + [Required] + public int OrderNo { get; set; } + public string BuyerId { get; set; } public List Products { get; set; } } diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs index a3266fe6..28bac790 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs @@ -27,7 +27,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests public virtual async Task CreateAsync(PaymentRequestCreationDto input) { - var paymentRequest = new PaymentRequest(id: GuidGenerator.Create(), orderId: input.OrderId, currency: input.Currency, buyerId: input.BuyerId); + var paymentRequest = new PaymentRequest(id: GuidGenerator.Create(), orderId: input.OrderId, orderNo:input.OrderNo, currency: input.Currency, buyerId: input.BuyerId); foreach (var paymentRequestProduct in input.Products .Select(s => new PaymentRequestProduct( diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestByPassAppService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestByPassAppService.cs index cc9488cc..1c032844 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestByPassAppService.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestByPassAppService.cs @@ -8,7 +8,11 @@ namespace EShopOnAbp.PaymentService.PaymentRequests [ExposeServices(typeof(PaymentRequestByPassAppService))] public class PaymentRequestByPassAppService : PaymentRequestAppService { - public PaymentRequestByPassAppService(IPaymentRequestRepository paymentRequestRepository, PayPalHttpClient payPalHttpClient) : base(paymentRequestRepository, payPalHttpClient) + public PaymentRequestByPassAppService( + IPaymentRequestRepository paymentRequestRepository, + PayPalHttpClient payPalHttpClient) + : base(paymentRequestRepository, + payPalHttpClient) { } @@ -31,4 +35,4 @@ namespace EShopOnAbp.PaymentService.PaymentRequests return ObjectMapper.Map(paymentRequest); } } -} +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestCompletedEto.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestCompletedEto.cs index dab8dfd7..468242a7 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestCompletedEto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestCompletedEto.cs @@ -11,6 +11,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests { public Guid PaymentRequestId { get; set; } public string OrderId { get; set; } + public int OrderNo { get; set; } public string Currency { get; set; } public string BuyerId { get; set; } public PaymentRequestState State { get; set; } diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestFailedEto.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestFailedEto.cs index 1e847b18..18d0c361 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestFailedEto.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentRequests/PaymentRequestFailedEto.cs @@ -11,6 +11,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests public Guid PaymentRequestId { get; set; } public string OrderId { get; set; } + public int OrderNo { get; set; } public string FailReason { get; set; } public ExtraPropertyDictionary ExtraProperties { get; set; } } diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentRequests/PaymentRequest.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentRequests/PaymentRequest.cs index 343cc1bc..e6f1528a 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentRequests/PaymentRequest.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentRequests/PaymentRequest.cs @@ -11,6 +11,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests { [NotNull] public string Currency { get; protected set; } [NotNull] public string OrderId { get; protected set; } + public int OrderNo { get; protected set; } [CanBeNull] public string BuyerId { get; protected set; } public PaymentRequestState State { get; protected set; } [CanBeNull] public string FailReason { get; protected set; } @@ -22,12 +23,14 @@ namespace EShopOnAbp.PaymentService.PaymentRequests public PaymentRequest(Guid id, [NotNull] string orderId, + int orderNo, [NotNull] string currency, [CanBeNull] string buyerId = null) : base(id) { OrderId = Check.NotNullOrWhiteSpace(orderId, nameof(orderId), minLength: PaymentRequestConsts.MinOrderIdLength, maxLength: PaymentRequestConsts.MaxOrderIdLength); Currency = Check.NotNullOrWhiteSpace(currency, nameof(currency), maxLength: PaymentRequestConsts.MaxCurrencyLength); BuyerId = buyerId; + OrderNo = orderNo; } public virtual void SetAsCompleted() @@ -44,6 +47,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests { PaymentRequestId = Id, OrderId = OrderId, + OrderNo = OrderNo, BuyerId = BuyerId, Currency = Currency, State = State, @@ -66,6 +70,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests { PaymentRequestId = Id, OrderId = OrderId, + OrderNo = OrderNo, FailReason = failReason, ExtraProperties = ExtraProperties }); diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextModelCreatingExtensions.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextModelCreatingExtensions.cs index cf97fca8..73da676f 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextModelCreatingExtensions.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextModelCreatingExtensions.cs @@ -25,6 +25,8 @@ namespace EShopOnAbp.PaymentService.EntityFrameworkCore .Property(p => p.OrderId) .IsRequired() .HasMaxLength(PaymentRequestConsts.MaxOrderIdLength); + + entity.Property(q => q.OrderNo).IsRequired(); entity.HasIndex(o => o.OrderId); }); diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.Designer.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.Designer.cs new file mode 100644 index 00000000..1d54e67c --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.Designer.cs @@ -0,0 +1,140 @@ +// +using System; +using EShopOnAbp.PaymentService.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.PaymentService.Migrations +{ + [DbContext(typeof(PaymentServiceDbContext))] + [Migration("20220107135728_Added-OrderNo")] + partial class AddedOrderNo + { + 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.PaymentService.PaymentRequests.PaymentRequest", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("BuyerId") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uuid") + .HasColumnName("CreatorId"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("ExtraProperties") + .HasColumnType("text") + .HasColumnName("ExtraProperties"); + + b.Property("FailReason") + .HasColumnType("text"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("OrderId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("character varying(36)"); + + b.Property("OrderNo") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("PaymentRequests"); + }); + + modelBuilder.Entity("EShopOnAbp.PaymentService.PaymentRequests.PaymentRequestProduct", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PaymentRequestId") + .HasColumnType("uuid"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("ReferenceId") + .HasColumnType("text"); + + b.Property("TotalPrice") + .HasColumnType("numeric"); + + b.Property("UnitPrice") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("PaymentRequestId"); + + b.ToTable("PaymentRequestProduct"); + }); + + modelBuilder.Entity("EShopOnAbp.PaymentService.PaymentRequests.PaymentRequestProduct", b => + { + b.HasOne("EShopOnAbp.PaymentService.PaymentRequests.PaymentRequest", null) + .WithMany("Products") + .HasForeignKey("PaymentRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("EShopOnAbp.PaymentService.PaymentRequests.PaymentRequest", b => + { + b.Navigation("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.cs new file mode 100644 index 00000000..7430d2b1 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/20220107135728_Added-OrderNo.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EShopOnAbp.PaymentService.Migrations +{ + public partial class AddedOrderNo : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "OrderNo", + table: "PaymentRequests", + type: "integer", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "OrderNo", + table: "PaymentRequests"); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/PaymentServiceDbContextModelSnapshot.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/PaymentServiceDbContextModelSnapshot.cs index 387b0bb8..426cd7ac 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/PaymentServiceDbContextModelSnapshot.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Migrations/PaymentServiceDbContextModelSnapshot.cs @@ -69,6 +69,9 @@ namespace EShopOnAbp.PaymentService.Migrations .HasMaxLength(36) .HasColumnType("character varying(36)"); + b.Property("OrderNo") + .HasColumnType("integer"); + b.Property("State") .HasColumnType("integer");