Browse Source

Improve the implementation of `ExtraProperties`

pull/236/head
gdlcf88 3 years ago
parent
commit
3ae9ecca1c
  1. 38
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderLineDto.cs
  2. 9
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs
  3. 25
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentItem.cs
  4. 26
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItem.cs
  5. 11
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttribute.cs
  6. 10
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttributeOption.cs
  7. 12
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductSku.cs
  8. 2
      plugins/Booking/test/EasyAbp.EShop.Plugins.Booking.Application.Tests/Authorization/BookingPaymentCreationAuthorizationHandlersTests.cs

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

@ -1,29 +1,26 @@
using System; using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using EasyAbp.EShop.Products.Products; using EasyAbp.EShop.Products.Products;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
namespace EasyAbp.EShop.Orders.Orders.Dtos namespace EasyAbp.EShop.Orders.Orders.Dtos
{ {
[Serializable] [Serializable]
public class OrderLineDto : FullAuditedEntityDto<Guid>, IOrderLine public class OrderLineDto : ExtensibleFullAuditedEntityDto<Guid>, IOrderLine
{ {
public Guid ProductId { get; set; } public Guid ProductId { get; set; }
public Guid ProductSkuId { get; set; } public Guid ProductSkuId { get; set; }
public Guid? ProductDetailId { 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; }
public string ProductGroupName { get; set; } public string ProductGroupName { get; set; }
public string ProductGroupDisplayName { get; set; } public string ProductGroupDisplayName { get; set; }
public string ProductUniqueName { get; set; } public string ProductUniqueName { get; set; }
public string ProductDisplayName { get; set; } public string ProductDisplayName { get; set; }
@ -31,28 +28,25 @@ namespace EasyAbp.EShop.Orders.Orders.Dtos
public InventoryStrategy? ProductInventoryStrategy { get; set; } public InventoryStrategy? ProductInventoryStrategy { get; set; }
public string SkuName { get; set; } public string SkuName { get; set; }
public string SkuDescription { get; set; } public string SkuDescription { get; set; }
public string MediaResources { get; set; } public string MediaResources { get; set; }
public string Currency { get; set; } public string Currency { get; set; }
public decimal UnitPrice { get; set; } public decimal UnitPrice { get; set; }
public decimal TotalPrice { get; set; } public decimal TotalPrice { get; set; }
public decimal TotalDiscount { get; set; } public decimal TotalDiscount { get; set; }
public decimal ActualTotalPrice { get; set; } public decimal ActualTotalPrice { get; set; }
public int Quantity { get; set; } public int Quantity { get; set; }
public int RefundedQuantity { get; set; } public int RefundedQuantity { get; set; }
public decimal RefundAmount { get; set; } public decimal RefundAmount { get; set; }
[JsonInclude]
public ExtraPropertyDictionary ExtraProperties { get; set; }
} }
} }

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

