diff --git a/Directory.Build.props b/Directory.Build.props
index 54b2c66e..12dbfb4f 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
7.1.0
2.10.0
- 2.4.0
+ 2.5.0
1.4.0
0.5.0
1.9.0
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderDto.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderDto.cs
index 7e51f46e..e07bada8 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderDto.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderDto.cs
@@ -3,13 +3,16 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
+using EasyAbp.EShop.Orders.Localization;
using EasyAbp.EShop.Stores.Stores;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Localization;
using Volo.Abp.ObjectExtending;
namespace EasyAbp.EShop.Orders.Orders.Dtos
{
[Serializable]
- public class CreateOrderDto : ExtensibleObject, IMultiStore
+ public class CreateOrderDto : ExtensibleObject, ICreateOrderInfo
{
[DisplayName("OrderStoreId")]
public Guid StoreId { get; set; }
@@ -17,6 +20,8 @@ namespace EasyAbp.EShop.Orders.Orders.Dtos
[DisplayName("OrderCustomerRemark")]
public string CustomerRemark { get; set; }
+ IEnumerable ICreateOrderInfo.OrderLines => OrderLines;
+
[DisplayName("OrderLine")]
public List OrderLines { get; set; }
@@ -26,19 +31,20 @@ namespace EasyAbp.EShop.Orders.Orders.Dtos
{
yield return result;
}
-
+
+ var localizer = validationContext.GetRequiredService>();
if (OrderLines.Count == 0)
{
yield return new ValidationResult(
- "OrderLines should not be empty.",
+ localizer[OrdersErrorCodes.OrderLinesShouldNotBeEmpty],
new[] { "OrderLines" }
);
}
-
- if (OrderLines.Any(orderLine => orderLine.Quantity <= 0))
+
+ if (OrderLines.Any(orderLine => orderLine.Quantity < 1))
{
yield return new ValidationResult(
- "Quantity should be greater than 0.",
+ localizer[OrdersErrorCodes.QuantityShouldBeGreaterThanZero],
new[] { "OrderLines" }
);
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderLineDto.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderLineDto.cs
index a92e4c63..a1d8e25b 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderLineDto.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/CreateOrderLineDto.cs
@@ -6,17 +6,17 @@ using Volo.Abp.ObjectExtending;
namespace EasyAbp.EShop.Orders.Orders.Dtos
{
[Serializable]
- public class CreateOrderLineDto : ExtensibleObject
+ public class CreateOrderLineDto : ExtensibleObject, ICreateOrderLineInfo
{
public const int MinimumQuantity = 1;
public const int MaximumQuantity = int.MaxValue;
-
+
[DisplayName("OrderLineProductId")]
public Guid ProductId { get; set; }
-
+
[DisplayName("OrderLineProductSkuId")]
public Guid ProductSkuId { get; set; }
-
+
[DisplayName("OrderLineQuantity")]
[Range(MinimumQuantity, MaximumQuantity)]
public int Quantity { get; set; }
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderDiscountDto.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderDiscountDto.cs
new file mode 100644
index 00000000..5da4e150
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderDiscountDto.cs
@@ -0,0 +1,16 @@
+using System;
+
+namespace EasyAbp.EShop.Orders.Orders.Dtos;
+
+public class OrderDiscountDto
+{
+ public Guid OrderLineId { get; set; }
+
+ public string Name { get; set; }
+
+ public string Key { get; set; }
+
+ public string DisplayName { get; set; }
+
+ public decimal DiscountedAmount { get; set; }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderDto.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderDto.cs
index 85910d3d..462871f2 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderDto.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderDto.cs
@@ -47,8 +47,10 @@ namespace EasyAbp.EShop.Orders.Orders.Dtos
public DateTime? PaymentExpiration { get; set; }
+ IEnumerable IOrder.OrderLines => OrderLines;
public List OrderLines { get; set; }
+ IEnumerable IOrder.OrderExtraFees => OrderExtraFees;
public List OrderExtraFees { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderExtraFeeDto.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderExtraFeeDto.cs
index 91ca226a..25ac14d5 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderExtraFeeDto.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp/EShop/Orders/Orders/Dtos/OrderExtraFeeDto.cs
@@ -2,12 +2,18 @@
namespace EasyAbp.EShop.Orders.Orders.Dtos
{
- public class OrderExtraFeeDto
+ public class OrderExtraFeeDto : IOrderExtraFee
{
+ public Guid OrderId { get; set; }
+
public string Name { get; set; }
-
+
public string Key { get; set; }
-
+
+ public string DisplayName { get; set; }
+
public decimal Fee { get; set; }
+
+ public decimal RefundAmount { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/BasicOrderCreationAuthorizationHandler.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/BasicOrderCreationAuthorizationHandler.cs
index bb857ce5..627f295a 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/BasicOrderCreationAuthorizationHandler.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/BasicOrderCreationAuthorizationHandler.cs
@@ -44,7 +44,7 @@ namespace EasyAbp.EShop.Orders.Orders
context.Succeed(requirement);
}
- protected virtual Task IsProductsPublishedAsync(CreateOrderDto input,
+ protected virtual Task IsProductsPublishedAsync(ICreateOrderInfo input,
Dictionary productDictionary)
{
return Task.FromResult(
@@ -53,7 +53,7 @@ namespace EasyAbp.EShop.Orders.Orders
);
}
- protected virtual Task IsInventoriesSufficientAsync(CreateOrderDto input,
+ protected virtual Task IsInventoriesSufficientAsync(ICreateOrderInfo input,
Dictionary productDictionary)
{
return Task.FromResult(
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/INewOrderGenerator.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/INewOrderGenerator.cs
deleted file mode 100644
index 1d7cd9ad..00000000
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/INewOrderGenerator.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using EasyAbp.EShop.Orders.Orders.Dtos;
-using EasyAbp.EShop.Products.ProductDetails.Dtos;
-using EasyAbp.EShop.Products.Products.Dtos;
-
-namespace EasyAbp.EShop.Orders.Orders
-{
- public interface INewOrderGenerator
- {
- Task GenerateAsync(Guid customerUserId, CreateOrderDto input, Dictionary productDict,
- Dictionary productDetailDict);
- }
-}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderLinePriceOverrider.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderLinePriceOverrider.cs
deleted file mode 100644
index a1440d63..00000000
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderLinePriceOverrider.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System.Threading.Tasks;
-using EasyAbp.EShop.Orders.Orders.Dtos;
-using EasyAbp.EShop.Products.Products.Dtos;
-using NodaMoney;
-
-namespace EasyAbp.EShop.Orders.Orders;
-
-public interface IOrderLinePriceOverrider
-{
- Task GetUnitPriceOrNullAsync(CreateOrderDto input, CreateOrderLineDto inputOrderLine, ProductDto product,
- ProductSkuDto productSku, Currency effectiveCurrency);
-}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderAppService.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderAppService.cs
index 06c5d04d..06d7ba4a 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderAppService.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderAppService.cs
@@ -5,7 +5,6 @@ using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Authorization;
using EasyAbp.EShop.Orders.Orders.Dtos;
using EasyAbp.EShop.Products.ProductDetails;
-using EasyAbp.EShop.Products.ProductDetails.Dtos;
using EasyAbp.EShop.Products.Products;
using EasyAbp.EShop.Products.Products.Dtos;
using EasyAbp.EShop.Stores.Stores;
@@ -102,21 +101,12 @@ namespace EasyAbp.EShop.Orders.Orders
new OrderOperationAuthorizationRequirement(OrderOperation.Creation)
);
- var productDetailIds = input.OrderLines
- .Select(dto =>
- productDict[dto.ProductId].GetSkuById(dto.ProductSkuId).ProductDetailId ??
- productDict[dto.ProductId].ProductDetailId)
- .Where(x => x.HasValue)
- .Select(x => x.Value)
- .ToList();
-
- var productDetailDict = await GetProductDetailDictionaryAsync(productDetailIds);
+ var productDetailModificationTimeDict =
+ await GetProductDetailModificationTimeDictionaryAsync(input, productDict);
// Todo: Can we use IProductDataScopedCache/IProductDetailDataScopedCache instead of productDict/productDetailDict?
- var order = await _newOrderGenerator.GenerateAsync(CurrentUser.GetId(), input, productDict,
- productDetailDict);
-
- await DiscountOrderAsync(order, productDict);
+ var order = await _newOrderGenerator.GenerateAsync(CurrentUser.GetId(), input,
+ productDict.ToDictionary(x => x.Key, x => (IProduct)x.Value), productDetailModificationTimeDict);
await Repository.InsertAsync(order, autoSave: true);
@@ -131,14 +121,6 @@ namespace EasyAbp.EShop.Orders.Orders
}
}
- protected virtual async Task DiscountOrderAsync(Order order, Dictionary productDict)
- {
- foreach (var provider in LazyServiceProvider.LazyGetService>())
- {
- await provider.DiscountAsync(order, productDict);
- }
- }
-
protected virtual async Task> GetProductDictionaryAsync(
IEnumerable productIds)
{
@@ -152,14 +134,23 @@ namespace EasyAbp.EShop.Orders.Orders
return dict;
}
- protected virtual async Task> GetProductDetailDictionaryAsync(
- IEnumerable productDetailIds)
+ protected virtual async Task> GetProductDetailModificationTimeDictionaryAsync(
+ ICreateOrderInfo input, Dictionary productDict)
{
- var dict = new Dictionary();
+ var productDetailIds = input.OrderLines
+ .Select(dto =>
+ productDict[dto.ProductId].GetSkuById(dto.ProductSkuId).ProductDetailId ??
+ productDict[dto.ProductId].ProductDetailId)
+ .Where(x => x.HasValue)
+ .Select(x => x.Value)
+ .ToList();
+
+ var dict = new Dictionary();
foreach (var productDetailId in productDetailIds.Distinct())
{
- dict.Add(productDetailId, await _productDetailAppService.GetAsync(productDetailId));
+ var product = await _productDetailAppService.GetAsync(productDetailId);
+ dict.Add(productDetailId, product.LastModificationTime ?? product.CreationTime);
}
return dict;
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderCreationResource.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderCreationResource.cs
index b71e1fe0..2fe90b2a 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderCreationResource.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderCreationResource.cs
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
-using EasyAbp.EShop.Orders.Orders.Dtos;
using EasyAbp.EShop.Products.Products.Dtos;
namespace EasyAbp.EShop.Orders.Orders
{
public class OrderCreationResource
{
- public CreateOrderDto Input { get; set; }
+ public ICreateOrderInfo Input { get; set; }
public Dictionary ProductDictionary { get; set; }
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs
index 4bdbb7fb..f7427807 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/OrdersApplicationAutoMapperProfile.cs
@@ -14,6 +14,7 @@ namespace EasyAbp.EShop.Orders
* into multiple profile classes for a better organization. */
CreateMap();
CreateMap();
+ CreateMap(MemberList.Destination);
CreateMap(MemberList.Destination);
}
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/en.json b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/en.json
index 6240dc00..75fe3af4 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/en.json
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/en.json
@@ -45,16 +45,33 @@
"OrderLineTotalDiscount": "Total discount",
"OrderLineActualTotalPrice": "Actual total price",
"OrderLineQuantity": "Quantity",
+ "OrderDiscount": "Order discount",
+ "OrderDiscountOrderId": "Order ID",
+ "OrderDiscountOrderLineId": "Order line ID",
+ "OrderDiscountName": "Name",
+ "OrderDiscountKey": "Key",
+ "OrderDiscountDisplayName": "Display name",
+ "OrderDiscountDiscountedAmount": "Discounted amount",
+ "OrderExtraFee": "Order extra fee",
+ "OrderExtraFeeOrderId": "Order ID",
+ "OrderExtraFeeName": "Extra fee name",
+ "OrderExtraFeeKey": "Extra fee key",
+ "OrderExtraFeeDisplayName": "Display name",
+ "OrderExtraFeeFee": "Fee",
+ "OrderExtraFeeRefundAmount": "Refund amount",
"EasyAbp.EShop.Orders:UnexpectedCurrency": "Only the specified currency {expectedCurrency} is allowed.",
"EasyAbp.EShop.Orders:OrderLineInvalidQuantity": "Invalid quantity {quantity} for product {productId} (SKU: {productSkuId}).",
"EasyAbp.EShop.Orders:DiscountAmountOverflow": "The discount amount overflow.",
- "EasyAbp.EShop.Orders:DuplicateOrderExtraFee": "The extra fee {extraFeeName} (key: {extraFeeKey}) is existed.",
+ "EasyAbp.EShop.Orders:DuplicateOrderDiscount": "The discount {discountName} (key: {discountKey}) of order line {orderLineId} already exists.",
+ "EasyAbp.EShop.Orders:DuplicateOrderExtraFee": "The extra fee {extraFeeName} (key: {extraFeeKey}) already exists.",
"EasyAbp.EShop.Orders:InvalidOrderExtraFee": "The extra fee {extraFee} is invalid.",
"EasyAbp.EShop.Orders:InvalidPayment": "The payment {paymentId} has invalid configurations for the order {orderId}.",
"EasyAbp.EShop.Orders:InvalidRefundAmount": "The refund amount ({amount}) is invalid.",
"EasyAbp.EShop.Orders:InvalidRefundQuantity": "The refund quantity ({quantity}) is invalid.",
"EasyAbp.EShop.Orders:OrderIsInWrongStage": "The order {orderId} is in the wrong stage.",
- "EasyAbp.EShop.Orders:ExistFlashSalesProduct": "Exist unexpected flash-sales product",
+ "EasyAbp.EShop.Orders:ExistFlashSalesProduct": "Exist unexpected flash-sales product.",
+ "EasyAbp.EShop.Orders:OrderLinesShouldNotBeEmpty": "OrderLines should not be empty.",
+ "EasyAbp.EShop.Orders:QuantityShouldBeGreaterThanZero": "Quantity should be greater than 0.",
"DisplayName:EasyAbp.EShop.Orders.CurrencyCode": "Currency code",
"Description:EasyAbp.EShop.Orders.CurrencyCode": "ISO 4217 code (see https://en.wikipedia.org/wiki/ISO_4217)"
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hans.json b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hans.json
index a4f962f4..a4c3217a 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hans.json
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hans.json
@@ -45,9 +45,24 @@
"OrderLineTotalDiscount": "总折扣",
"OrderLineActualTotalPrice": "折后总价",
"OrderLineQuantity": "数量",
+ "OrderDiscount": "订单折扣项",
+ "OrderDiscountOrderId": "订单 ID",
+ "OrderDiscountOrderLineId": "订单项 ID",
+ "OrderDiscountName": "折扣项名称",
+ "OrderDiscountKey": "折扣项 Key",
+ "OrderDiscountDisplayName": "显示名称",
+ "OrderDiscountDiscountedAmount": "折扣金额",
+ "OrderExtraFee": "订单额外费用",
+ "OrderExtraFeeOrderId": "订单 ID",
+ "OrderExtraFeeName": "额外费用名称",
+ "OrderExtraFeeKey": "额外费用 Key",
+ "OrderExtraFeeDisplayName": "显示名称",
+ "OrderExtraFeeFee": "金额",
+ "OrderExtraFeeRefundAmount": "已退款金额",
"EasyAbp.EShop.Orders:UnexpectedCurrency": "只允许指定的{expectedCurrency}货币",
"EasyAbp.EShop.Orders:OrderLineInvalidQuantity": "产品{productId}(SKU: {productSkuId})的{quantity}数量无效",
"EasyAbp.EShop.Orders:DiscountAmountOverflow": "折扣金额溢出",
+ "EasyAbp.EShop.Orders:DuplicateOrderDiscount": "订单项{orderLineId}的折扣项{discountName}(key: {discountKey})已经存在",
"EasyAbp.EShop.Orders:DuplicateOrderExtraFee": "额外费用{extraFeeName}(key: {extraFeeKey})已经存在",
"EasyAbp.EShop.Orders:InvalidOrderExtraFee": "额外费用{extraFee}无效",
"EasyAbp.EShop.Orders:InvalidPayment": "付款{paymentId}有无效的订单配置{orderId}",
@@ -55,6 +70,8 @@
"EasyAbp.EShop.Orders:InvalidRefundQuantity": "退款数量({quantity})无效",
"EasyAbp.EShop.Orders:OrderIsInWrongStage": "订单{orderId}处于错误的阶段",
"EasyAbp.EShop.Orders:ExistFlashSalesProduct": "清单中不允许存在闪购产品",
+ "EasyAbp.EShop.Orders:OrderLinesShouldNotBeEmpty": "订单项不可为空",
+ "EasyAbp.EShop.Orders:QuantityShouldBeGreaterThanZero": "购买数量应大于0",
"DisplayName:EasyAbp.EShop.Orders.CurrencyCode": "货币代码",
"Description:EasyAbp.EShop.Orders.CurrencyCode": "ISO 4217 货币代码 (详见 https://en.wikipedia.org/wiki/ISO_4217)"
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hant.json b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hant.json
index 7db41b9f..b3aabc95 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hant.json
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Localization/Orders/zh-Hant.json
@@ -45,9 +45,24 @@
"OrderLineTotalDiscount": "總折扣",
"OrderLineActualTotalPrice": "折後總價",
"OrderLineQuantity": "數量",
+ "OrderDiscount": "訂單折扣項",
+ "OrderDiscountOrderId": "訂單 ID",
+ "OrderDiscountOrderLineId": "訂單項 ID",
+ "OrderDiscountName": "折扣項名稱",
+ "OrderDiscountKey": "折扣項 Key",
+ "OrderDiscountDisplayName": "顯示名稱",
+ "OrderDiscountDiscountedAmount": "折扣金額",
+ "OrderExtraFee": "訂單額外費用",
+ "OrderExtraFeeOrderId": "訂單 ID",
+ "OrderExtraFeeName": "額外費用名稱",
+ "OrderExtraFeeKey": "額外費用 Key",
+ "OrderExtraFeeDisplayName": "顯示名稱",
+ "OrderExtraFeeFee": "金額",
+ "OrderExtraFeeRefundAmount": "已退款金額",
"EasyAbp.EShop.Orders:UnexpectedCurrency": "只允許指定的{expectedCurrency}貨幣",
"EasyAbp.EShop.Orders:OrderLineInvalidQuantity": "產品{productId}(SKU: {productSkuId})的{quantity}數量無效",
"EasyAbp.EShop.Orders:DiscountAmountOverflow": "折扣金額溢出",
+ "EasyAbp.EShop.Orders:DuplicateOrderDiscount": "訂單項{orderLineId}的折扣項{discountName}(key: {discountKey})已經存在",
"EasyAbp.EShop.Orders:DuplicateOrderExtraFee": "額外費用{extraFeeName}(key: {extraFeeKey})已經存在",
"EasyAbp.EShop.Orders:InvalidOrderExtraFee": "額外費用{extraFee}無效",
"EasyAbp.EShop.Orders:InvalidPayment": "付款{paymentId}有無效的訂單配置{orderId}",
@@ -55,6 +70,8 @@
"EasyAbp.EShop.Orders:InvalidRefundQuantity": "退款數量({quantity})無效",
"EasyAbp.EShop.Orders:OrderIsInWrongStage": "訂單{orderId}處於錯誤的階段",
"EasyAbp.EShop.Orders:ExistFlashSalesProduct": "清單中不允許存在閃購產品",
+ "EasyAbp.EShop.Orders:OrderLinesShouldNotBeEmpty": "訂單項不可為空",
+ "EasyAbp.EShop.Orders:QuantityShouldBeGreaterThanZero": "購買數量應大於0",
"DisplayName:EasyAbp.EShop.Orders.CurrencyCode": "貨幣代碼",
"Description:EasyAbp.EShop.Orders.CurrencyCode": "ISO 4217 貨幣代碼 (詳見 https://en.wikipedia.org/wiki/ISO_4217)"
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/CreateOrderInfoModel.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/CreateOrderInfoModel.cs
new file mode 100644
index 00000000..14552436
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/CreateOrderInfoModel.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using Volo.Abp.ObjectExtending;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+[Serializable]
+public class CreateOrderInfoModel : ExtensibleObject, ICreateOrderInfo
+{
+ public Guid StoreId { get; set; }
+
+ public string CustomerRemark { get; set; }
+
+ IEnumerable ICreateOrderInfo.OrderLines => OrderLines;
+ public List OrderLines { get; set; }
+
+ public CreateOrderInfoModel()
+ {
+ }
+
+ public CreateOrderInfoModel(Guid storeId, string customerRemark, List orderLines)
+ {
+ StoreId = storeId;
+ CustomerRemark = customerRemark;
+ OrderLines = orderLines;
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/CreateOrderLineInfoModel.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/CreateOrderLineInfoModel.cs
new file mode 100644
index 00000000..dae46aed
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/CreateOrderLineInfoModel.cs
@@ -0,0 +1,25 @@
+using System;
+using Volo.Abp.ObjectExtending;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+[Serializable]
+public class CreateOrderLineInfoModel : ExtensibleObject, ICreateOrderLineInfo
+{
+ public Guid ProductId { get; set; }
+
+ public Guid ProductSkuId { get; set; }
+
+ public int Quantity { get; set; }
+
+ public CreateOrderLineInfoModel()
+ {
+ }
+
+ public CreateOrderLineInfoModel(Guid productId, Guid productSkuId, int quantity)
+ {
+ ProductId = productId;
+ ProductSkuId = productSkuId;
+ Quantity = quantity;
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/ICreateOrderInfo.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/ICreateOrderInfo.cs
new file mode 100644
index 00000000..4b772389
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/ICreateOrderInfo.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+using EasyAbp.EShop.Stores.Stores;
+using Volo.Abp.Data;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+public interface ICreateOrderInfo : IMultiStore, IHasExtraProperties
+{
+ string CustomerRemark { get; }
+
+ IEnumerable OrderLines { get; }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/ICreateOrderLineInfo.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/ICreateOrderLineInfo.cs
new file mode 100644
index 00000000..b3220046
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/ICreateOrderLineInfo.cs
@@ -0,0 +1,13 @@
+using System;
+using Volo.Abp.Data;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+public interface ICreateOrderLineInfo : IHasExtraProperties
+{
+ Guid ProductId { get; }
+
+ Guid ProductSkuId { get; }
+
+ int Quantity { get; }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrder.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrder.cs
index fc205188..4b3ed8bf 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrder.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrder.cs
@@ -1,50 +1,63 @@
using System;
+using System.Collections.Generic;
using EasyAbp.EShop.Stores.Stores;
+using JetBrains.Annotations;
using Volo.Abp.Data;
namespace EasyAbp.EShop.Orders.Orders
{
public interface IOrder : IMultiStore, IHasExtraProperties
{
+ Guid Id { get; }
+
+ [NotNull]
string OrderNumber { get; }
-
+
Guid CustomerUserId { get; }
-
+
OrderStatus OrderStatus { get; }
+ [NotNull]
string Currency { get; }
-
+
decimal ProductTotalPrice { get; }
-
+
decimal TotalDiscount { get; }
-
+
decimal TotalPrice { get; }
-
+
///
/// ActualTotalPrice = TotalPrice - TotalDiscount
///
decimal ActualTotalPrice { get; }
decimal RefundAmount { get; }
-
+
+ [CanBeNull]
string CustomerRemark { get; }
-
+
+ [CanBeNull]
string StaffRemark { get; }
-
+
Guid? PaymentId { get; }
-
+
DateTime? PaidTime { get; }
-
+
DateTime? CompletionTime { get; }
-
+
DateTime? CanceledTime { get; }
-
+
+ [CanBeNull]
string CancellationReason { get; }
-
+
DateTime? ReducedInventoryAfterPlacingTime { get; }
-
+
DateTime? ReducedInventoryAfterPaymentTime { get; }
-
+
DateTime? PaymentExpiration { get; }
+
+ IEnumerable OrderLines { get; }
+
+ IEnumerable OrderExtraFees { get; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderExtraFee.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderExtraFee.cs
new file mode 100644
index 00000000..f09f5546
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderExtraFee.cs
@@ -0,0 +1,23 @@
+using System;
+using JetBrains.Annotations;
+
+namespace EasyAbp.EShop.Orders.Orders
+{
+ public interface IOrderExtraFee
+ {
+ Guid OrderId { get; }
+
+ [NotNull]
+ string Name { get; }
+
+ [CanBeNull]
+ string Key { get; }
+
+ [CanBeNull]
+ string DisplayName { get; }
+
+ decimal Fee { get; }
+
+ decimal RefundAmount { get; }
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderLine.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderLine.cs
index f63f14a3..b807d1fb 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderLine.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/IOrderLine.cs
@@ -1,11 +1,14 @@
using System;
using EasyAbp.EShop.Products.Products;
+using JetBrains.Annotations;
using Volo.Abp.Data;
namespace EasyAbp.EShop.Orders.Orders
{
- public interface IOrderLine : IHasExtraProperties
+ public interface IOrderLine : IHasExtraProperties, IHasProductGroupDisplayName
{
+ Guid Id { get; }
+
Guid ProductId { get; }
Guid ProductSkuId { get; }
@@ -16,12 +19,13 @@ namespace EasyAbp.EShop.Orders.Orders
DateTime? ProductDetailModificationTime { get; }
+ [NotNull]
string ProductGroupName { get; }
- string ProductGroupDisplayName { get; }
-
+ [CanBeNull]
string ProductUniqueName { get; }
+ [NotNull]
string ProductDisplayName { get; }
///
@@ -30,12 +34,16 @@ namespace EasyAbp.EShop.Orders.Orders
///
InventoryStrategy? ProductInventoryStrategy { get; }
+ [CanBeNull]
string SkuName { get; }
+ [CanBeNull]
string SkuDescription { get; }
+ [CanBeNull]
string MediaResources { get; }
+ [NotNull]
string Currency { get; }
decimal UnitPrice { get; }
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderEto.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderEto.cs
index 534aa74e..e9ea4c98 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderEto.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderEto.cs
@@ -54,8 +54,12 @@ namespace EasyAbp.EShop.Orders.Orders
public DateTime? PaymentExpiration { get; set; }
+ IEnumerable IOrder.OrderLines => OrderLines;
public List OrderLines { get; set; }
-
+
+ IEnumerable IOrder.OrderExtraFees => OrderExtraFees;
+ public List OrderExtraFees { get; set; }
+
public DateTime CreationTime { get; set; }
public Guid? CreatorId { get; set; }
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderExtraFeeEto.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderExtraFeeEto.cs
new file mode 100644
index 00000000..148a30cd
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderExtraFeeEto.cs
@@ -0,0 +1,20 @@
+using System;
+
+namespace EasyAbp.EShop.Orders.Orders
+{
+ [Serializable]
+ public class OrderExtraFeeEto : IOrderExtraFee
+ {
+ public Guid OrderId { get; set; }
+
+ public string Name { get; set; }
+
+ public string Key { get; set; }
+
+ public string DisplayName { get; set; }
+
+ public decimal Fee { get; set; }
+
+ public decimal RefundAmount { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/OrdersErrorCodes.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/OrdersErrorCodes.cs
index d87dd982..84cdfe3f 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/OrdersErrorCodes.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/OrdersErrorCodes.cs
@@ -6,11 +6,14 @@
public const string OrderLineInvalidQuantity = "EasyAbp.EShop.Orders:OrderLineInvalidQuantity";
public const string DiscountAmountOverflow = "EasyAbp.EShop.Orders:DiscountAmountOverflow";
public const string DuplicateOrderExtraFee = "EasyAbp.EShop.Orders:DuplicateOrderExtraFee";
+ public const string DuplicateOrderDiscount = "EasyAbp.EShop.Orders:DuplicateOrderDiscount";
public const string InvalidOrderExtraFee = "EasyAbp.EShop.Orders:InvalidOrderExtraFee";
public const string InvalidPayment = "EasyAbp.EShop.Orders:InvalidPayment";
public const string InvalidRefundAmount = "EasyAbp.EShop.Orders:InvalidRefundAmount";
public const string InvalidRefundQuantity = "EasyAbp.EShop.Orders:InvalidRefundQuantity";
public const string OrderIsInWrongStage = "EasyAbp.EShop.Orders:OrderIsInWrongStage";
public const string ExistFlashSalesProduct = "EasyAbp.EShop.Orders:ExistFlashSalesProduct";
+ public const string OrderLinesShouldNotBeEmpty = "EasyAbp.EShop.Orders:OrderLinesShouldNotBeEmpty";
+ public const string QuantityShouldBeGreaterThanZero = "EasyAbp.EShop.Orders:QuantityShouldBeGreaterThanZero";
}
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/DuplicateOrderDiscountException.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/DuplicateOrderDiscountException.cs
new file mode 100644
index 00000000..77a7e34b
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/DuplicateOrderDiscountException.cs
@@ -0,0 +1,16 @@
+using System;
+using Volo.Abp;
+
+namespace EasyAbp.EShop.Orders.Orders
+{
+ public class DuplicateOrderDiscountException : BusinessException
+ {
+ public DuplicateOrderDiscountException(Guid orderLineId, string discountName, string discountKey) : base(
+ OrdersErrorCodes.DuplicateOrderDiscount)
+ {
+ WithData(nameof(orderLineId), orderLineId);
+ WithData(nameof(discountName), discountName);
+ WithData(nameof(discountKey), discountKey);
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/INewOrderGenerator.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/INewOrderGenerator.cs
new file mode 100644
index 00000000..90ff7d0e
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/INewOrderGenerator.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using EasyAbp.EShop.Products.Products;
+
+namespace EasyAbp.EShop.Orders.Orders
+{
+ public interface INewOrderGenerator
+ {
+ Task GenerateAsync(Guid customerUserId, ICreateOrderInfo input, Dictionary productDict,
+ Dictionary productDetailModificationTimeDict);
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderDiscountProvider.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderDiscountProvider.cs
similarity index 54%
rename from modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderDiscountProvider.cs
rename to modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderDiscountProvider.cs
index 3de5c09f..f817308c 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderDiscountProvider.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderDiscountProvider.cs
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using EasyAbp.EShop.Products.Products.Dtos;
+using EasyAbp.EShop.Products.Products;
namespace EasyAbp.EShop.Orders.Orders
{
public interface IOrderDiscountProvider
{
- Task DiscountAsync(Order order, Dictionary productDict);
+ Task> GetAllAsync(Order order, Dictionary productDict);
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderExtraFeeProvider.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderExtraFeeProvider.cs
similarity index 56%
rename from modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderExtraFeeProvider.cs
rename to modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderExtraFeeProvider.cs
index 9cd5ba9d..848d32c1 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/IOrderExtraFeeProvider.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderExtraFeeProvider.cs
@@ -1,15 +1,14 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using EasyAbp.EShop.Orders.Orders.Dtos;
-using EasyAbp.EShop.Products.Products.Dtos;
+using EasyAbp.EShop.Products.Products;
using NodaMoney;
namespace EasyAbp.EShop.Orders.Orders
{
public interface IOrderExtraFeeProvider
{
- Task> GetListAsync(Guid customerUserId, CreateOrderDto input,
- Dictionary productDict, Currency effectiveCurrency);
+ Task> GetListAsync(Guid customerUserId, ICreateOrderInfo input,
+ Dictionary productDict, Currency effectiveCurrency);
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderLinePriceOverrider.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderLinePriceOverrider.cs
new file mode 100644
index 00000000..73f86e44
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderLinePriceOverrider.cs
@@ -0,0 +1,11 @@
+using System.Threading.Tasks;
+using EasyAbp.EShop.Products.Products;
+using NodaMoney;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+public interface IOrderLinePriceOverrider
+{
+ Task GetUnitPriceOrNullAsync(ICreateOrderInfo input, ICreateOrderLineInfo inputOrderLine,
+ IProduct product, IProductSku productSku, Currency effectiveCurrency);
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs
similarity index 67%
rename from modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs
rename to modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs
index fa253029..859d09b6 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs
@@ -2,57 +2,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using EasyAbp.EShop.Orders.Orders.Dtos;
using EasyAbp.EShop.Orders.Settings;
-using EasyAbp.EShop.Products.ProductDetails.Dtos;
using EasyAbp.EShop.Products.Products;
-using EasyAbp.EShop.Products.Products.Dtos;
-using Microsoft.Extensions.DependencyInjection;
using NodaMoney;
using Volo.Abp;
+using Volo.Abp.Auditing;
using Volo.Abp.DependencyInjection;
-using Volo.Abp.Guids;
-using Volo.Abp.MultiTenancy;
+using Volo.Abp.Domain.Services;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Settings;
-using Volo.Abp.Timing;
namespace EasyAbp.EShop.Orders.Orders
{
- public class NewOrderGenerator : INewOrderGenerator, ITransientDependency
+ public class NewOrderGenerator : DomainService, INewOrderGenerator, ITransientDependency
{
- private readonly IClock _clock;
- private readonly IGuidGenerator _guidGenerator;
- private readonly ICurrentTenant _currentTenant;
private readonly ISettingProvider _settingProvider;
- private readonly IServiceProvider _serviceProvider;
private readonly IOrderNumberGenerator _orderNumberGenerator;
private readonly IProductSkuDescriptionProvider _productSkuDescriptionProvider;
private readonly IEnumerable _orderLinePriceOverriders;
public NewOrderGenerator(
- IClock clock,
- IGuidGenerator guidGenerator,
- ICurrentTenant currentTenant,
ISettingProvider settingProvider,
- IServiceProvider serviceProvider,
IOrderNumberGenerator orderNumberGenerator,
IProductSkuDescriptionProvider productSkuDescriptionProvider,
IEnumerable orderLinePriceOverriders)
{
- _clock = clock;
- _guidGenerator = guidGenerator;
- _currentTenant = currentTenant;
_settingProvider = settingProvider;
- _serviceProvider = serviceProvider;
_orderNumberGenerator = orderNumberGenerator;
_productSkuDescriptionProvider = productSkuDescriptionProvider;
_orderLinePriceOverriders = orderLinePriceOverriders;
}
- public virtual async Task GenerateAsync(Guid customerUserId, CreateOrderDto input,
- Dictionary productDict, Dictionary productDetailDict)
+ public virtual async Task GenerateAsync(Guid customerUserId, ICreateOrderInfo input,
+ Dictionary productDict, Dictionary productDetailModificationTimeDict)
{
+ await ValidateInputAsync(input);
+
var effectiveCurrency = await GetEffectiveCurrencyAsync();
var orderLines = new List();
@@ -60,7 +45,7 @@ namespace EasyAbp.EShop.Orders.Orders
foreach (var inputOrderLine in input.OrderLines)
{
orderLines.Add(await GenerateOrderLineAsync(
- input, inputOrderLine, productDict, productDetailDict, effectiveCurrency));
+ input, inputOrderLine, productDict, productDetailModificationTimeDict, effectiveCurrency));
}
var productTotalPrice = orderLines.Select(x => x.TotalPrice).Sum();
@@ -72,8 +57,8 @@ namespace EasyAbp.EShop.Orders.Orders
var totalDiscount = orderLines.Select(x => x.TotalDiscount).Sum();
var order = new Order(
- id: _guidGenerator.Create(),
- tenantId: _currentTenant.Id,
+ id: GuidGenerator.Create(),
+ tenantId: CurrentTenant.Id,
storeId: input.StoreId,
customerUserId: customerUserId,
currency: effectiveCurrency.Code,
@@ -82,7 +67,7 @@ namespace EasyAbp.EShop.Orders.Orders
totalPrice: totalPrice,
actualTotalPrice: totalPrice - totalDiscount,
customerRemark: input.CustomerRemark,
- paymentExpiration: paymentExpireIn.HasValue ? _clock.Now.Add(paymentExpireIn.Value) : null
+ paymentExpiration: paymentExpireIn.HasValue ? Clock.Now.Add(paymentExpireIn.Value) : null
);
input.MapExtraPropertiesTo(order, MappingPropertyDefinitionChecks.Destination);
@@ -97,16 +82,47 @@ namespace EasyAbp.EShop.Orders.Orders
// see https://github.com/EasyAbp/EShop/issues/214
if (order.OrderLines.All(x => x.ProductInventoryStrategy != InventoryStrategy.ReduceAfterPlacing))
{
- order.SetReducedInventoryAfterPlacingTime(_clock.Now);
+ order.SetReducedInventoryAfterPlacingTime(Clock.Now);
}
+ await DiscountOrderAsync(order, productDict);
+
return order;
}
+ protected virtual Task ValidateInputAsync(ICreateOrderInfo info)
+ {
+ if (!info.OrderLines.Any())
+ {
+ throw new BusinessException(OrdersErrorCodes.OrderLinesShouldNotBeEmpty);
+ }
+
+ if (info.OrderLines.Any(orderLine => orderLine.Quantity < 1))
+ {
+ throw new BusinessException(OrdersErrorCodes.QuantityShouldBeGreaterThanZero);
+ }
+
+ return Task.CompletedTask;
+ }
+
+ protected virtual async Task DiscountOrderAsync(Order order, Dictionary productDict)
+ {
+ foreach (var provider in LazyServiceProvider.LazyGetService>())
+ {
+ var discounts = await provider.GetAllAsync(order, productDict);
+
+ foreach (var discount in discounts)
+ {
+ order.AddDiscount(discount.OrderLineId, discount.Name, discount.Key, discount.DisplayName,
+ discount.DiscountedAmount);
+ }
+ }
+ }
+
protected virtual async Task AddOrderExtraFeesAsync(Order order, Guid customerUserId,
- CreateOrderDto input, Dictionary productDict, Currency effectiveCurrency)
+ ICreateOrderInfo input, Dictionary productDict, Currency effectiveCurrency)
{
- var providers = _serviceProvider.GetServices();
+ var providers = LazyServiceProvider.LazyGetService>();
foreach (var provider in providers)
{
@@ -115,25 +131,27 @@ namespace EasyAbp.EShop.Orders.Orders
foreach (var infoModel in infoModels)
{
var fee = new Money(infoModel.Fee, effectiveCurrency);
- order.AddOrderExtraFee(fee.Amount, infoModel.Name, infoModel.Key);
+ order.AddOrderExtraFee(fee.Amount, infoModel.Name, infoModel.Key, infoModel.DisplayName);
}
}
}
- protected virtual async Task GenerateOrderLineAsync(CreateOrderDto input,
- CreateOrderLineDto inputOrderLine, Dictionary productDict,
- Dictionary productDetailDict, Currency effectiveCurrency)
+ protected virtual async Task GenerateOrderLineAsync(ICreateOrderInfo input,
+ ICreateOrderLineInfo inputOrderLine, Dictionary productDict,
+ Dictionary productDetailModificationTimeDict, Currency effectiveCurrency)
{
var product = productDict[inputOrderLine.ProductId];
var productSku = product.GetSkuById(inputOrderLine.ProductSkuId);
-
+
if (productSku.Currency != effectiveCurrency.Code)
{
throw new UnexpectedCurrencyException(effectiveCurrency.Code);
}
var productDetailId = productSku.ProductDetailId ?? product.ProductDetailId;
- var productDetail = productDetailId.HasValue ? productDetailDict[productDetailId.Value] : null;
+ var productDetailModificationTime = productDetailId.HasValue
+ ? productDetailModificationTimeDict[productDetailId.Value]
+ : (DateTime?)null;
if (!inputOrderLine.Quantity.IsBetween(productSku.OrderMinQuantity, productSku.OrderMaxQuantity))
{
@@ -145,14 +163,18 @@ namespace EasyAbp.EShop.Orders.Orders
var totalPrice = unitPrice * inputOrderLine.Quantity;
var orderLine = new OrderLine(
- id: _guidGenerator.Create(),
+ id: GuidGenerator.Create(),
productId: product.Id,
productSkuId: productSku.Id,
productDetailId: productDetailId,
- productModificationTime: product.LastModificationTime ?? product.CreationTime,
- productDetailModificationTime: productDetail?.LastModificationTime ?? productDetail?.CreationTime,
+ productModificationTime: product is IAuditedObject auditedProduct
+ ? auditedProduct.LastModificationTime ?? auditedProduct.CreationTime
+ : Clock.Now,
+ productDetailModificationTime: productDetailModificationTime,
productGroupName: product.ProductGroupName,
- productGroupDisplayName: product.ProductGroupDisplayName,
+ productGroupDisplayName: product is IHasProductGroupDisplayName hasProductGroupDisplayName
+ ? hasProductGroupDisplayName.ProductGroupDisplayName
+ : product.ProductGroupName,
productUniqueName: product.UniqueName,
productDisplayName: product.DisplayName,
productInventoryStrategy: product.InventoryStrategy,
@@ -172,8 +194,8 @@ namespace EasyAbp.EShop.Orders.Orders
return orderLine;
}
- protected virtual async Task GetUnitPriceAsync(CreateOrderDto input, CreateOrderLineDto inputOrderLine,
- ProductDto product, ProductSkuDto productSku, Currency effectiveCurrency)
+ protected virtual async Task GetUnitPriceAsync(ICreateOrderInfo input,
+ ICreateOrderLineInfo inputOrderLine, IProduct product, IProductSku productSku, Currency effectiveCurrency)
{
foreach (var overrider in _orderLinePriceOverriders)
{
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/Order.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/Order.cs
index 06fa086c..d583482b 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/Order.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/Order.cs
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
-using EasyAbp.EShop.Stores.Stores;
using System.Linq;
using JetBrains.Annotations;
-using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
@@ -12,54 +10,54 @@ namespace EasyAbp.EShop.Orders.Orders
public class Order : FullAuditedAggregateRoot, IOrder, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }
-
+
public virtual Guid StoreId { get; protected set; }
-
- [NotNull]
+
public virtual string OrderNumber { get; protected set; }
-
+
public virtual Guid CustomerUserId { get; protected set; }
-
+
public virtual OrderStatus OrderStatus { get; protected set; }
- [NotNull]
public virtual string Currency { get; protected set; }
-
+
public virtual decimal ProductTotalPrice { get; protected set; }
-
+
public virtual decimal TotalDiscount { get; protected set; }
-
+
public virtual decimal TotalPrice { get; protected set; }
-
+
public virtual decimal ActualTotalPrice { get; protected set; }
public virtual decimal RefundAmount { get; protected set; }
-
- [CanBeNull]
+
public virtual string CustomerRemark { get; protected set; }
-
- [CanBeNull]
+
public virtual string StaffRemark { get; protected set; }
-
+
public virtual Guid? PaymentId { get; protected set; }
-
+
public virtual DateTime? PaidTime { get; protected set; }
-
+
public virtual DateTime? CompletionTime { get; protected set; }
-
+
public virtual DateTime? CanceledTime { get; protected set; }
-
- [CanBeNull]
+
public virtual string CancellationReason { get; protected set; }
public virtual DateTime? ReducedInventoryAfterPlacingTime { get; protected set; }
-
+
public virtual DateTime? ReducedInventoryAfterPaymentTime { get; protected set; }
-
+
public virtual DateTime? PaymentExpiration { get; protected set; }
-
+
+ IEnumerable IOrder.OrderLines => OrderLines;
public virtual List OrderLines { get; protected set; }
-
+
+ IEnumerable IOrder.OrderExtraFees => OrderExtraFees;
+
+ public virtual List OrderDiscounts { get; protected set; }
+
public virtual List OrderExtraFees { get; protected set; }
protected Order()
@@ -92,9 +90,10 @@ namespace EasyAbp.EShop.Orders.Orders
PaymentExpiration = paymentExpiration;
RefundAmount = 0;
-
+
OrderStatus = OrderStatus.Pending;
OrderLines = new List();
+ OrderDiscounts = new List();
OrderExtraFees = new List();
}
@@ -187,35 +186,47 @@ namespace EasyAbp.EShop.Orders.Orders
return !(!PaymentId.HasValue || PaidTime.HasValue);
}
- public void AddDiscount(Guid orderLineId, decimal expectedDiscountAmount)
+ public void AddDiscount(Guid orderLineId, [NotNull] string discountName, [CanBeNull] string discountKey,
+ [CanBeNull] string discountDisplayName, decimal discountedAmount)
{
var orderLine = OrderLines.Single(x => x.Id == orderLineId);
- orderLine.AddDiscount(expectedDiscountAmount);
-
- TotalDiscount += expectedDiscountAmount;
- ActualTotalPrice -= expectedDiscountAmount;
+ orderLine.AddDiscount(discountedAmount);
+
+ TotalDiscount += discountedAmount;
+ ActualTotalPrice -= discountedAmount;
if (ActualTotalPrice < decimal.Zero)
{
throw new DiscountAmountOverflowException();
}
+
+ if (OrderDiscounts.Any(x => x.OrderLineId == orderLineId && x.Name == discountName && x.Key == discountKey))
+ {
+ throw new DuplicateOrderDiscountException(orderLineId, discountName, discountKey);
+ }
+
+ var orderDiscount = new OrderDiscount(
+ Id, orderLineId, discountName, discountKey, discountDisplayName, discountedAmount);
+
+ OrderDiscounts.Add(orderDiscount);
}
- public void AddOrderExtraFee(decimal extraFee, [NotNull] string extraFeeName, [CanBeNull] string extraFeeKey)
+ public void AddOrderExtraFee(decimal extraFee, [NotNull] string extraFeeName, [CanBeNull] string extraFeeKey,
+ [CanBeNull] string extraFeeDisplayName)
{
if (extraFee <= decimal.Zero)
{
throw new InvalidOrderExtraFeeException(extraFee);
}
-
- var orderExtraFee = new OrderExtraFee(Id, extraFeeName, extraFeeKey, extraFee);
- if (OrderExtraFees.Any(x => x.EntityEquals(orderExtraFee)))
+ if (OrderExtraFees.Any(x => x.Name == extraFeeName && x.Key == extraFeeKey))
{
throw new DuplicateOrderExtraFeeException(extraFeeName, extraFeeKey);
}
-
+
+ var orderExtraFee = new OrderExtraFee(Id, extraFeeName, extraFeeKey, extraFeeDisplayName, extraFee);
+
OrderExtraFees.Add(orderExtraFee);
TotalPrice += extraFee;
@@ -233,4 +244,4 @@ namespace EasyAbp.EShop.Orders.Orders
PaidTime.HasValue && !ReducedInventoryAfterPaymentTime.HasValue;
}
}
-}
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderDiscount.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderDiscount.cs
new file mode 100644
index 00000000..7c8f46d0
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderDiscount.cs
@@ -0,0 +1,48 @@
+using System;
+using JetBrains.Annotations;
+using Volo.Abp.Domain.Entities;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+public class OrderDiscount : Entity
+{
+ public virtual Guid OrderId { get; protected set; }
+
+ public virtual Guid OrderLineId { get; protected set; }
+
+ [NotNull]
+ public virtual string Name { get; protected set; }
+
+ [CanBeNull]
+ public virtual string Key { get; protected set; }
+
+ [CanBeNull]
+ public virtual string DisplayName { get; protected set; }
+
+ public virtual decimal DiscountedAmount { get; protected set; }
+
+ protected OrderDiscount()
+ {
+ }
+
+ public OrderDiscount(
+ Guid orderId,
+ Guid orderLineId,
+ [NotNull] string name,
+ [CanBeNull] string key,
+ [CanBeNull] string displayName,
+ decimal discountedAmount)
+ {
+ OrderId = orderId;
+ OrderLineId = orderLineId;
+ Name = name;
+ Key = key;
+ DisplayName = displayName;
+ DiscountedAmount = discountedAmount;
+ }
+
+ public override object[] GetKeys()
+ {
+ return new object[] { OrderId, OrderLineId, Name, Key };
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderDiscountInfoModel.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderDiscountInfoModel.cs
new file mode 100644
index 00000000..0e0aec48
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderDiscountInfoModel.cs
@@ -0,0 +1,34 @@
+using System;
+using JetBrains.Annotations;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+public class OrderDiscountInfoModel
+{
+ public Guid OrderLineId { get; set; }
+
+ [NotNull]
+ public string Name { get; set; }
+
+ [CanBeNull]
+ public string Key { get; set; }
+
+ [CanBeNull]
+ public string DisplayName { get; set; }
+
+ public decimal DiscountedAmount { get; set; }
+
+ public OrderDiscountInfoModel(
+ Guid orderLineId,
+ [NotNull] string name,
+ [CanBeNull] string key,
+ [CanBeNull] string displayName,
+ decimal discountedAmount)
+ {
+ OrderLineId = orderLineId;
+ Name = name;
+ Key = key ?? string.Empty;
+ DisplayName = displayName;
+ DiscountedAmount = discountedAmount;
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderExtraFee.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderExtraFee.cs
index 1d2f85bd..e6474281 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderExtraFee.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderExtraFee.cs
@@ -4,7 +4,7 @@ using Volo.Abp.Domain.Entities;
namespace EasyAbp.EShop.Orders.Orders
{
- public class OrderExtraFee : Entity
+ public class OrderExtraFee : Entity, IOrderExtraFee
{
public virtual Guid OrderId { get; protected set; }
@@ -13,6 +13,9 @@ namespace EasyAbp.EShop.Orders.Orders
[CanBeNull]
public virtual string Key { get; protected set; }
+
+ [CanBeNull]
+ public virtual string DisplayName { get; protected set; }
public virtual decimal Fee { get; protected set; }
@@ -26,11 +29,13 @@ namespace EasyAbp.EShop.Orders.Orders
Guid orderId,
[NotNull] string name,
[CanBeNull] string key,
+ [CanBeNull] string displayName,
decimal fee)
{
OrderId = orderId;
Name = name;
Key = key;
+ DisplayName = displayName;
Fee = fee;
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderExtraFeeInfoModel.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderExtraFeeInfoModel.cs
similarity index 77%
rename from modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderExtraFeeInfoModel.cs
rename to modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderExtraFeeInfoModel.cs
index cdd7bc2e..15cba7ec 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderExtraFeeInfoModel.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderExtraFeeInfoModel.cs
@@ -6,18 +6,23 @@ namespace EasyAbp.EShop.Orders.Orders
{
[NotNull]
public string Name { get; set; }
-
+
[CanBeNull]
public string Key { get; set; }
-
+
+ [CanBeNull]
+ public string DisplayName { get; set; }
+
public decimal Fee { get; set; }
public OrderExtraFeeInfoModel(
[NotNull] string name,
[CanBeNull] string key,
+ [CanBeNull] string displayName,
decimal fee)
{
Name = name;
+ DisplayName = displayName;
Key = key ?? string.Empty;
Fee = fee;
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs
index 34b7a033..2e51295e 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLine.cs
@@ -19,30 +19,22 @@ namespace EasyAbp.EShop.Orders.Orders
public virtual DateTime? ProductDetailModificationTime { get; protected set; }
- [NotNull]
public virtual string ProductGroupName { get; protected set; }
- [NotNull]
public virtual string ProductGroupDisplayName { get; protected set; }
- [CanBeNull]
public virtual string ProductUniqueName { get; protected set; }
- [NotNull]
public virtual string ProductDisplayName { get; protected set; }
public virtual InventoryStrategy? ProductInventoryStrategy { get; protected set; }
- [CanBeNull]
public virtual string SkuName { get; protected set; }
- [CanBeNull]
public virtual string SkuDescription { get; protected set; }
- [CanBeNull]
public virtual string MediaResources { get; protected set; }
- [NotNull]
public virtual string Currency { get; protected set; }
public virtual decimal UnitPrice { get; protected set; }
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderLineInvalidQuantityException.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLineInvalidQuantityException.cs
similarity index 100%
rename from modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/OrderLineInvalidQuantityException.cs
rename to modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderLineInvalidQuantityException.cs
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/ProductInventoryReductionEventHandler.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/ProductInventoryReductionEventHandler.cs
index 4098a3bd..6a4f2b86 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/ProductInventoryReductionEventHandler.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/ProductInventoryReductionEventHandler.cs
@@ -121,6 +121,7 @@ namespace EasyAbp.EShop.Orders.Orders
{
Name = x.Name,
Key = x.Key,
+ DisplayName = x.DisplayName,
TotalAmount = x.Fee - x.RefundAmount
}));
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/UnexpectedCurrencyException.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/UnexpectedCurrencyException.cs
similarity index 100%
rename from modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/UnexpectedCurrencyException.cs
rename to modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/UnexpectedCurrencyException.cs
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs
index 266f427e..3d74d29c 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/OrdersDomainAutoMapperProfile.cs
@@ -12,6 +12,7 @@ namespace EasyAbp.EShop.Orders
* into multiple profile classes for a better organization. */
CreateMap();
CreateMap();
+ CreateMap();
}
}
}
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContext.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContext.cs
index d0918f12..6f127574 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContext.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContext.cs
@@ -13,6 +13,7 @@ namespace EasyAbp.EShop.Orders.EntityFrameworkCore
*/
public DbSet Orders { get; set; }
public DbSet OrderLines { get; set; }
+ public DbSet OrderDiscounts { get; set; }
public DbSet OrderExtraFees { get; set; }
public OrdersDbContext(DbContextOptions options)
diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContextModelCreatingExtensions.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContextModelCreatingExtensions.cs
index 04b060dc..a9c65c4e 100644
--- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContextModelCreatingExtensions.cs
+++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp/EShop/Orders/EntityFrameworkCore/OrdersDbContextModelCreatingExtensions.cs
@@ -66,6 +66,15 @@ namespace EasyAbp.EShop.Orders.EntityFrameworkCore
b.Property(x => x.RefundAmount).HasColumnType("decimal(20,8)");
});
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "OrderDiscounts", options.Schema);
+ b.ConfigureByConvention();
+ /* Configure more properties here */
+ b.Property(x => x.DiscountedAmount).HasColumnType("decimal(20,8)");
+ b.HasKey(x => new {x.OrderId, x.OrderLineId, x.Name, x.Key});
+ });
+
builder.Entity(b =>
{
b.ToTable(options.TablePrefix + "OrderExtraFees", options.Schema);
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/EasyAbp.EShop.Orders.Application.Tests.csproj b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/EasyAbp.EShop.Orders.Application.Tests.csproj
index bc1875b2..12c6f5d8 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/EasyAbp.EShop.Orders.Application.Tests.csproj
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/EasyAbp.EShop.Orders.Application.Tests.csproj
@@ -2,7 +2,7 @@
net7.0
-
+ EasyAbp.EShop.Orders
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderAppServiceTests.cs b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderAppServiceTests.cs
index 7ca763f0..b8e5adba 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderAppServiceTests.cs
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/OrderAppServiceTests.cs
@@ -119,10 +119,7 @@ namespace EasyAbp.EShop.Orders.Orders
{
var orderRepository = ServiceProvider.GetRequiredService();
var orderCount = 0;
- await WithUnitOfWorkAsync(async () =>
- {
- orderCount = await orderRepository.CountAsync();
- });
+ await WithUnitOfWorkAsync(async () => { orderCount = await orderRepository.CountAsync(); });
// Arrange
var checkCreateOrderInput = new CheckCreateOrderInput
@@ -131,7 +128,7 @@ namespace EasyAbp.EShop.Orders.Orders
StoreId = OrderTestData.Store1Id,
OrderLines = new List
{
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku1Id,
@@ -160,10 +157,7 @@ namespace EasyAbp.EShop.Orders.Orders
{
var orderRepository = ServiceProvider.GetRequiredService();
var orderCount = 0;
- await WithUnitOfWorkAsync(async () =>
- {
- orderCount = await orderRepository.CountAsync();
- });
+ await WithUnitOfWorkAsync(async () => { orderCount = await orderRepository.CountAsync(); });
// Arrange
var checkCreateOrderInput = new CheckCreateOrderInput
@@ -172,7 +166,7 @@ namespace EasyAbp.EShop.Orders.Orders
StoreId = OrderTestData.Store1Id,
OrderLines = new List
{
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku1Id,
@@ -206,13 +200,13 @@ namespace EasyAbp.EShop.Orders.Orders
StoreId = OrderTestData.Store1Id,
OrderLines = new List
{
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku1Id,
Quantity = 10
},
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku2Id,
@@ -684,13 +678,13 @@ namespace EasyAbp.EShop.Orders.Orders
StoreId = OrderTestData.Store1Id,
OrderLines = new List
{
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku1Id,
Quantity = 10
},
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku2Id,
@@ -725,13 +719,13 @@ namespace EasyAbp.EShop.Orders.Orders
StoreId = OrderTestData.Store1Id,
OrderLines = new List
{
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku1Id,
Quantity = 10
},
- new CreateOrderLineDto
+ new()
{
ProductId = OrderTestData.Product1Id,
ProductSkuId = OrderTestData.ProductSku2Id,
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/TestOrderLinePriceOverrider.cs b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/TestOrderLinePriceOverrider.cs
index 10d61c50..68062a7a 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/TestOrderLinePriceOverrider.cs
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Application.Tests/Orders/TestOrderLinePriceOverrider.cs
@@ -1,6 +1,5 @@
using System.Threading.Tasks;
-using EasyAbp.EShop.Orders.Orders.Dtos;
-using EasyAbp.EShop.Products.Products.Dtos;
+using EasyAbp.EShop.Products.Products;
using NodaMoney;
using Volo.Abp.DependencyInjection;
@@ -9,9 +8,9 @@ namespace EasyAbp.EShop.Orders.Orders;
public class TestOrderLinePriceOverrider : IOrderLinePriceOverrider, ITransientDependency
{
public static decimal Sku3UnitPrice { get; set; } = 100m;
-
- public async Task GetUnitPriceOrNullAsync(CreateOrderDto input, CreateOrderLineDto inputOrderLine,
- ProductDto product, ProductSkuDto productSku, Currency effectiveCurrency)
+
+ public async Task GetUnitPriceOrNullAsync(ICreateOrderInfo input, ICreateOrderLineInfo inputOrderLine,
+ IProduct product, IProductSku productSku, Currency effectiveCurrency)
{
if (inputOrderLine.ProductSkuId == OrderTestData.ProductSku3Id)
{
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/DemoOrderDiscountProvider.cs b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/DemoOrderDiscountProvider.cs
new file mode 100644
index 00000000..bbdb9875
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/DemoOrderDiscountProvider.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using EasyAbp.EShop.Products.Products;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+public class DemoOrderDiscountProvider : IOrderDiscountProvider
+{
+ public Task> GetAllAsync(Order order, Dictionary productDict)
+ {
+ return Task.FromResult(new List
+ {
+ new(order.OrderLines.First().Id, "DemoDiscount1", "1", "Demo Discount 1", 0.01m),
+ new(order.OrderLines.First().Id, "DemoDiscount2", "2", "Demo Discount 2", 0.1m),
+ });
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/InventoryReductionResultTests.cs b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/InventoryReductionResultTests.cs
index 13806a0e..4990055d 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/InventoryReductionResultTests.cs
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/InventoryReductionResultTests.cs
@@ -53,6 +53,7 @@ public class InventoryReductionResultTests : OrdersDomainTestBase
OrderTestData.Order1Id,
"Name",
"Key",
+ "DisplayName",
0.3m
));
@@ -153,6 +154,7 @@ public class InventoryReductionResultTests : OrdersDomainTestBase
var orderExtraFee = eventData.OrderExtraFees[0];
orderExtraFee.Name.ShouldBe("Name");
orderExtraFee.Key.ShouldBe("Key");
+ orderExtraFee.DisplayName.ShouldBe("DisplayName");
orderExtraFee.TotalAmount.ShouldBe(0.3m);
Order1.CanceledTime.ShouldNotBeNull();
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDiscountTests.cs b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDiscountTests.cs
new file mode 100644
index 00000000..3d7491df
--- /dev/null
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDiscountTests.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using EasyAbp.EShop.Products.Products;
+using Microsoft.Extensions.DependencyInjection;
+using Shouldly;
+using Xunit;
+
+namespace EasyAbp.EShop.Orders.Orders;
+
+public class OrderDiscountTests : OrdersDomainTestBase
+{
+ protected override void AfterAddApplication(IServiceCollection services)
+ {
+ services.AddTransient();
+ base.AfterAddApplication(services);
+ }
+
+ [Fact]
+ public async Task Should_Create_Order_With_Discount()
+ {
+ var orderGenerator = GetRequiredService();
+
+ var createOrderInfoModel = new CreateOrderInfoModel(OrderTestData.Store1Id, null,
+ new List
+ {
+ new(OrderTestData.Product1Id, OrderTestData.ProductSku1Id, 2)
+ }
+ );
+
+ var order = await orderGenerator.GenerateAsync(Guid.NewGuid(), createOrderInfoModel,
+ new Dictionary
+ {
+ {
+ OrderTestData.Product1Id, new ProductEto
+ {
+ Id = OrderTestData.Product1Id,
+ ProductSkus = new List
+ {
+ new()
+ {
+ Id = OrderTestData.ProductSku1Id,
+ AttributeOptionIds = new List(),
+ Price = 1m,
+ Currency = "USD",
+ OrderMinQuantity = 1,
+ OrderMaxQuantity = 100,
+ }
+ }
+ }
+ }
+ }, new Dictionary());
+
+ order.ActualTotalPrice.ShouldBe(1.89m);
+ order.TotalDiscount.ShouldBe(0.11m);
+ order.OrderDiscounts.Count.ShouldBe(2);
+ order.OrderDiscounts.ShouldContain(x =>
+ x.OrderId == order.Id && x.OrderLineId == order.OrderLines.First().Id && x.Name == "DemoDiscount1" &&
+ x.Key == "1" && x.DisplayName == "Demo Discount 1" && x.DiscountedAmount == 0.01m);
+ order.OrderDiscounts.ShouldContain(x =>
+ x.OrderId == order.Id && x.OrderLineId == order.OrderLines.First().Id && x.Name == "DemoDiscount2" &&
+ x.Key == "2" && x.DisplayName == "Demo Discount 2" && x.DiscountedAmount == 0.1m);
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDomainTests.cs b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDomainTests.cs
index 6836ab02..202ccb7a 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDomainTests.cs
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.Domain.Tests/Orders/OrderDomainTests.cs
@@ -62,6 +62,7 @@ namespace EasyAbp.EShop.Orders.Orders
OrderTestData.Order1Id,
"Name",
"Key",
+ "DisplayName",
0.3m
));
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests.csproj b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests.csproj
index 6fbfd82d..78869d99 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests.csproj
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests/EasyAbp.EShop.Orders.EntityFrameworkCore.Tests.csproj
@@ -2,7 +2,7 @@
net7.0
-
+ EasyAbp.EShop.Orders
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp.csproj b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp.csproj
index 7565243b..f2cfb7dd 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp.csproj
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp/EasyAbp.EShop.Orders.HttpApi.Client.ConsoleTestApp.csproj
@@ -3,7 +3,7 @@
Exe
net7.0
-
+ EasyAbp.EShop.Orders
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.MongoDB.Tests/EasyAbp.EShop.Orders.MongoDB.Tests.csproj b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.MongoDB.Tests/EasyAbp.EShop.Orders.MongoDB.Tests.csproj
index 3ff4596b..ffb2e253 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.MongoDB.Tests/EasyAbp.EShop.Orders.MongoDB.Tests.csproj
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.MongoDB.Tests/EasyAbp.EShop.Orders.MongoDB.Tests.csproj
@@ -2,7 +2,7 @@
net7.0
-
+ EasyAbp.EShop.Orders
diff --git a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.TestBase/EasyAbp.EShop.Orders.TestBase.csproj b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.TestBase/EasyAbp.EShop.Orders.TestBase.csproj
index 93e2e271..f45059f1 100644
--- a/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.TestBase/EasyAbp.EShop.Orders.TestBase.csproj
+++ b/modules/EasyAbp.EShop.Orders/test/EasyAbp.EShop.Orders.TestBase/EasyAbp.EShop.Orders.TestBase.csproj
@@ -2,7 +2,7 @@
net7.0
-
+ EasyAbp.EShop.Orders
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Payments/Dtos/PaymentDto.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Payments/Dtos/PaymentDto.cs
index 64b0c40c..cd9ee32c 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Payments/Dtos/PaymentDto.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Payments/Dtos/PaymentDto.cs
@@ -11,9 +11,9 @@ namespace EasyAbp.EShop.Payments.Payments.Dtos
#region Base properties
public Guid UserId { get; set; }
-
+
public string PaymentMethod { get; set; }
-
+
public string PayeeAccount { get; set; }
public string ExternalTradingCode { get; set; }
@@ -27,15 +27,16 @@ namespace EasyAbp.EShop.Payments.Payments.Dtos
public decimal ActualPaymentAmount { get; set; }
public decimal RefundAmount { get; set; }
-
+
public decimal PendingRefundAmount { get; set; }
public DateTime? CompletionTime { get; set; }
-
+
public DateTime? CanceledTime { get; set; }
-
+
#endregion
-
+
+ IEnumerable IPayment.PaymentItems => PaymentItems;
public List PaymentItems { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/RefundDto.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/RefundDto.cs
index 6ba6529c..9c142db9 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/RefundDto.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/RefundDto.cs
@@ -19,19 +19,20 @@ namespace EasyAbp.EShop.Payments.Refunds.Dtos
public string Currency { get; set; }
public decimal RefundAmount { get; set; }
-
+
public string DisplayReason { get; set; }
public string CustomerRemark { get; set; }
public string StaffRemark { get; set; }
-
+
public DateTime? CompletedTime { get; set; }
-
+
public DateTime? CanceledTime { get; set; }
-
+
#endregion
-
+
+ IEnumerable IRefund.RefundItems => RefundItems;
public List RefundItems { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Payments/EShopPaymentEto.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Payments/EShopPaymentEto.cs
index 188ff539..4092e5e8 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Payments/EShopPaymentEto.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Payments/EShopPaymentEto.cs
@@ -14,7 +14,7 @@ namespace EasyAbp.EShop.Payments.Payments
public Guid Id { get; set; }
public Guid? TenantId { get; set; }
-
+
public Guid UserId { get; set; }
public string PaymentMethod { get; set; }
@@ -41,6 +41,7 @@ namespace EasyAbp.EShop.Payments.Payments
#endregion
- public List PaymentItems { get; set; } = new List();
+ IEnumerable IPayment.PaymentItems => PaymentItems;
+ public List PaymentItems { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/EShopRefundEto.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/EShopRefundEto.cs
index 11f3595a..1fa8900e 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/EShopRefundEto.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/EShopRefundEto.cs
@@ -16,27 +16,28 @@ namespace EasyAbp.EShop.Payments.Refunds
public Guid? TenantId { get; set; }
public Guid PaymentId { get; set; }
-
+
public string RefundPaymentMethod { get; set; }
-
+
public string ExternalTradingCode { get; set; }
-
+
public string Currency { get; set; }
-
+
public decimal RefundAmount { get; set; }
-
+
public string DisplayReason { get; set; }
public string CustomerRemark { get; set; }
-
+
public string StaffRemark { get; set; }
-
+
public DateTime? CompletedTime { get; set; }
-
+
public DateTime? CanceledTime { get; set; }
-
+
#endregion
- public List RefundItems { get; set; } = new List();
+ IEnumerable IRefund.RefundItems => RefundItems;
+ public List RefundItems { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/OrderExtraFeeRefundInfoModel.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/OrderExtraFeeRefundInfoModel.cs
index e0062f51..4bda640c 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/OrderExtraFeeRefundInfoModel.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/OrderExtraFeeRefundInfoModel.cs
@@ -6,9 +6,11 @@ namespace EasyAbp.EShop.Payments.Refunds
public class OrderExtraFeeRefundInfoModel
{
public string Name { get; set; }
-
+
public string Key { get; set; }
-
+
+ public string DisplayName { get; set; }
+
public decimal TotalAmount { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFeeEto.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFeeEto.cs
index 4aa7d73c..e2575c72 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFeeEto.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFeeEto.cs
@@ -6,9 +6,11 @@ namespace EasyAbp.EShop.Payments.Refunds
public class RefundItemOrderExtraFeeEto
{
public string Name { get; set; }
-
+
public string Key { get; set; }
-
+
+ public string DisplayName { get; set; }
+
public decimal RefundAmount { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs
index 8e3276e0..e1c42c61 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Payments/Payment.cs
@@ -10,44 +10,44 @@ namespace EasyAbp.EShop.Payments.Payments
public class Payment : FullAuditedAggregateRoot, IPayment, IMultiTenant
{
#region Base properties
-
+
public virtual Guid? TenantId { get; protected set; }
-
+
public virtual Guid UserId { get; protected set; }
-
+
[NotNull]
public virtual string PaymentMethod { get; protected set; }
-
+
[CanBeNull]
public virtual string PayeeAccount { get; protected set; }
-
+
[CanBeNull]
public virtual string ExternalTradingCode { get; protected set; }
-
+
[NotNull]
public virtual string Currency { get; protected set; }
-
+
public virtual decimal OriginalPaymentAmount { get; protected set; }
public virtual decimal PaymentDiscount { get; protected set; }
-
+
public virtual decimal ActualPaymentAmount { get; protected set; }
-
+
public virtual decimal RefundAmount { get; protected set; }
-
+
public virtual decimal PendingRefundAmount { get; protected set; }
public virtual DateTime? CompletionTime { get; protected set; }
-
+
public virtual DateTime? CanceledTime { get; protected set; }
-
+
+ IEnumerable IPayment.PaymentItems => PaymentItems;
public virtual List PaymentItems { get; protected set; }
-
+
#endregion
protected Payment()
{
-
}
public void SetPaymentItems(List paymentItems)
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs
index 6149292f..167a49b5 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/Refund.cs
@@ -12,41 +12,41 @@ namespace EasyAbp.EShop.Payments.Refunds
#region Base properties
public virtual Guid? TenantId { get; protected set; }
-
+
public virtual Guid PaymentId { get; protected set; }
-
+
[NotNull]
public virtual string RefundPaymentMethod { get; protected set; }
-
+
[NotNull]
public virtual string ExternalTradingCode { get; protected set; }
-
+
[NotNull]
public virtual string Currency { get; protected set; }
-
+
public virtual decimal RefundAmount { get; protected set; }
-
+
public virtual string DisplayReason { get; protected set; }
[CanBeNull]
public virtual string CustomerRemark { get; protected set; }
-
+
[CanBeNull]
public virtual string StaffRemark { get; protected set; }
public virtual DateTime? CompletedTime { get; protected set; }
-
+
public virtual DateTime? CanceledTime { get; protected set; }
-
+
#endregion
-
+
+ IEnumerable IRefund.RefundItems => RefundItems;
public virtual List RefundItems { get; protected set; }
protected Refund()
{
-
}
-
+
public void SetRefundItems(List refundItems)
{
RefundItems = refundItems;
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs
index ac11ebdc..8f6d4482 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundItemOrderExtraFee.cs
@@ -10,21 +10,29 @@ namespace EasyAbp.EShop.Payments.Refunds
{
[NotNull]
public virtual string Name { get; protected set; }
-
+
[CanBeNull]
public virtual string Key { get; protected set; }
-
+
+ [CanBeNull]
+ public virtual string DisplayName { get; protected set; }
+
public virtual decimal RefundAmount { get; protected set; }
protected RefundItemOrderExtraFee()
{
}
- public RefundItemOrderExtraFee(Guid id, [NotNull] string name, [CanBeNull] string key,
+ public RefundItemOrderExtraFee(
+ Guid id,
+ [NotNull] string name,
+ [CanBeNull] string key,
+ [CanBeNull] string displayName,
decimal refundAmount) : base(id)
{
Name = name;
Key = key;
+ DisplayName = displayName;
RefundAmount = refundAmount;
}
}
diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs
index 68828507..cbc28946 100644
--- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs
+++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp/EShop/Payments/Refunds/RefundSynchronizer.cs
@@ -195,7 +195,7 @@ namespace EasyAbp.EShop.Payments.Refunds
{
refundItemOrderExtraFeeEntity = new RefundItemOrderExtraFee(_guidGenerator.Create(),
orderExtraFeeInfoModel.Name, orderExtraFeeInfoModel.Key,
- orderExtraFeeInfoModel.TotalAmount);
+ orderExtraFeeInfoModel.DisplayName, orderExtraFeeInfoModel.TotalAmount);
refundItem.OrderExtraFees.Add(refundItemOrderExtraFeeEntity);
}
diff --git a/modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Domain.Tests/Refunds/RefundOrderEventHandlerTests.cs b/modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Domain.Tests/Refunds/RefundOrderEventHandlerTests.cs
index 6694ac75..7dd18d6e 100644
--- a/modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Domain.Tests/Refunds/RefundOrderEventHandlerTests.cs
+++ b/modules/EasyAbp.EShop.Payments/test/EasyAbp.EShop.Payments.Domain.Tests/Refunds/RefundOrderEventHandlerTests.cs
@@ -82,6 +82,7 @@ public class RefundOrderEventHandlerTests : PaymentsDomainTestBase
{
Name = "Name",
Key = "Key",
+ DisplayName = "DisplayName",
TotalAmount = 0.6m
});
@@ -111,6 +112,7 @@ public class RefundOrderEventHandlerTests : PaymentsDomainTestBase
orderExtraFees.Count.ShouldBe(1);
orderExtraFees[0].Name.ShouldBe("Name");
orderExtraFees[0].Key.ShouldBe("Key");
+ orderExtraFees[0].DisplayName.ShouldBe("DisplayName");
orderExtraFees[0].TotalAmount.ShouldBe(0.6m);
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeDto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeDto.cs
index 0e75efce..cad078c6 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeDto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeDto.cs
@@ -6,7 +6,7 @@ using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Products.Products.Dtos
{
[Serializable]
- public class ProductAttributeDto : ExtensibleFullAuditedEntityDto
+ public class ProductAttributeDto : ExtensibleFullAuditedEntityDto, IProductAttribute
{
[Required]
public string DisplayName { get; set; }
@@ -15,6 +15,7 @@ namespace EasyAbp.EShop.Products.Products.Dtos
public int DisplayOrder { get; set; }
+ IEnumerable IProductAttribute.ProductAttributeOptions => ProductAttributeOptions;
public List ProductAttributeOptions { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeOptionDto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeOptionDto.cs
index 577a8519..b6f64c92 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeOptionDto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductAttributeOptionDto.cs
@@ -5,7 +5,7 @@ using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Products.Products.Dtos
{
[Serializable]
- public class ProductAttributeOptionDto : ExtensibleFullAuditedEntityDto
+ public class ProductAttributeOptionDto : ExtensibleFullAuditedEntityDto, IProductAttributeOption
{
[Required]
public string DisplayName { get; set; }
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductDto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductDto.cs
index bd91407a..dc4a9948 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductDto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductDto.cs
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Products.Products.Dtos
{
[Serializable]
- public class ProductDto : ExtensibleFullAuditedEntityDto
+ public class ProductDto : ExtensibleFullAuditedEntityDto, IProduct, IHasProductGroupDisplayName
{
public Guid StoreId { get; set; }
@@ -44,25 +43,10 @@ namespace EasyAbp.EShop.Products.Products.Dtos
public decimal? MaximumPrice { get; set; }
+ IEnumerable IProduct.ProductAttributes => ProductAttributes;
public List ProductAttributes { get; set; }
+ IEnumerable IProduct.ProductSkus => ProductSkus;
public List ProductSkus { get; set; }
-
- public ProductSkuDto GetSkuById(Guid skuId)
- {
- return ProductSkus.Single(x => x.Id == skuId);
- }
-
- public ProductSkuDto FindSkuById(Guid skuId)
- {
- return ProductSkus.FirstOrDefault(x => x.Id == skuId);
- }
-
- public TimeSpan? GetSkuPaymentExpireIn(Guid skuId)
- {
- var sku = GetSkuById(skuId);
-
- return sku.PaymentExpireIn ?? PaymentExpireIn;
- }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs
index 0a2429a4..21e8686c 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs
@@ -6,10 +6,9 @@ using Volo.Abp.Data;
namespace EasyAbp.EShop.Products.Products.Dtos
{
[Serializable]
- public class ProductSkuDto : ExtensibleFullAuditedEntityDto
+ public class ProductSkuDto : ExtensibleFullAuditedEntityDto, IProductSku
{
public List AttributeOptionIds { get; set; }
-
public string Name { get; set; }
public string Currency { get; set; }
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductViewDto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductViewDto.cs
index 46a617cd..6de98b2e 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductViewDto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductViewDto.cs
@@ -1,11 +1,10 @@
using System;
-using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Products.Products.Dtos
{
[Serializable]
- public class ProductViewDto : ExtensibleCreationAuditedEntityDto
+ public class ProductViewDto : ExtensibleCreationAuditedEntityDto, IProductBase, IHasProductGroupDisplayName
{
public Guid StoreId { get; set; }
@@ -33,6 +32,8 @@ namespace EasyAbp.EShop.Products.Products.Dtos
public bool IsHidden { get; set; }
+ public TimeSpan? PaymentExpireIn { get; set; }
+
public decimal? MinimumPrice { get; set; }
public decimal? MaximumPrice { get; set; }
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs
index c3528d6a..d665704a 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs
@@ -32,7 +32,6 @@ namespace EasyAbp.EShop.Products.Products
private readonly EShopProductsOptions _options;
private readonly IProductInventoryProviderResolver _productInventoryProviderResolver;
private readonly IProductViewCacheKeyProvider _productViewCacheKeyProvider;
- private readonly IAttributeOptionIdsSerializer _attributeOptionIdsSerializer;
private readonly IProductRepository _repository;
public ProductAppService(
@@ -41,7 +40,6 @@ namespace EasyAbp.EShop.Products.Products
IDistributedCache cache,
IProductInventoryProviderResolver productInventoryProviderResolver,
IProductViewCacheKeyProvider productViewCacheKeyProvider,
- IAttributeOptionIdsSerializer attributeOptionIdsSerializer,
IProductRepository repository) : base(repository)
{
_productManager = productManager;
@@ -49,7 +47,6 @@ namespace EasyAbp.EShop.Products.Products
_options = options.Value;
_productInventoryProviderResolver = productInventoryProviderResolver;
_productViewCacheKeyProvider = productViewCacheKeyProvider;
- _attributeOptionIdsSerializer = attributeOptionIdsSerializer;
_repository = repository;
}
@@ -127,21 +124,11 @@ namespace EasyAbp.EShop.Products.Products
return dto;
}
- protected virtual async Task UpdateProductAttributesAsync(Product product, CreateUpdateProductDto input)
+ protected virtual Task UpdateProductAttributesAsync(Product product, CreateUpdateProductDto input)
{
var isProductSkusEmpty = product.ProductSkus.IsNullOrEmpty();
- var usedAttributeOptionIds = new HashSet();
-
- foreach (var serializedAttributeOptionIds in product.ProductSkus.Select(sku =>
- sku.SerializedAttributeOptionIds))
- {
- foreach (var attributeOptionId in await _attributeOptionIdsSerializer.DeserializeAsync(
- serializedAttributeOptionIds))
- {
- usedAttributeOptionIds.Add(attributeOptionId);
- }
- }
+ var usedAttributeOptionIds = new HashSet(product.ProductSkus.SelectMany(x => x.AttributeOptionIds));
foreach (var attributeDto in input.ProductAttributes)
{
@@ -198,6 +185,7 @@ namespace EasyAbp.EShop.Products.Products
}
product.ProductAttributes.RemoveAll(a => removedAttributeNames.Contains(a.DisplayName));
+ return Task.CompletedTask;
}
public override async Task GetAsync(Guid id)
@@ -528,11 +516,11 @@ namespace EasyAbp.EShop.Products.Products
return Task.CompletedTask;
}
- protected virtual async Task MapToProductSkuAsync(CreateProductSkuDto createInput)
+ protected virtual Task MapToProductSkuAsync(CreateProductSkuDto createInput)
{
var entity = new ProductSku(
GuidGenerator.Create(),
- await _attributeOptionIdsSerializer.SerializeAsync(createInput.AttributeOptionIds),
+ createInput.AttributeOptionIds,
createInput.Name,
createInput.Currency,
createInput.OriginalPrice,
@@ -546,7 +534,7 @@ namespace EasyAbp.EShop.Products.Products
createInput.MapExtraPropertiesTo(entity);
- return entity;
+ return Task.FromResult(entity);
}
protected virtual Task MapToProductSkuAsync(UpdateProductSkuDto updateInput, ProductSku entity)
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs
index f575692b..0a19e6f6 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/ProductsApplicationAutoMapperProfile.cs
@@ -19,7 +19,7 @@ namespace EasyAbp.EShop.Products
{
public class ProductsApplicationAutoMapperProfile : Profile, ISingletonDependency
{
- public ProductsApplicationAutoMapperProfile(IAttributeOptionIdsSerializer attributeOptionIdsSerializer)
+ public ProductsApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
@@ -33,14 +33,10 @@ namespace EasyAbp.EShop.Products
CreateMap();
CreateMap();
CreateMap()
- .ForSourceMember(entity => entity.SerializedAttributeOptionIds, opt => opt.DoNotValidate())
- .Ignore(dto => dto.AttributeOptionIds)
.Ignore(dto => dto.Price)
.Ignore(dto => dto.DiscountedPrice)
.Ignore(dto => dto.Inventory)
- .Ignore(dto => dto.Sold)
- .AfterMap(async (src, dest) => dest.AttributeOptionIds =
- (await attributeOptionIdsSerializer.DeserializeAsync(src.SerializedAttributeOptionIds)).ToList());
+ .Ignore(dto => dto.Sold);
CreateMap(MemberList.Source)
.ForSourceMember(dto => dto.StoreId, opt => opt.DoNotValidate());
CreateMap(MemberList.Source);
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp.EShop.Products.Domain.Shared.csproj b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp.EShop.Products.Domain.Shared.csproj
index a303b860..4c0064eb 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp.EShop.Products.Domain.Shared.csproj
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp.EShop.Products.Domain.Shared.csproj
@@ -11,6 +11,7 @@
+
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/EShopProductsDomainSharedModule.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/EShopProductsDomainSharedModule.cs
index 578678bb..ee44bb6f 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/EShopProductsDomainSharedModule.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/EShopProductsDomainSharedModule.cs
@@ -3,6 +3,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.Localization;
using EasyAbp.EShop.Products.Localization;
using EasyAbp.EShop.Stores;
+using Volo.Abp.Json;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
@@ -12,6 +13,7 @@ namespace EasyAbp.EShop.Products
{
[DependsOn(
typeof(AbpValidationModule),
+ typeof(AbpJsonAbstractionsModule),
typeof(AbpTreesDomainSharedModule),
typeof(EShopStoresDomainSharedModule)
)]
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IHasAttributeOptionIds.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IHasAttributeOptionIds.cs
new file mode 100644
index 00000000..246a3b34
--- /dev/null
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IHasAttributeOptionIds.cs
@@ -0,0 +1,9 @@
+using System;
+using System.Collections.Generic;
+
+namespace EasyAbp.EShop.Products.Products;
+
+public interface IHasAttributeOptionIds
+{
+ List AttributeOptionIds { get; }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IHasProductGroupDisplayName.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IHasProductGroupDisplayName.cs
new file mode 100644
index 00000000..85fbc6bc
--- /dev/null
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IHasProductGroupDisplayName.cs
@@ -0,0 +1,9 @@
+using JetBrains.Annotations;
+
+namespace EasyAbp.EShop.Products.Products;
+
+public interface IHasProductGroupDisplayName
+{
+ [NotNull]
+ string ProductGroupDisplayName { get; }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProduct.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProduct.cs
index fd2a8407..ec0993b2 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProduct.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProduct.cs
@@ -1,34 +1,11 @@
-using System;
-using EasyAbp.EShop.Stores.Stores;
-using JetBrains.Annotations;
-using Volo.Abp.Data;
+using System.Collections.Generic;
namespace EasyAbp.EShop.Products.Products
{
- public interface IProduct : IHasExtraProperties, IMultiStore
+ public interface IProduct : IProductBase
{
- string ProductGroupName { get; }
+ IEnumerable ProductAttributes { get; }
- Guid? ProductDetailId { get; }
-
- string UniqueName { get; }
-
- string DisplayName { get; }
-
- string Overview { get; }
-
- InventoryStrategy InventoryStrategy { get; }
-
- [CanBeNull] string InventoryProviderName { get; }
-
- string MediaResources { get; }
-
- int DisplayOrder { get; }
-
- bool IsPublished { get; }
-
- bool IsStatic { get; }
-
- bool IsHidden { get; }
+ IEnumerable ProductSkus { get; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttribute.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttribute.cs
index e743971e..6f76ed65 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttribute.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttribute.cs
@@ -1,13 +1,22 @@
-using Volo.Abp.Data;
+using System;
+using System.Collections.Generic;
+using JetBrains.Annotations;
+using Volo.Abp.Data;
namespace EasyAbp.EShop.Products.Products
{
public interface IProductAttribute : IHasExtraProperties
{
+ Guid Id { get; }
+
+ [NotNull]
string DisplayName { get; }
-
+
+ [CanBeNull]
string Description { get; }
-
+
int DisplayOrder { get; }
+
+ IEnumerable ProductAttributeOptions { get; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttributeOption.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttributeOption.cs
index 4d943db9..d11e9cf3 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttributeOption.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductAttributeOption.cs
@@ -1,13 +1,19 @@
-using Volo.Abp.Data;
+using System;
+using JetBrains.Annotations;
+using Volo.Abp.Data;
namespace EasyAbp.EShop.Products.Products
{
public interface IProductAttributeOption : IHasExtraProperties
{
+ Guid Id { get; }
+
+ [NotNull]
string DisplayName { get; }
-
+
+ [CanBeNull]
string Description { get; }
-
+
int DisplayOrder { get; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductBase.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductBase.cs
new file mode 100644
index 00000000..974dce17
--- /dev/null
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductBase.cs
@@ -0,0 +1,47 @@
+using System;
+using EasyAbp.EShop.Stores.Stores;
+using JetBrains.Annotations;
+using Volo.Abp.Data;
+
+namespace EasyAbp.EShop.Products.Products
+{
+ public interface IProductBase : IHasExtraProperties, IMultiStore
+ {
+ Guid Id { get; }
+
+ [NotNull]
+ string ProductGroupName { get; }
+
+ Guid? ProductDetailId { get; }
+
+ [CanBeNull]
+ string UniqueName { get; }
+
+ [NotNull]
+ string DisplayName { get; }
+
+ ///
+ /// Tell your customer what the product is. It is usually shown in the product list.
+ ///
+ [CanBeNull]
+ string Overview { get; }
+
+ InventoryStrategy InventoryStrategy { get; }
+
+ [CanBeNull]
+ string InventoryProviderName { get; }
+
+ [CanBeNull]
+ string MediaResources { get; }
+
+ int DisplayOrder { get; }
+
+ bool IsPublished { get; }
+
+ bool IsStatic { get; }
+
+ bool IsHidden { get; }
+
+ TimeSpan? PaymentExpireIn { get; }
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductSku.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductSku.cs
index 920945c9..c1d78ef7 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductSku.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductSku.cs
@@ -1,26 +1,32 @@
using System;
+using JetBrains.Annotations;
using Volo.Abp.Data;
namespace EasyAbp.EShop.Products.Products
{
- public interface IProductSku : IHasExtraProperties
+ public interface IProductSku : IHasAttributeOptionIds, IHasExtraProperties
{
- string SerializedAttributeOptionIds { get; }
-
+ Guid Id { get; }
+
+ [CanBeNull]
string Name { get; }
-
+
+ [NotNull]
string Currency { get; }
-
+
decimal? OriginalPrice { get; }
-
+
decimal Price { get; }
int OrderMinQuantity { get; }
-
+
int OrderMaxQuantity { get; }
-
+
+ TimeSpan? PaymentExpireIn { get; }
+
+ [CanBeNull]
string MediaResources { get; }
-
+
Guid? ProductDetailId { get; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/IProductSkuDescriptionProvider.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductSkuDescriptionProvider.cs
similarity index 51%
rename from modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/IProductSkuDescriptionProvider.cs
rename to modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductSkuDescriptionProvider.cs
index acfcc18e..697544b1 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/IProductSkuDescriptionProvider.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/IProductSkuDescriptionProvider.cs
@@ -1,10 +1,9 @@
using System.Threading.Tasks;
-using EasyAbp.EShop.Products.Products.Dtos;
namespace EasyAbp.EShop.Products.Products
{
public interface IProductSkuDescriptionProvider
{
- Task GenerateAsync(ProductDto productDto, ProductSkuDto productSkuDto);
+ Task GenerateAsync(IProduct product, IProductSku productSku);
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductAttributeEto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductAttributeEto.cs
index 9f8b15b9..171a1d2a 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductAttributeEto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductAttributeEto.cs
@@ -10,11 +10,12 @@ namespace EasyAbp.EShop.Products.Products
public Guid Id { get; set; }
public string DisplayName { get; set; }
-
+
public string Description { get; set; }
-
+
public int DisplayOrder { get; set; }
-
+
+ IEnumerable IProductAttribute.ProductAttributeOptions => ProductAttributeOptions;
public List ProductAttributeOptions { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductEto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductEto.cs
index eae729a4..8cd5ae19 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductEto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductEto.cs
@@ -37,8 +37,12 @@ namespace EasyAbp.EShop.Products.Products
public bool IsHidden { get; set; }
+ public TimeSpan? PaymentExpireIn { get; set; }
+
+ IEnumerable IProduct.ProductAttributes => ProductAttributes;
public List ProductAttributes { get; set; }
+ IEnumerable IProduct.ProductSkus => ProductSkus;
public List ProductSkus { get; set; }
}
}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductExtensions.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductExtensions.cs
new file mode 100644
index 00000000..618a6acc
--- /dev/null
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductExtensions.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Linq;
+
+namespace EasyAbp.EShop.Products.Products;
+
+public static class ProductExtensions
+{
+ public static IProductSku GetSkuById(this IProduct product, Guid skuId)
+ {
+ return product.ProductSkus.Single(x => x.Id == skuId);
+ }
+
+ public static IProductSku FindSkuById(this IProduct product, Guid skuId)
+ {
+ return product.ProductSkus.FirstOrDefault(x => x.Id == skuId);
+ }
+
+ public static TimeSpan? GetSkuPaymentExpireIn(this IProduct product, Guid skuId)
+ {
+ var sku = product.GetSkuById(skuId);
+
+ return sku.PaymentExpireIn ?? product.PaymentExpireIn;
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/ProductSkuDescriptionProvider.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductSkuDescriptionProvider.cs
similarity index 75%
rename from modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/ProductSkuDescriptionProvider.cs
rename to modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductSkuDescriptionProvider.cs
index d8a6ae04..704955b6 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/ProductSkuDescriptionProvider.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductSkuDescriptionProvider.cs
@@ -1,7 +1,6 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
-using EasyAbp.EShop.Products.Products.Dtos;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
@@ -16,13 +15,13 @@ namespace EasyAbp.EShop.Products.Products
_jsonSerializer = jsonSerializer;
}
- public virtual Task GenerateAsync(ProductDto productDto, ProductSkuDto productSkuDto)
+ public virtual Task GenerateAsync(IProduct product, IProductSku productSku)
{
var names = new Collection();
- foreach (var attributeOptionId in productSkuDto.AttributeOptionIds)
+ foreach (var attributeOptionId in productSku.AttributeOptionIds)
{
- names.Add(productDto.ProductAttributes.SelectMany(
+ names.Add(product.ProductAttributes.SelectMany(
attribute => attribute.ProductAttributeOptions.Where(option => option.Id == attributeOptionId),
(attribute, option) => new [] {attribute.DisplayName, option.DisplayName}).Single());
}
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductSkuEto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductSkuEto.cs
index 09b047cc..8c05d00f 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductSkuEto.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductSkuEto.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
@@ -8,7 +9,7 @@ namespace EasyAbp.EShop.Products.Products
{
public Guid Id { get; set; }
- public string SerializedAttributeOptionIds { get; set; }
+ public List AttributeOptionIds { get; set; }
public string Name { get; set; }
@@ -22,6 +23,8 @@ namespace EasyAbp.EShop.Products.Products
public int OrderMaxQuantity { get; set; }
+ public TimeSpan? PaymentExpireIn { get; }
+
public string MediaResources { get; set; }
public Guid? ProductDetailId { get; set; }
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Options/ProductGroups/IProductGroup.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Options/ProductGroups/IProductGroup.cs
deleted file mode 100644
index 17c95391..00000000
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Options/ProductGroups/IProductGroup.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace EasyAbp.EShop.Products.Options.ProductGroups
-{
- public interface IProductGroup
- {
-
- }
-}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/AttributeOptionIdsSerializer.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/AttributeOptionIdsSerializer.cs
deleted file mode 100644
index 22891048..00000000
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/AttributeOptionIdsSerializer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Volo.Abp.DependencyInjection;
-using Volo.Abp.Json;
-
-namespace EasyAbp.EShop.Products.Products
-{
- public class AttributeOptionIdsSerializer : IAttributeOptionIdsSerializer, ITransientDependency
- {
- private readonly IJsonSerializer _jsonSerializer;
-
- public AttributeOptionIdsSerializer(IJsonSerializer jsonSerializer)
- {
- _jsonSerializer = jsonSerializer;
- }
-
- public async Task FormatAsync(string serializedAttributeOptionIds)
- {
- return await SerializeAsync(await DeserializeAsync(serializedAttributeOptionIds));
- }
-
- public Task SerializeAsync(IEnumerable attributeOptionIds)
- {
- if (attributeOptionIds == null)
- {
- return Task.FromResult(string.Empty);
- }
-
- return Task.FromResult(_jsonSerializer.Serialize(attributeOptionIds.OrderBy(x => x)));
- }
-
- public Task> DeserializeAsync(string serializedAttributeOptionIds)
- {
- return Task.FromResult(_jsonSerializer.Deserialize>(serializedAttributeOptionIds));
- }
- }
-}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IAttributeOptionIdsSerializer.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IAttributeOptionIdsSerializer.cs
deleted file mode 100644
index 547128a3..00000000
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IAttributeOptionIdsSerializer.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-namespace EasyAbp.EShop.Products.Products
-{
- public interface IAttributeOptionIdsSerializer
- {
- Task FormatAsync(string serializedAttributeOptionIds);
-
- Task SerializeAsync(IEnumerable attributeOptionIds);
-
- Task> DeserializeAsync(string serializedAttributeOptionIds);
- }
-}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/Product.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/Product.cs
index b65b62cb..643f34d7 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/Product.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/Product.cs
@@ -14,21 +14,14 @@ namespace EasyAbp.EShop.Products.Products
public virtual Guid StoreId { get; protected set; }
- [NotNull]
public virtual string ProductGroupName { get; protected set; }
public virtual Guid? ProductDetailId { get; protected set; }
- [CanBeNull]
public virtual string UniqueName { get; protected set; }
- [NotNull]
public virtual string DisplayName { get; protected set; }
- ///
- /// Tell your customer what the product is. It is usually shown in the product list.
- ///
- [CanBeNull]
public virtual string Overview { get; protected set; }
public virtual InventoryStrategy InventoryStrategy { get; protected set; }
@@ -39,7 +32,6 @@ namespace EasyAbp.EShop.Products.Products
///
public virtual string InventoryProviderName { get; protected set; }
- [CanBeNull]
public virtual string MediaResources { get; protected set; }
public virtual int DisplayOrder { get; protected set; }
@@ -52,8 +44,10 @@ namespace EasyAbp.EShop.Products.Products
public virtual TimeSpan? PaymentExpireIn { get; protected set; }
+ IEnumerable IProduct.ProductAttributes => ProductAttributes;
public virtual List ProductAttributes { get; protected set; }
+ IEnumerable IProduct.ProductSkus => ProductSkus;
public virtual List ProductSkus { get; protected set; }
protected Product()
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttribute.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttribute.cs
index 79e2c249..791774f9 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttribute.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttribute.cs
@@ -9,16 +9,15 @@ namespace EasyAbp.EShop.Products.Products
{
public class ProductAttribute : FullAuditedEntity, IProductAttribute
{
- [NotNull]
public virtual string DisplayName { get; protected set; }
-
- [CanBeNull]
+
public virtual string Description { get; protected set; }
-
+
public virtual int DisplayOrder { get; protected set; }
-
+
public ExtraPropertyDictionary ExtraProperties { get; protected set; }
+ IEnumerable IProductAttribute.ProductAttributeOptions => ProductAttributeOptions;
public virtual List ProductAttributeOptions { get; protected set; }
protected ProductAttribute()
@@ -26,7 +25,7 @@ namespace EasyAbp.EShop.Products.Products
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
}
-
+
public ProductAttribute(
Guid id,
[NotNull] string displayName,
@@ -38,7 +37,7 @@ namespace EasyAbp.EShop.Products.Products
DisplayOrder = displayOrder;
ProductAttributeOptions = new List();
-
+
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
}
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttributeOption.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttributeOption.cs
index e355d986..41070e85 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttributeOption.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductAttributeOption.cs
@@ -8,12 +8,10 @@ namespace EasyAbp.EShop.Products.Products
{
public class ProductAttributeOption : FullAuditedEntity, IProductAttributeOption
{
- [NotNull]
public virtual string DisplayName { get; protected set; }
-
- [CanBeNull]
+
public virtual string Description { get; protected set; }
-
+
public virtual int DisplayOrder { get; protected set; }
public ExtraPropertyDictionary ExtraProperties { get; protected set; }
@@ -23,7 +21,7 @@ namespace EasyAbp.EShop.Products.Products
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
}
-
+
public ProductAttributeOption(
Guid id,
[NotNull] string displayName,
@@ -33,7 +31,7 @@ namespace EasyAbp.EShop.Products.Products
DisplayName = displayName;
Description = description;
DisplayOrder = displayOrder;
-
+
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
}
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs
index ade8db3d..4f3dbf36 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs
@@ -19,7 +19,6 @@ namespace EasyAbp.EShop.Products.Products
private readonly IProductDetailRepository _productDetailRepository;
private readonly IProductCategoryRepository _productCategoryRepository;
private readonly IProductInventoryProviderResolver _productInventoryProviderResolver;
- private readonly IAttributeOptionIdsSerializer _attributeOptionIdsSerializer;
private readonly IProductGroupConfigurationProvider _productGroupConfigurationProvider;
public ProductManager(
@@ -28,7 +27,6 @@ namespace EasyAbp.EShop.Products.Products
IProductDetailRepository productDetailRepository,
IProductCategoryRepository productCategoryRepository,
IProductInventoryProviderResolver productInventoryProviderResolver,
- IAttributeOptionIdsSerializer attributeOptionIdsSerializer,
IProductGroupConfigurationProvider productGroupConfigurationProvider)
{
_productRepository = productRepository;
@@ -36,7 +34,6 @@ namespace EasyAbp.EShop.Products.Products
_productDetailRepository = productDetailRepository;
_productCategoryRepository = productCategoryRepository;
_productInventoryProviderResolver = productInventoryProviderResolver;
- _attributeOptionIdsSerializer = attributeOptionIdsSerializer;
_productGroupConfigurationProvider = productGroupConfigurationProvider;
}
@@ -120,8 +117,6 @@ namespace EasyAbp.EShop.Products.Products
[UnitOfWork]
public virtual async Task CreateSkuAsync(Product product, ProductSku productSku)
{
- // productSku.SetSerializedAttributeOptionIds(await _attributeOptionIdsSerializer.FormatAsync(productSku.SerializedAttributeOptionIds));
-
await CheckSkuAttributeOptionsAsync(product, productSku);
await CheckProductSkuNameUniqueAsync(product, productSku);
@@ -151,25 +146,22 @@ namespace EasyAbp.EShop.Products.Products
return Task.CompletedTask;
}
- protected virtual async Task CheckSkuAttributeOptionsAsync(Product product, ProductSku productSku)
+ protected virtual Task CheckSkuAttributeOptionsAsync(Product product, ProductSku productSku)
{
- var attributeOptionIds =
- (await _attributeOptionIdsSerializer.DeserializeAsync(productSku.SerializedAttributeOptionIds))
- .ToList();
-
- if (!product.ProductAttributes.TrueForAll(attribute =>
- attribute.ProductAttributeOptions.Select(option => option.Id).Intersect(attributeOptionIds)
- .Count() == 1))
+ if (!product.ProductAttributes.TrueForAll(attribute => attribute.ProductAttributeOptions
+ .Select(option => option.Id).Intersect(productSku.AttributeOptionIds).Count() == 1))
{
throw new ProductSkuIncorrectAttributeOptionsException(product.Id,
- productSku.SerializedAttributeOptionIds);
+ productSku.AttributeOptionIds.JoinAsString(","));
}
- if (product.ProductSkus.Where(sku => sku.Id != productSku.Id).FirstOrDefault(sku =>
- sku.SerializedAttributeOptionIds.Equals(productSku.SerializedAttributeOptionIds)) != null)
+ if (product.ProductSkus.Where(sku => sku.Id != productSku.Id).Any(sku =>
+ sku.AttributeOptionIds.Order().SequenceEqual(productSku.AttributeOptionIds.Order())))
{
- throw new ProductSkuDuplicatedException(product.Id, productSku.SerializedAttributeOptionIds);
+ throw new ProductSkuDuplicatedException(product.Id, productSku.AttributeOptionIds.JoinAsString(","));
}
+
+ return Task.CompletedTask;
}
[UnitOfWork]
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductSku.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductSku.cs
index f1235626..f8910d78 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductSku.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductSku.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using JetBrains.Annotations;
using NodaMoney;
using Volo.Abp;
@@ -10,13 +11,20 @@ namespace EasyAbp.EShop.Products.Products
{
public class ProductSku : FullAuditedEntity, IProductSku
{
- [NotNull]
- public virtual string SerializedAttributeOptionIds { get; protected set; }
+ private List _attributeOptionIds;
+
+ public virtual List AttributeOptionIds
+ {
+ get => _attributeOptionIds;
+ protected set
+ {
+ _attributeOptionIds = value;
+ _attributeOptionIds.Sort();
+ }
+ }
- [CanBeNull]
public virtual string Name { get; protected set; }
- [NotNull]
public virtual string Currency { get; protected set; }
public virtual decimal? OriginalPrice { get; protected set; }
@@ -29,7 +37,6 @@ namespace EasyAbp.EShop.Products.Products
public virtual TimeSpan? PaymentExpireIn { get; protected set; }
- [CanBeNull]
public virtual string MediaResources { get; protected set; }
public virtual Guid? ProductDetailId { get; protected set; }
@@ -44,7 +51,7 @@ namespace EasyAbp.EShop.Products.Products
public ProductSku(
Guid id,
- [NotNull] string serializedAttributeOptionIds,
+ List attributeOptionIds,
[CanBeNull] string name,
[NotNull] string currency,
decimal? originalPrice,
@@ -58,8 +65,8 @@ namespace EasyAbp.EShop.Products.Products
Check.NotNullOrWhiteSpace(currency, nameof(currency));
var nodaCurrency = NodaMoney.Currency.FromCode(currency);
- SerializedAttributeOptionIds =
- Check.NotNullOrWhiteSpace(serializedAttributeOptionIds, nameof(serializedAttributeOptionIds));
+ Check.NotNullOrEmpty(attributeOptionIds, nameof(attributeOptionIds));
+ AttributeOptionIds = attributeOptionIds;
Name = name?.Trim();
Currency = nodaCurrency.Code;
OriginalPrice = originalPrice.HasValue ? new Money(originalPrice.Value, nodaCurrency).Amount : null;
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductView.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductView.cs
index 66af8957..37b7fd54 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductView.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductView.cs
@@ -4,7 +4,8 @@ using Volo.Abp.MultiTenancy;
namespace EasyAbp.EShop.Products.Products
{
- public class ProductView : CreationAuditedAggregateRoot, IProduct, IMultiTenant
+ public class ProductView : CreationAuditedAggregateRoot,
+ IProductBase, IHasProductGroupDisplayName, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }
@@ -36,6 +37,8 @@ namespace EasyAbp.EShop.Products.Products
public virtual bool IsHidden { get; protected set; }
+ public virtual TimeSpan? PaymentExpireIn { get; protected set; }
+
#endregion
public virtual string ProductGroupDisplayName { get; protected set; }
@@ -64,6 +67,7 @@ namespace EasyAbp.EShop.Products.Products
bool isPublished,
bool isStatic,
bool isHidden,
+ TimeSpan? paymentExpireIn,
string mediaResources,
int displayOrder,
string productGroupDisplayName,
@@ -84,6 +88,7 @@ namespace EasyAbp.EShop.Products.Products
IsPublished = isPublished;
IsStatic = isStatic;
IsHidden = isHidden;
+ PaymentExpireIn = paymentExpireIn;
MediaResources = mediaResources;
DisplayOrder = displayOrder;
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/AttributeOptionIds/AttributeOptionIdsValueComparer.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/AttributeOptionIds/AttributeOptionIdsValueComparer.cs
new file mode 100644
index 00000000..64aacd03
--- /dev/null
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/AttributeOptionIds/AttributeOptionIdsValueComparer.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
+
+namespace EasyAbp.EShop.Products.EntityFrameworkCore.AttributeOptionIds;
+
+public class AttributeOptionIdsValueComparer : ValueComparer>
+{
+ public AttributeOptionIdsValueComparer()
+ : base(
+ (d1, d2) => d1.SequenceEqual(d2),
+ d => d.Aggregate(0, (k, v) => HashCode.Combine(k, v.GetHashCode())),
+ d => new List(d))
+ {
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/AttributeOptionIds/AttributeOptionIdsValueConverter.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/AttributeOptionIds/AttributeOptionIdsValueConverter.cs
new file mode 100644
index 00000000..765b0869
--- /dev/null
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/AttributeOptionIds/AttributeOptionIdsValueConverter.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text.Json;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace EasyAbp.EShop.Products.EntityFrameworkCore.AttributeOptionIds;
+
+public class AttributeOptionIdsValueConverter : ValueConverter, string>
+{
+ public AttributeOptionIdsValueConverter() : base(
+ v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null),
+ v => JsonSerializer.Deserialize>(v, (JsonSerializerOptions)null))
+ {
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/EShopProductsEntityTypeBuilderExtensions.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/EShopProductsEntityTypeBuilderExtensions.cs
new file mode 100644
index 00000000..2f3dcf71
--- /dev/null
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/EShopProductsEntityTypeBuilderExtensions.cs
@@ -0,0 +1,20 @@
+using System;
+using EasyAbp.EShop.Products.EntityFrameworkCore.AttributeOptionIds;
+using EasyAbp.EShop.Products.Products;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace EasyAbp.EShop.Products.EntityFrameworkCore;
+
+public static class EShopProductsEntityTypeBuilderExtensions
+{
+ public static void TryConfigureAttributeOptionIds(this EntityTypeBuilder b)
+ {
+ if (b.Metadata.ClrType.IsAssignableTo())
+ {
+ b.Property(nameof(IHasAttributeOptionIds.AttributeOptionIds))
+ .HasConversion()
+ .Metadata.SetValueComparer(new AttributeOptionIdsValueComparer());
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/ProductsDbContextModelCreatingExtensions.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/ProductsDbContextModelCreatingExtensions.cs
index 2dfc08ff..58db971a 100644
--- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/ProductsDbContextModelCreatingExtensions.cs
+++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp/EShop/Products/EntityFrameworkCore/ProductsDbContextModelCreatingExtensions.cs
@@ -81,6 +81,7 @@ namespace EasyAbp.EShop.Products.EntityFrameworkCore
{
b.ToTable(options.TablePrefix + "ProductSkus", options.Schema);
b.ConfigureByConvention();
+ b.TryConfigureAttributeOptionIds();
/* Configure more properties here */
b.Property(x => x.Price).HasColumnType("decimal(20,8)");
b.Property(x => x.OriginalPrice).HasColumnType("decimal(20,8)");
diff --git a/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Domain.Tests/Products/ProductDomainTests.cs b/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Domain.Tests/Products/ProductDomainTests.cs
index 958a17f6..dc4c526a 100644
--- a/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Domain.Tests/Products/ProductDomainTests.cs
+++ b/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.Domain.Tests/Products/ProductDomainTests.cs
@@ -12,13 +12,11 @@ namespace EasyAbp.EShop.Products.Products
{
private IProductRepository ProductRepository { get; }
private IProductManager ProductManager { get; }
- private IAttributeOptionIdsSerializer AttributeOptionIdsSerializer { get; }
public ProductDomainTests()
{
ProductRepository = ServiceProvider.GetRequiredService();
ProductManager = ServiceProvider.GetRequiredService();
- AttributeOptionIdsSerializer = ServiceProvider.GetRequiredService();
}
[Fact]
@@ -129,7 +127,7 @@ namespace EasyAbp.EShop.Products.Products
{
var product1 = await ProductRepository.GetAsync(ProductsTestData.Product1Id);
- var attributeOptionIds = new[]
+ var attributeOptionIds = new List
{
ProductsTestData.Product1Attribute1Option4Id,
ProductsTestData.Product1Attribute2Option2Id
@@ -140,9 +138,8 @@ namespace EasyAbp.EShop.Products.Products
await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(attributeOptionIds));
});
- var serializedAttributeOptionIds = await AttributeOptionIdsSerializer.SerializeAsync(attributeOptionIds);
- product1.ProductSkus.Count(x => x.SerializedAttributeOptionIds == serializedAttributeOptionIds).ShouldBe(1);
+ product1.ProductSkus.Count(x => x.AttributeOptionIds.SequenceEqual(attributeOptionIds)).ShouldBe(1);
}
[Fact]
@@ -152,7 +149,7 @@ namespace EasyAbp.EShop.Products.Products
await Should.ThrowAsync(async () =>
{
- await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(new[]
+ await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(new List
{
ProductsTestData.Product1Attribute1Option1Id // need 2 options but input 1
}));
@@ -160,7 +157,7 @@ namespace EasyAbp.EShop.Products.Products
await Should.ThrowAsync(async () =>
{
- await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(new[]
+ await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(new List
{
ProductsTestData.Product1Attribute1Option1Id,
Guid.NewGuid() // a nonexistent option
@@ -169,7 +166,7 @@ namespace EasyAbp.EShop.Products.Products
await Should.ThrowAsync(async () =>
{
- await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(new[]
+ await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(new List
{
ProductsTestData.Product1Attribute1Option1Id,
ProductsTestData.Product1Attribute1Option2Id // 2 options from attribute1
@@ -186,7 +183,8 @@ namespace EasyAbp.EShop.Products.Products
await ProductManager.CreateAsync(product2);
- var fakeSku = new ProductSku(Guid.NewGuid(), "[]", null, "USD", null, 0m, 1, 1, null, null, null);
+ var fakeSku = new ProductSku(Guid.NewGuid(), new List { Guid.NewGuid() }, null, "USD", null, 0m, 1, 1,
+ null, null, null);
var inventoryDataModel = await ProductManager.GetInventoryDataAsync(product2, fakeSku);
@@ -194,9 +192,9 @@ namespace EasyAbp.EShop.Products.Products
inventoryDataModel.Inventory.ShouldBe(9998);
}
- private async Task CreateTestSkuAsync(IEnumerable attributeOptionIds)
+ private async Task CreateTestSkuAsync(List attributeOptionIds)
{
- return new ProductSku(Guid.NewGuid(), await AttributeOptionIdsSerializer.SerializeAsync(attributeOptionIds),
+ return new ProductSku(Guid.NewGuid(), attributeOptionIds,
"test-sku", "USD", null, 0m, 1, 10, null, null, null);
}
}
diff --git a/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.TestBase/ProductsTestDataBuilder.cs b/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.TestBase/ProductsTestDataBuilder.cs
index b7ca74f3..4176a335 100644
--- a/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.TestBase/ProductsTestDataBuilder.cs
+++ b/modules/EasyAbp.EShop.Products/test/EasyAbp.EShop.Products.TestBase/ProductsTestDataBuilder.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
using EasyAbp.EShop.Products.ProductDetails;
using EasyAbp.EShop.Products.Products;
@@ -13,18 +14,15 @@ namespace EasyAbp.EShop.Products
private readonly IProductManager _productManager;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IProductDetailRepository _productDetailRepository;
- private readonly IAttributeOptionIdsSerializer _attributeOptionIdsSerializer;
public ProductsTestDataBuilder(
IProductManager productManager,
IUnitOfWorkManager unitOfWorkManager,
- IProductDetailRepository productDetailRepository,
- IAttributeOptionIdsSerializer attributeOptionIdsSerializer)
+ IProductDetailRepository productDetailRepository)
{
_productManager = productManager;
_unitOfWorkManager = unitOfWorkManager;
_productDetailRepository = productDetailRepository;
- _attributeOptionIdsSerializer = attributeOptionIdsSerializer;
}
public void Build()
@@ -71,18 +69,18 @@ namespace EasyAbp.EShop.Products
await _productManager.CreateAsync(product);
var productSku1 = new ProductSku(ProductsTestData.Product1Sku1Id,
- await _attributeOptionIdsSerializer.SerializeAsync(new[]
- { ProductsTestData.Product1Attribute1Option1Id, ProductsTestData.Product1Attribute2Option1Id }),
+ new List
+ { ProductsTestData.Product1Attribute1Option1Id, ProductsTestData.Product1Attribute2Option1Id },
null, "USD", null, 1m, 1, 10, null, null, null);
var productSku2 = new ProductSku(ProductsTestData.Product1Sku2Id,
- await _attributeOptionIdsSerializer.SerializeAsync(new[]
- { ProductsTestData.Product1Attribute1Option2Id, ProductsTestData.Product1Attribute2Option1Id }),
+ new List
+ { ProductsTestData.Product1Attribute1Option2Id, ProductsTestData.Product1Attribute2Option1Id },
null, "USD", null, 2m, 1, 10, null, null, null);
var productSku3 = new ProductSku(ProductsTestData.Product1Sku3Id,
- await _attributeOptionIdsSerializer.SerializeAsync(new[]
- { ProductsTestData.Product1Attribute1Option3Id, ProductsTestData.Product1Attribute2Option2Id }),
+ new List
+ { ProductsTestData.Product1Attribute1Option3Id, ProductsTestData.Product1Attribute2Option2Id },
null, "USD", null, 3m, 1, 10, null, null, null);
await _productManager.CreateSkuAsync(product, productSku1);
diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketItems/BasicBasketItemProductInfoUpdater.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketItems/BasicBasketItemProductInfoUpdater.cs
index 83cbaa78..7b257ac0 100644
--- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketItems/BasicBasketItemProductInfoUpdater.cs
+++ b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketItems/BasicBasketItemProductInfoUpdater.cs
@@ -27,7 +27,7 @@ public class BasicBasketItemProductInfoUpdater : IBasketItemProductInfoUpdater,
protected virtual async Task InternalUpdateAsync(int targetQuantity, IBasketItem item, ProductDto productDto)
{
- var productSkuDto = productDto.FindSkuById(item.ProductSkuId);
+ var productSkuDto = (ProductSkuDto)productDto.FindSkuById(item.ProductSkuId);
if (productSkuDto == null)
{
diff --git a/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/Authorization/BookingOrderCreationAuthorizationHandler.cs b/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/Authorization/BookingOrderCreationAuthorizationHandler.cs
index 7e698468..9396bd76 100644
--- a/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/Authorization/BookingOrderCreationAuthorizationHandler.cs
+++ b/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/Authorization/BookingOrderCreationAuthorizationHandler.cs
@@ -116,7 +116,7 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
}
}
- protected virtual OccupyAssetInfoModel CreateOccupyAssetInfoModel(Guid assetId, CreateOrderLineDto orderLine)
+ protected virtual OccupyAssetInfoModel CreateOccupyAssetInfoModel(Guid assetId, ICreateOrderLineInfo orderLine)
{
return new OccupyAssetInfoModel(
assetId,
@@ -128,7 +128,7 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
}
protected virtual OccupyAssetByCategoryInfoModel CreateOccupyAssetByCategoryInfoModel(Guid assetCategoryId,
- CreateOrderLineDto orderLine)
+ ICreateOrderLineInfo orderLine)
{
return new OccupyAssetByCategoryInfoModel(
assetCategoryId,
@@ -140,7 +140,7 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
);
}
- protected virtual async Task IsAssetInfoValidAsync(CreateOrderLineDto orderLine,
+ protected virtual async Task IsAssetInfoValidAsync(ICreateOrderLineInfo orderLine,
OrderCreationResource resource)
{
var mapping = (await _grantedStoreAppService.GetListAsync(new GetGrantedStoreListDto
@@ -179,7 +179,7 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
return productAsset is not null;
}
- protected virtual async Task IsAssetCategoryInfoValidAsync(CreateOrderLineDto orderLine,
+ protected virtual async Task IsAssetCategoryInfoValidAsync(ICreateOrderLineInfo orderLine,
OrderCreationResource resource)
{
var mapping = (await _grantedStoreAppService.GetListAsync(new GetGrantedStoreListDto
@@ -218,7 +218,7 @@ namespace EasyAbp.EShop.Orders.Booking.Authorization
return productAssetCategory is not null;
}
- protected virtual async Task IsPeriodInfoValidAsync(CreateOrderLineDto orderLine)
+ protected virtual async Task IsPeriodInfoValidAsync(ICreateOrderLineInfo orderLine)
{
var periodSchemeId = orderLine.GetBookingPeriodSchemeId();
var periodId = orderLine.GetBookingPeriodId();
diff --git a/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/BookingOrderLinePriceOverrider.cs b/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/BookingOrderLinePriceOverrider.cs
index 49af4375..20d160e2 100644
--- a/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/BookingOrderLinePriceOverrider.cs
+++ b/plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/BookingOrderLinePriceOverrider.cs
@@ -6,6 +6,7 @@ using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos;
using EasyAbp.EShop.Plugins.Booking.ProductAssets;
using EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos;
+using EasyAbp.EShop.Products.Products;
using EasyAbp.EShop.Products.Products.Dtos;
using NodaMoney;
using Volo.Abp.DependencyInjection;
@@ -25,8 +26,8 @@ public class BookingOrderLinePriceOverrider : IOrderLinePriceOverrider, ITransie
_productAssetCategoryAppService = productAssetCategoryAppService;
}
- public virtual async Task GetUnitPriceOrNullAsync(CreateOrderDto input, CreateOrderLineDto inputOrderLine,
- ProductDto product, ProductSkuDto productSku, Currency effectiveCurrency)
+ public virtual async Task GetUnitPriceOrNullAsync(ICreateOrderInfo input,
+ ICreateOrderLineInfo inputOrderLine, IProduct product, IProductSku productSku, Currency effectiveCurrency)
{
if (inputOrderLine.FindBookingAssetId() is not null)
{
@@ -41,8 +42,8 @@ public class BookingOrderLinePriceOverrider : IOrderLinePriceOverrider, ITransie
return null;
}
- public virtual async Task GetAssetBookingUnitPriceAsync(CreateOrderDto input,
- CreateOrderLineDto inputOrderLine, Currency effectiveCurrency)
+ public virtual async Task GetAssetBookingUnitPriceAsync(ICreateOrderInfo input,
+ ICreateOrderLineInfo inputOrderLine, Currency effectiveCurrency)
{
var productAsset = (await _productAssetAppService.GetListAsync(
new GetProductAssetListDto
@@ -76,8 +77,8 @@ public class BookingOrderLinePriceOverrider : IOrderLinePriceOverrider, ITransie
return null;
}
- public virtual async Task GetAssetCategoryBookingUnitPriceAsync(CreateOrderDto input,
- CreateOrderLineDto inputOrderLine, Currency effectiveCurrency)
+ public virtual async Task GetAssetCategoryBookingUnitPriceAsync(ICreateOrderInfo input,
+ ICreateOrderLineInfo inputOrderLine, Currency effectiveCurrency)
{
var productAssetCategory = (await _productAssetCategoryAppService.GetListAsync(
new GetProductAssetCategoryListDto
diff --git a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Orders/CreateOrderLineDtoExtensions.cs b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Orders/CreateOrderLineInfoExtensions.cs
similarity index 59%
rename from plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Orders/CreateOrderLineDtoExtensions.cs
rename to plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Orders/CreateOrderLineInfoExtensions.cs
index 1840702b..1c49e375 100644
--- a/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Orders/CreateOrderLineDtoExtensions.cs
+++ b/plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Orders/CreateOrderLineInfoExtensions.cs
@@ -1,94 +1,95 @@
using System;
+using EasyAbp.EShop.Orders.Orders;
using EasyAbp.EShop.Orders.Orders.Dtos;
using Volo.Abp;
using Volo.Abp.Data;
namespace EasyAbp.EShop.Orders;
-public static class CreateOrderLineDtoExtensions
+public static class CreateOrderLineInfoExtensions
{
- public static Guid? FindBookingAssetId(this CreateOrderLineDto orderLine)
+ public static Guid? FindBookingAssetId(this ICreateOrderLineInfo orderLine)
{
return orderLine.GetProperty(BookingOrderProperties.OrderLineBookingAssetId);
}
- public static Guid GetBookingAssetId(this CreateOrderLineDto orderLine)
+ public static Guid GetBookingAssetId(this ICreateOrderLineInfo orderLine)
{
return Check.NotNull(FindBookingAssetId(orderLine),
BookingOrderProperties.OrderLineBookingAssetId)!.Value;
}
- public static Guid? FindBookingAssetCategoryId(this CreateOrderLineDto orderLine)
+ public static Guid? FindBookingAssetCategoryId(this ICreateOrderLineInfo orderLine)
{
return orderLine.GetProperty(BookingOrderProperties.OrderLineBookingAssetCategoryId);
}
- public static Guid GetBookingAssetCategoryId(this CreateOrderLineDto orderLine)
+ public static Guid GetBookingAssetCategoryId(this ICreateOrderLineInfo orderLine)
{
return Check.NotNull(FindBookingAssetCategoryId(orderLine),
BookingOrderProperties.OrderLineBookingAssetCategoryId)!.Value;
}
- public static Guid? FindBookingPeriodSchemeId(this CreateOrderLineDto orderLine)
+ public static Guid? FindBookingPeriodSchemeId(this ICreateOrderLineInfo orderLine)
{
return orderLine.GetProperty(BookingOrderProperties.OrderLineBookingPeriodSchemeId);
}
- public static Guid GetBookingPeriodSchemeId(this CreateOrderLineDto orderLine)
+ public static Guid GetBookingPeriodSchemeId(this ICreateOrderLineInfo orderLine)
{
return Check.NotNull(FindBookingPeriodSchemeId(orderLine),
BookingOrderProperties.OrderLineBookingPeriodSchemeId)!.Value;
}
- public static Guid? FindBookingPeriodId(this CreateOrderLineDto orderLine)
+ public static Guid? FindBookingPeriodId(this ICreateOrderLineInfo orderLine)
{
return orderLine.GetProperty(BookingOrderProperties.OrderLineBookingPeriodId);
}
- public static Guid GetBookingPeriodId(this CreateOrderLineDto orderLine)
+ public static Guid GetBookingPeriodId(this ICreateOrderLineInfo orderLine)
{
return Check.NotNull(FindBookingPeriodId(orderLine),
BookingOrderProperties.OrderLineBookingPeriodId)!.Value;
}
- public static int? FindBookingVolume(this CreateOrderLineDto orderLine)
+ public static int? FindBookingVolume(this ICreateOrderLineInfo orderLine)
{
return orderLine.Quantity;
}
- public static int GetBookingVolume(this CreateOrderLineDto orderLine)
+ public static int GetBookingVolume(this ICreateOrderLineInfo orderLine)
{
return FindBookingVolume(orderLine)!.Value;
}
- public static DateTime? FindBookingDate(this CreateOrderLineDto orderLine)
+ public static DateTime? FindBookingDate(this ICreateOrderLineInfo orderLine)
{
return orderLine.FindDateTimeProperty(BookingOrderProperties.OrderLineBookingDate);
}
- public static DateTime GetBookingDate(this CreateOrderLineDto orderLine)
+ public static DateTime GetBookingDate(this ICreateOrderLineInfo orderLine)
{
return Check.NotNull(FindBookingDate(orderLine),
BookingOrderProperties.OrderLineBookingDate)!.Value;
}
- public static TimeSpan? FindBookingStartingTime(this CreateOrderLineDto orderLine)
+ public static TimeSpan? FindBookingStartingTime(this ICreateOrderLineInfo orderLine)
{
return orderLine.FindTimeSpanProperty(BookingOrderProperties.OrderLineBookingStartingTime);
}
- public static TimeSpan GetBookingStartingTime(this CreateOrderLineDto orderLine)
+ public static TimeSpan GetBookingStartingTime(this ICreateOrderLineInfo orderLine)
{
return Check.NotNull(FindBookingStartingTime(orderLine),
BookingOrderProperties.OrderLineBookingStartingTime)!.Value;
}
- public static TimeSpan? FindBookingDuration(this CreateOrderLineDto orderLine)
+ public static TimeSpan? FindBookingDuration(this ICreateOrderLineInfo orderLine)
{
return orderLine.FindTimeSpanProperty(BookingOrderProperties.OrderLineBookingDuration);
}
- public static TimeSpan GetBookingDuration(this CreateOrderLineDto orderLine)
+ public static TimeSpan GetBookingDuration(this ICreateOrderLineInfo orderLine)
{
return Check.NotNull(FindBookingDuration(orderLine),
BookingOrderProperties.OrderLineBookingDuration)!.Value;
diff --git a/plugins/Coupons/src/EasyAbp.EShop.Orders.Plugins.Coupons/EasyAbp/EShop/Orders/Plugins/Coupons/OrderDiscount/CouponOrderDiscountProvider.cs b/plugins/Coupons/src/EasyAbp.EShop.Orders.Plugins.Coupons/EasyAbp/EShop/Orders/Plugins/Coupons/OrderDiscount/CouponOrderDiscountProvider.cs
index 7f3d640f..c55e486f 100644
--- a/plugins/Coupons/src/EasyAbp.EShop.Orders.Plugins.Coupons/EasyAbp/EShop/Orders/Plugins/Coupons/OrderDiscount/CouponOrderDiscountProvider.cs
+++ b/plugins/Coupons/src/EasyAbp.EShop.Orders.Plugins.Coupons/EasyAbp/EShop/Orders/Plugins/Coupons/OrderDiscount/CouponOrderDiscountProvider.cs
@@ -7,7 +7,8 @@ using EasyAbp.EShop.Plugins.Coupons;
using EasyAbp.EShop.Plugins.Coupons.Coupons;
using EasyAbp.EShop.Plugins.Coupons.Coupons.Dtos;
using EasyAbp.EShop.Plugins.Coupons.CouponTemplates;
-using EasyAbp.EShop.Products.Products.Dtos;
+using EasyAbp.EShop.Products.Products;
+using NodaMoney;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Timing;
@@ -16,6 +17,8 @@ namespace EasyAbp.EShop.Orders.Plugins.Coupons.OrderDiscount
{
public class CouponOrderDiscountProvider : IOrderDiscountProvider, ITransientDependency
{
+ public static string OrderDiscountName { get; set; } = "Coupon";
+
private readonly IClock _clock;
private readonly ICouponAppService _couponAppService;
private readonly ICouponLookupService _couponLookupService;
@@ -32,13 +35,14 @@ namespace EasyAbp.EShop.Orders.Plugins.Coupons.OrderDiscount
_couponLookupService = couponLookupService;
_couponTemplateLookupService = couponTemplateLookupService;
}
-
- public virtual async Task DiscountAsync(Order order, Dictionary productDict)
+
+ public virtual async Task> GetAllAsync(Order order,
+ Dictionary productDict)
{
var couponId = order.GetProperty(CouponsConsts.OrderCouponIdPropertyName);
if (couponId is null)
{
- return order;
+ return new List();
}
var now = _clock.Now;
@@ -54,7 +58,7 @@ namespace EasyAbp.EShop.Orders.Plugins.Coupons.OrderDiscount
{
throw new CouponHasBeenOccupiedException();
}
-
+
var couponTemplate = await _couponTemplateLookupService.FindByIdAsync(coupon.CouponTemplateId);
if (couponTemplate == null ||
@@ -65,12 +69,12 @@ namespace EasyAbp.EShop.Orders.Plugins.Coupons.OrderDiscount
}
var orderLinesInScope = GetOrderLinesInScope(couponTemplate, order, productDict);
-
- DiscountOrderLines(couponTemplate, order, orderLinesInScope);
-
- await _couponAppService.OccupyAsync(coupon.Id, new OccupyCouponInput {OrderId = order.Id});
- return order;
+ var models = await DiscountOrderLinesAsync(couponTemplate, coupon, order, orderLinesInScope);
+
+ await _couponAppService.OccupyAsync(coupon.Id, new OccupyCouponInput { OrderId = order.Id });
+
+ return models;
}
protected virtual bool IsCurrencyExpected(CouponTemplateData couponTemplate, Order order)
@@ -78,21 +82,25 @@ namespace EasyAbp.EShop.Orders.Plugins.Coupons.OrderDiscount
return couponTemplate.Currency == order.Currency;
}
- protected virtual void DiscountOrderLines(CouponTemplateData couponTemplate, Order order,
- List