Browse Source

Record InventoryStrategy in OrderLine

Resolve #215
pull/216/head
gdlcf88 4 years ago
parent
commit
3a5060fb38
  1. 5
      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. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp.EShop.Orders.Domain.Shared.csproj
  4. 4
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/EShopOrdersDomainSharedModule.cs
  5. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/en.json
  6. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hans.json
  7. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hant.json
  8. 41
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderLine.cs
  9. 5
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderLineEto.cs
  10. 8
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs
  11. 1
      modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/InventoryReductionResultTests.cs
  12. 2
      modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDomainTests.cs
  13. 6171
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220818075709_AddedProductInventoryStrategyProperty.Designer.cs
  14. 37
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220818075709_AddedProductInventoryStrategyProperty.cs
  15. 8
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/EShopSampleDbContextModelSnapshot.cs

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

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using EasyAbp.EShop.Products.Products;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
@ -26,7 +27,9 @@ namespace EasyAbp.EShop.Orders.Orders.Dtos
public string ProductUniqueName { get; set; }
public string ProductDisplayName { get; set; }
public InventoryStrategy? ProductInventoryStrategy { get; set; }
public string SkuName { get; set; }
public string SkuDescription { get; set; }

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

@ -148,6 +148,7 @@ namespace EasyAbp.EShop.Orders.Orders
productGroupDisplayName: product.ProductGroupDisplayName,
productUniqueName: product.UniqueName,
productDisplayName: product.DisplayName,
productInventoryStrategy: product.InventoryStrategy,
skuName: productSku.Name,
skuDescription: await _productSkuDescriptionProvider.GenerateAsync(product, productSku),
mediaResources: product.MediaResources,

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp.EShop.Orders.Domain.Shared.csproj

@ -12,6 +12,7 @@
<PackageReference Include="Volo.Abp.Validation" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Auditing.Contracts" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Payments\src\EasyAbp.EShop.Payments.Domain.Shared\EasyAbp.EShop.Payments.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Products\src\EasyAbp.EShop.Products.Domain.Shared\EasyAbp.EShop.Products.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Stores\src\EasyAbp.EShop.Stores.Domain.Shared\EasyAbp.EShop.Stores.Domain.Shared.csproj" />
</ItemGroup>

4
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/EShopOrdersDomainSharedModule.cs