@ -1,9 +1,9 @@
using System; using System;
using System.Text.Json.Serialization;
using EasyAbp.EShop.Products.Products; using EasyAbp.EShop.Products.Products;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.DynamicProxy;
namespace EasyAbp.EShop.Orders.Orders namespace EasyAbp.EShop.Orders.Orders
{ {
@ -59,13 +59,12 @@ namespace EasyAbp.EShop.Orders.Orders
public virtual decimal RefundAmount { get; protected set; } public virtual decimal RefundAmount { get; protected set; }
[JsonInclude] public ExtraPropertyDictionary ExtraProperties { get; protected set; }
public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; }
protected OrderLine() protected OrderLine()
{ {
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
public OrderLine( public OrderLine(
@ -114,7 +113,7 @@ namespace EasyAbp.EShop.Orders.Orders
RefundAmount = 0; RefundAmount = 0;
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
internal void Refund(int quantity, decimal amount) internal void Refund(int quantity, decimal amount)

25
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/PaymentItem.cs

@ -1,11 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using EasyAbp.EShop.Stores.Stores; using EasyAbp.EShop.Stores.Stores;
using EasyAbp.PaymentService.Payments; using EasyAbp.PaymentService.Payments;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.DynamicProxy;
namespace EasyAbp.EShop.Payments.Payments namespace EasyAbp.EShop.Payments.Payments
{ {
@ -15,36 +14,34 @@ namespace EasyAbp.EShop.Payments.Payments
[NotNull] [NotNull]
public virtual string ItemType { get; protected set; } public virtual string ItemType { get; protected set; }
public virtual string ItemKey { get; protected set; } public virtual string ItemKey { get; protected set; }
public virtual decimal OriginalPaymentAmount { get; protected set; } public virtual decimal OriginalPaymentAmount { get; protected set; }
public virtual decimal PaymentDiscount { get; protected set; } public virtual decimal PaymentDiscount { get; protected set; }
public virtual decimal ActualPaymentAmount { get; protected set; } public virtual decimal ActualPaymentAmount { get; protected set; }
public virtual decimal RefundAmount { get; protected set; } public virtual decimal RefundAmount { get; protected set; }
public virtual decimal PendingRefundAmount { get; protected set; } public virtual decimal PendingRefundAmount { get; protected set; }
[JsonInclude] public ExtraPropertyDictionary ExtraProperties { get; protected set; }
public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; }
#endregion #endregion
public virtual Guid StoreId { get; protected set; } public virtual Guid StoreId { get; protected set; }
public void SetStoreId(Guid storeId) public void SetStoreId(Guid storeId)
{ {
StoreId = storeId; StoreId = storeId;
} }
protected PaymentItem() protected PaymentItem()
{ {
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
this.SetDefaultsForExtraProperties();
} }
} }
} }

26
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItem.cs

@ -1,10 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json.Serialization;
using EasyAbp.EShop.Stores.Stores; using EasyAbp.EShop.Stores.Stores;
using EasyAbp.PaymentService.Refunds; using EasyAbp.PaymentService.Refunds;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.DynamicProxy;
namespace EasyAbp.EShop.Payments.Refunds namespace EasyAbp.EShop.Payments.Refunds
{ {
@ -13,41 +13,39 @@ namespace EasyAbp.EShop.Payments.Refunds
#region Base properties #region Base properties
public virtual Guid PaymentItemId { get; protected set; } public virtual Guid PaymentItemId { get; protected set; }
public virtual decimal RefundAmount { get; protected set; } public virtual decimal RefundAmount { get; protected set; }
public virtual string CustomerRemark { get; protected set; } public virtual string CustomerRemark { get; protected set; }
public virtual string StaffRemark { get; protected set; } public virtual string StaffRemark { get; protected set; }
[JsonInclude]
public virtual ExtraPropertyDictionary ExtraProperties { get; set; } public virtual ExtraPropertyDictionary ExtraProperties { get; set; }
#endregion #endregion
public virtual Guid StoreId { get; protected set; } public virtual Guid StoreId { get; protected set; }
public virtual Guid OrderId { get; protected set; } public virtual Guid OrderId { get; protected set; }
public virtual List<RefundItemOrderLine> OrderLines { get; protected set; } public virtual List<RefundItemOrderLine> OrderLines { get; protected set; }
public virtual List<RefundItemOrderExtraFee> OrderExtraFees { get; protected set; } public virtual List<RefundItemOrderExtraFee> OrderExtraFees { get; protected set; }
protected RefundItem() protected RefundItem()
{ {
OrderLines = new List<RefundItemOrderLine>(); OrderLines = new List<RefundItemOrderLine>();
OrderExtraFees = new List<RefundItemOrderExtraFee>(); OrderExtraFees = new List<RefundItemOrderExtraFee>();
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
this.SetDefaultsForExtraProperties();
} }
public void SetStoreId(Guid storeId) public void SetStoreId(Guid storeId)
{ {
StoreId = storeId; StoreId = storeId;
} }
public void SetOrderId(Guid orderId) public void SetOrderId(Guid orderId)
{ {
OrderId = orderId; OrderId = orderId;

11
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttribute.cs

@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json.Serialization;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.DynamicProxy;
namespace EasyAbp.EShop.Products.Products namespace EasyAbp.EShop.Products.Products
{ {
@ -16,16 +16,15 @@ namespace EasyAbp.EShop.Products.Products
public virtual string Description { get; protected set; } public virtual string Description { get; protected set; }
public virtual int DisplayOrder { get; protected set; } public virtual int DisplayOrder { get; protected set; }
[JsonInclude] public ExtraPropertyDictionary ExtraProperties { get; protected set; }
public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; }
public virtual List<ProductAttributeOption> ProductAttributeOptions { get; protected set; } public virtual List<ProductAttributeOption> ProductAttributeOptions { get; protected set; }
protected ProductAttribute() protected ProductAttribute()
{ {
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
public ProductAttribute( public ProductAttribute(
@ -41,7 +40,7 @@ namespace EasyAbp.EShop.Products.Products
ProductAttributeOptions = new List<ProductAttributeOption>(); ProductAttributeOptions = new List<ProductAttributeOption>();
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
} }
} }

10
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttributeOption.cs

@ -1,9 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.DynamicProxy;
namespace EasyAbp.EShop.Products.Products namespace EasyAbp.EShop.Products.Products
{ {
@ -17,13 +16,12 @@ namespace EasyAbp.EShop.Products.Products
public virtual int DisplayOrder { get; protected set; } public virtual int DisplayOrder { get; protected set; }
[JsonInclude] public ExtraPropertyDictionary ExtraProperties { get; protected set; }
public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; }
protected ProductAttributeOption() protected ProductAttributeOption()
{ {
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
public ProductAttributeOption( public ProductAttributeOption(
@ -37,7 +35,7 @@ namespace EasyAbp.EShop.Products.Products
DisplayOrder = displayOrder; DisplayOrder = displayOrder;
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
} }
} }

12
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductSku.cs

@ -1,10 +1,10 @@
using System; using System;
using System.Text.Json.Serialization;
using JetBrains.Annotations; using JetBrains.Annotations;
using NodaMoney; using NodaMoney;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.DynamicProxy;
namespace EasyAbp.EShop.Products.Products namespace EasyAbp.EShop.Products.Products
{ {
@ -16,6 +16,9 @@ namespace EasyAbp.EShop.Products.Products
[CanBeNull] [CanBeNull]
public virtual string Name { get; protected set; } public virtual string Name { get; protected set; }
[CanBeNull]
public virtual string Description { get; protected set; }
[NotNull] [NotNull]
public virtual string Currency { get; protected set; } public virtual string Currency { get; protected set; }
@ -34,13 +37,12 @@ namespace EasyAbp.EShop.Products.Products
public virtual Guid? ProductDetailId { get; protected set; } public virtual Guid? ProductDetailId { get; protected set; }
[JsonInclude] public ExtraPropertyDictionary ExtraProperties { get; protected set; }
public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; }
protected ProductSku() protected ProductSku()
{ {
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
public ProductSku( public ProductSku(
@ -72,7 +74,7 @@ namespace EasyAbp.EShop.Products.Products
ProductDetailId = productDetailId; ProductDetailId = productDetailId;
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
} }
internal void TrimName() internal void TrimName()

2
plugins/Booking/test/EasyAbp.EShop.Plugins.Booking.Application.Tests/Authorization/BookingPaymentCreationAuthorizationHandlersTests.cs

@ -37,7 +37,6 @@ public class BookingPaymentCreationAuthorizationHandlersTests : BookingApplicati
ProductId = BookingTestConsts.BookingProduct1Id, ProductId = BookingTestConsts.BookingProduct1Id,
ProductSkuId = BookingTestConsts.BookingProduct1Sku1Id, ProductSkuId = BookingTestConsts.BookingProduct1Sku1Id,
Quantity = BookingTestConsts.Volume, Quantity = BookingTestConsts.Volume,
ExtraProperties = new ExtraPropertyDictionary()
}; };
orderLine1.SetProperty(BookingOrderProperties.OrderLineBookingPeriodSchemeId, orderLine1.SetProperty(BookingOrderProperties.OrderLineBookingPeriodSchemeId,
@ -55,7 +54,6 @@ public class BookingPaymentCreationAuthorizationHandlersTests : BookingApplicati
ProductId = BookingTestConsts.BookingProduct1Id, ProductId = BookingTestConsts.BookingProduct1Id,
ProductSkuId = BookingTestConsts.BookingProduct1Sku1Id, ProductSkuId = BookingTestConsts.BookingProduct1Sku1Id,
Quantity = BookingTestConsts.Volume, Quantity = BookingTestConsts.Volume,
ExtraProperties = new ExtraPropertyDictionary()
}; };
orderLine2.SetProperty(BookingOrderProperties.OrderLineBookingPeriodSchemeId, orderLine2.SetProperty(BookingOrderProperties.OrderLineBookingPeriodSchemeId,

Loading…
Cancel
Save