Browse Source

Record ProductDetailId in OrderLine

pull/143/head
gdlcf88 4 years ago
parent
commit
084c0f8ab5
  1. 2
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderLineDto.cs
  2. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs
  3. 2
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderLine.cs
  4. 2
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderLineEto.cs
  5. 4
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs
  6. 96
      modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderAppServiceTests.cs
  7. 5134
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220411204916_AddedProductDetailIdToOrderLine.Designer.cs
  8. 26
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220411204916_AddedProductDetailIdToOrderLine.cs
  9. 3
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/EShopSampleDbContextModelSnapshot.cs

2
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderLineDto.cs

@ -13,6 +13,8 @@ namespace EasyAbp.EShop.Orders.Orders.Dtos
public Guid ProductSkuId { get; set; } public Guid ProductSkuId { get; set; }
public Guid? ProductDetailId { get; set; }
public DateTime ProductModificationTime { get; set; } public DateTime ProductModificationTime { get; set; }
public DateTime? ProductDetailModificationTime { get; set; } public DateTime? ProductDetailModificationTime { get; set; }

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs

@ -126,6 +126,7 @@ namespace EasyAbp.EShop.Orders.Orders
id: _guidGenerator.Create(), id: _guidGenerator.Create(),
productId: product.Id, productId: product.Id,
productSkuId: productSku.Id, productSkuId: productSku.Id,
productDetailId: productDetailId,
productModificationTime: product.LastModificationTime ?? product.CreationTime, productModificationTime: product.LastModificationTime ?? product.CreationTime,
productDetailModificationTime: productDetail?.LastModificationTime ?? productDetail?.CreationTime, productDetailModificationTime: productDetail?.LastModificationTime ?? productDetail?.CreationTime,
productGroupName: product.ProductGroupName, productGroupName: product.ProductGroupName,

2
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderLine.cs

@ -9,6 +9,8 @@ namespace EasyAbp.EShop.Orders.Orders
Guid ProductSkuId { get; } Guid ProductSkuId { get; }
Guid? ProductDetailId { get; }
DateTime ProductModificationTime { get; } DateTime ProductModificationTime { get; }
DateTime? ProductDetailModificationTime { get; } DateTime? ProductDetailModificationTime { get; }

2
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderLineEto.cs

@ -12,6 +12,8 @@ namespace EasyAbp.EShop.Orders.Orders
public Guid ProductSkuId { get; set; } public Guid ProductSkuId { get; set; }
public Guid? ProductDetailId { get; set; }
public DateTime ProductModificationTime { get; set; } public DateTime ProductModificationTime { get; set; }
public DateTime? ProductDetailModificationTime { get; set; } public DateTime? ProductDetailModificationTime { get; set; }

4
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs

@ -13,6 +13,8 @@ namespace EasyAbp.EShop.Orders.Orders
public virtual Guid ProductSkuId { get; protected set; } public virtual Guid ProductSkuId { get; protected set; }
public virtual Guid? ProductDetailId { get; protected set; }
public virtual DateTime ProductModificationTime { get; protected set; } public virtual DateTime ProductModificationTime { get; protected set; }
public virtual DateTime? ProductDetailModificationTime { get; protected set; } public virtual DateTime? ProductDetailModificationTime { get; protected set; }
@ -68,6 +70,7 @@ namespace EasyAbp.EShop.Orders.Orders
Guid id, Guid id,
Guid productId, Guid productId,
Guid productSkuId, Guid productSkuId,
Guid? productDetailId,
DateTime productModificationTime, DateTime productModificationTime,
DateTime? productDetailModificationTime, DateTime? productDetailModificationTime,
[NotNull] string productGroupName, [NotNull] string productGroupName,
@ -86,6 +89,7 @@ namespace EasyAbp.EShop.Orders.Orders
{ {
ProductId = productId; ProductId = productId;
ProductSkuId = productSkuId; ProductSkuId = productSkuId;
ProductDetailId = productDetailId;
ProductModificationTime = productModificationTime; ProductModificationTime = productModificationTime;
ProductDetailModificationTime = productDetailModificationTime; ProductDetailModificationTime = productDetailModificationTime;
ProductGroupName = productGroupName; ProductGroupName = productGroupName;

96
modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderAppServiceTests.cs

@ -110,6 +110,12 @@ namespace EasyAbp.EShop.Orders.Orders
ProductId = OrderTestData.Product1Id, ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku1Id, ProductSkuId = OrderTestData.ProductSku1Id,
Quantity = 10 Quantity = 10
},
new CreateOrderLineDto
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku2Id,
Quantity = 1
} }
} }
}; };
@ -124,47 +130,6 @@ namespace EasyAbp.EShop.Orders.Orders
var response = await _orderAppService.GetAsync(createResponse.Id); var response = await _orderAppService.GetAsync(createResponse.Id);
// Assert // Assert
response.ShouldNotBeNull();
response.Currency.ShouldBe("CNY");
response.CanceledTime.ShouldBeNull();
response.CancellationReason.ShouldBeNullOrEmpty();
response.CompletionTime.ShouldBeNull();
response.CustomerRemark.ShouldBe("customer remark");
response.OrderNumber.ShouldNotBeNull();
response.OrderStatus.ShouldBe(OrderStatus.Pending);
response.PaidTime.ShouldBeNull();
response.PaymentId.ShouldBeNull();
response.RefundAmount.ShouldBe(0m);
response.StaffRemark.ShouldBeNullOrEmpty();
response.StoreId.ShouldBe(OrderTestData.Store1Id);
response.TotalDiscount.ShouldBe(0m);
response.TotalPrice.ShouldBe(10m);
response.ActualTotalPrice.ShouldBe(10m);
response.CustomerUserId.ShouldBe(Guid.Parse("2e701e62-0953-4dd3-910b-dc6cc93ccb0d"));
response.ProductTotalPrice.ShouldBe(10m);
response.ReducedInventoryAfterPaymentTime.ShouldBeNull();
response.ReducedInventoryAfterPlacingTime.ShouldNotBeNull();
response.OrderLines.Count.ShouldBe(1);
var responseOrderLine = response.OrderLines.First();
responseOrderLine.ProductId.ShouldBe(OrderTestData.Product1Id);
responseOrderLine.ProductSkuId.ShouldBe(OrderTestData.ProductSku1Id);
responseOrderLine.ProductDisplayName.ShouldBe("Hello pencil");
responseOrderLine.ProductUniqueName.ShouldBe("Pencil");
responseOrderLine.ProductGroupName.ShouldBe("Default");
responseOrderLine.ProductGroupDisplayName.ShouldBe("Default");
responseOrderLine.SkuName.ShouldBe("My SKU");
responseOrderLine.UnitPrice.ShouldBe(1m);
responseOrderLine.TotalPrice.ShouldBe(10m);
responseOrderLine.TotalDiscount.ShouldBe(0m);
responseOrderLine.ActualTotalPrice.ShouldBe(10m);
responseOrderLine.Currency.ShouldBe("CNY");
responseOrderLine.Quantity.ShouldBe(10);
responseOrderLine.ProductModificationTime.ShouldBe(OrderTestData.ProductLastModificationTime);
responseOrderLine.ProductDetailModificationTime.ShouldBe(OrderTestData.ProductDetailLastModificationTime);
responseOrderLine.RefundAmount.ShouldBe(0m);
responseOrderLine.RefundedQuantity.ShouldBe(0);
UsingDbContext(context => UsingDbContext(context =>
{ {
context.Orders.Count().ShouldBe(1); context.Orders.Count().ShouldBe(1);
@ -183,31 +148,36 @@ namespace EasyAbp.EShop.Orders.Orders
order.StaffRemark.ShouldBeNullOrEmpty(); order.StaffRemark.ShouldBeNullOrEmpty();
order.StoreId.ShouldBe(OrderTestData.Store1Id); order.StoreId.ShouldBe(OrderTestData.Store1Id);
order.TotalDiscount.ShouldBe(0m); order.TotalDiscount.ShouldBe(0m);
order.TotalPrice.ShouldBe(10m); order.TotalPrice.ShouldBe(12m);
order.ActualTotalPrice.ShouldBe(10m); order.ActualTotalPrice.ShouldBe(12m);
order.CustomerUserId.ShouldBe(Guid.Parse("2e701e62-0953-4dd3-910b-dc6cc93ccb0d")); order.CustomerUserId.ShouldBe(Guid.Parse("2e701e62-0953-4dd3-910b-dc6cc93ccb0d"));
order.ProductTotalPrice.ShouldBe(10m); order.ProductTotalPrice.ShouldBe(12m);
order.ReducedInventoryAfterPaymentTime.ShouldBeNull(); order.ReducedInventoryAfterPaymentTime.ShouldBeNull();
order.ReducedInventoryAfterPlacingTime.ShouldNotBeNull(); order.ReducedInventoryAfterPlacingTime.ShouldNotBeNull();
order.OrderLines.Count.ShouldBe(1); order.OrderLines.Count.ShouldBe(2);
var orderLine = order.OrderLines.First(); var orderLine1 = response.OrderLines.Single(x => x.ProductSkuId == OrderTestData.ProductSku1Id);
orderLine.ProductId.ShouldBe(OrderTestData.Product1Id); orderLine1.ProductId.ShouldBe(OrderTestData.Product1Id);
orderLine.ProductSkuId.ShouldBe(OrderTestData.ProductSku1Id); orderLine1.ProductSkuId.ShouldBe(OrderTestData.ProductSku1Id);
orderLine.ProductDisplayName.ShouldBe("Hello pencil"); orderLine1.ProductDetailId.ShouldBe(OrderTestData.ProductDetail1Id);
orderLine.ProductUniqueName.ShouldBe("Pencil"); orderLine1.ProductDisplayName.ShouldBe("Hello pencil");
orderLine.ProductGroupName.ShouldBe("Default"); orderLine1.ProductUniqueName.ShouldBe("Pencil");
orderLine.ProductGroupDisplayName.ShouldBe("Default"); orderLine1.ProductGroupName.ShouldBe("Default");
orderLine.SkuName.ShouldBe("My SKU"); orderLine1.ProductGroupDisplayName.ShouldBe("Default");
orderLine.UnitPrice.ShouldBe(1m); orderLine1.SkuName.ShouldBe("My SKU");
orderLine.TotalPrice.ShouldBe(10m); orderLine1.UnitPrice.ShouldBe(1m);
orderLine.TotalDiscount.ShouldBe(0m); orderLine1.TotalPrice.ShouldBe(10m);
orderLine.ActualTotalPrice.ShouldBe(10m); orderLine1.TotalDiscount.ShouldBe(0m);
orderLine.Currency.ShouldBe("CNY"); orderLine1.ActualTotalPrice.ShouldBe(10m);
orderLine.Quantity.ShouldBe(10); orderLine1.Currency.ShouldBe("CNY");
orderLine.ProductModificationTime.ShouldBe(OrderTestData.ProductLastModificationTime); orderLine1.Quantity.ShouldBe(10);
orderLine.RefundAmount.ShouldBe(0m); orderLine1.ProductModificationTime.ShouldBe(OrderTestData.ProductLastModificationTime);
orderLine.RefundedQuantity.ShouldBe(0); orderLine1.ProductDetailModificationTime.ShouldBe(OrderTestData.ProductDetailLastModificationTime);
orderLine1.RefundAmount.ShouldBe(0m);
orderLine1.RefundedQuantity.ShouldBe(0);
var orderLine2 = response.OrderLines.Single(x => x.ProductSkuId == OrderTestData.ProductSku2Id);
orderLine2.ProductDetailId.ShouldBe(OrderTestData.ProductDetail2Id);
}); });
} }

5134
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220411204916_AddedProductDetailIdToOrderLine.Designer.cs

File diff suppressed because it is too large

26
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220411204916_AddedProductDetailIdToOrderLine.cs

@ -0,0 +1,26 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopSample.Migrations
{
public partial class AddedProductDetailIdToOrderLine : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "ProductDetailId",
table: "EasyAbpEShopOrdersOrderLines",
type: "uniqueidentifier",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProductDetailId",
table: "EasyAbpEShopOrdersOrderLines");
}
}
}

3
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/EShopSampleDbContextModelSnapshot.cs

@ -214,6 +214,9 @@ namespace EShopSample.Migrations
b.Property<Guid?>("OrderId") b.Property<Guid?>("OrderId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<Guid?>("ProductDetailId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("ProductDetailModificationTime") b.Property<DateTime?>("ProductDetailModificationTime")
.HasColumnType("datetime2"); .HasColumnType("datetime2");

Loading…
Cancel
Save