@ -2,6 +2,7 @@
using Volo.Abp.Localization;
using EasyAbp.EShop.Orders.Localization;
using EasyAbp.EShop.Payments;
using EasyAbp.EShop.Products;
using EasyAbp.EShop.Stores;
using Volo.Abp.Auditing;
using Volo.Abp.Localization.ExceptionHandling;
@ -15,7 +16,8 @@ namespace EasyAbp.EShop.Orders
typeof(AbpValidationModule),
typeof(AbpAuditingContractsModule),
typeof(EShopStoresDomainSharedModule),
typeof(EShopPaymentsDomainSharedModule)
typeof(EShopPaymentsDomainSharedModule),
typeof(EShopProductsDomainSharedModule)
)]
public class EShopOrdersDomainSharedModule : AbpModule
{

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/en.json

@ -35,6 +35,7 @@
"OrderLineProductGroupDisplayName": "Product group",
"OrderLineProductUniqueName": "Product unique name",
"OrderLineProductDisplayName": "Product display name",
"OrderLineProductInventoryStrategy": "Product inventory strategy",
"OrderLineSkuName": "SKU name",
"OrderLineSkuDescription": "SKU description",
"OrderLineMediaResources": "Media resources",

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hans.json

@ -35,6 +35,7 @@
"OrderLineProductGroupDisplayName": "商品组名称",
"OrderLineProductUniqueName": "商品编号",
"OrderLineProductDisplayName": "商品名称",
"OrderLineProductInventoryStrategy": "商品库存策略",
"OrderLineSkuName": "SKU 编号",
"OrderLineSkuDescription": "SKU 描述",
"OrderLineMediaResources": "多媒体资源",

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hant.json

@ -35,6 +35,7 @@
"OrderLineProductGroupDisplayName": "商品組名稱",
"OrderLineProductUniqueName": "商品編號",
"OrderLineProductDisplayName": "商品名稱",
"OrderLineProductInventoryStrategy": "商品庫存策略",
"OrderLineSkuName": "SKU 編號",
"OrderLineSkuDescription": "SKU 描述",
"OrderLineMediaResources": "多媒體資源",

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

@ -1,4 +1,5 @@
using System;
using EasyAbp.EShop.Products.Products;
using Volo.Abp.Data;
namespace EasyAbp.EShop.Orders.Orders
@ -6,44 +7,50 @@ namespace EasyAbp.EShop.Orders.Orders
public interface IOrderLine : IHasExtraProperties
{
Guid ProductId { get; }
Guid ProductSkuId { get; }
Guid? ProductDetailId { get; }
DateTime ProductModificationTime { get; }
DateTime? ProductDetailModificationTime { get; }
string ProductGroupName { get; }
string ProductGroupDisplayName { get; }
string ProductUniqueName { get; }
string ProductDisplayName { get; }
/// <summary>
/// If it is <c>null</c>, should get the <see cref="InventoryStrategy"/> from the Product entity.
/// See https://github.com/EasyAbp/EShop/issues/215
/// </summary>
InventoryStrategy? ProductInventoryStrategy { get; }
string SkuName { get; }
string SkuDescription { get; }
string MediaResources { get; }
string Currency { get; }
decimal UnitPrice { get; }
decimal TotalPrice { get; }
decimal TotalDiscount { get; }
/// <summary>
/// ActualTotalPrice = TotalPrice - TotalDiscount
/// </summary>
decimal ActualTotalPrice { get; }
int Quantity { get; }
int RefundedQuantity { get; }
decimal RefundAmount { get; }

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

@ -1,4 +1,5 @@
using System;
using EasyAbp.EShop.Products.Products;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
@ -25,7 +26,9 @@ namespace EasyAbp.EShop.Orders.Orders
public string ProductUniqueName { get; set; }
public string ProductDisplayName { get; set; }
public InventoryStrategy? ProductInventoryStrategy { get; set; }
public string SkuName { get; set; }
public string SkuDescription { get; set; }

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

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using EasyAbp.EShop.Products.Products;
using JetBrains.Annotations;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing;
@ -30,7 +30,9 @@ namespace EasyAbp.EShop.Orders.Orders
[NotNull]
public virtual string ProductDisplayName { get; protected set; }
public virtual InventoryStrategy? ProductInventoryStrategy { get; protected set; }
[CanBeNull]
public virtual string SkuName { get; protected set; }
@ -77,6 +79,7 @@ namespace EasyAbp.EShop.Orders.Orders
[NotNull] string productGroupDisplayName,
[CanBeNull] string productUniqueName,
[NotNull] string productDisplayName,
InventoryStrategy productInventoryStrategy,
[CanBeNull] string skuName,
[CanBeNull] string skuDescription,
[CanBeNull] string mediaResources,
@ -96,6 +99,7 @@ namespace EasyAbp.EShop.Orders.Orders
ProductGroupDisplayName = productGroupDisplayName;
ProductUniqueName = productUniqueName;
ProductDisplayName = productDisplayName;
ProductInventoryStrategy = productInventoryStrategy;
SkuName = skuName;
SkuDescription = skuDescription;
MediaResources = mediaResources;

1
modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/InventoryReductionResultTests.cs

@ -38,6 +38,7 @@ public class InventoryReductionResultTests : OrdersDomainTestBase
"Default",
null,
"Product 1",
InventoryStrategy.NoNeed,
null,
null,
null,

2
modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDomainTests.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Payments.Refunds;
using EasyAbp.EShop.Products.Products;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Shouldly;
@ -46,6 +47,7 @@ namespace EasyAbp.EShop.Orders.Orders
"Default",
null,
"Product 1",
InventoryStrategy.NoNeed,
null,
null,
null,

6171
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220818075709_AddedProductInventoryStrategyProperty.Designer.cs

File diff suppressed because it is too large

37
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220818075709_AddedProductInventoryStrategyProperty.cs

@ -0,0 +1,37 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopSample.Migrations
{
public partial class AddedProductInventoryStrategyProperty : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "ReducedInventoryTime",
table: "EasyAbpEShopPluginsFlashSalesFlashSaleResults",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<int>(
name: "ProductInventoryStrategy",
table: "EasyAbpEShopOrdersOrderLines",
type: "int",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ReducedInventoryTime",
table: "EasyAbpEShopPluginsFlashSalesFlashSaleResults");
migrationBuilder.DropColumn(
name: "ProductInventoryStrategy",
table: "EasyAbpEShopOrdersOrderLines");
}
}
}

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

@ -19,7 +19,7 @@ namespace EShopSample.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "6.0.7")
.HasAnnotation("ProductVersion", "6.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
@ -699,6 +699,9 @@ namespace EShopSample.Migrations
b.Property<Guid>("ProductId")
.HasColumnType("uniqueidentifier");
b.Property<int?>("ProductInventoryStrategy")
.HasColumnType("int");
b.Property<DateTime>("ProductModificationTime")
.HasColumnType("datetime2");
@ -1853,6 +1856,9 @@ namespace EShopSample.Migrations
b.Property<string>("Reason")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("ReducedInventoryTime")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");

Loading…
Cancel
Save