Browse Source

Add Currency properties

pull/150/head
gdlcf88 4 years ago
parent
commit
826f0711f8
  1. 34
      plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/BookingOrderLinePriceOverrider.cs
  2. 17
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/CreateProductAssetCategoryDto.cs
  3. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/CreateProductAssetCategoryPeriodDto.cs
  4. 2
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/ProductAssetCategoryDto.cs
  5. 2
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/ProductAssetCategoryPeriodDto.cs
  6. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/UpdateProductAssetCategoryDto.cs
  7. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/UpdateProductAssetCategoryPeriodDto.cs
  8. 16
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/CreateProductAssetDto.cs
  9. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/CreateProductAssetPeriodDto.cs
  10. 2
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/ProductAssetDto.cs
  11. 2
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/ProductAssetPeriodDto.cs
  12. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/UpdateProductAssetDto.cs
  13. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/UpdateProductAssetPeriodDto.cs
  14. 12
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryAppService.cs
  15. 8
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetAppService.cs
  16. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain.Shared/EasyAbp/EShop/Plugins/Booking/Localization/en.json
  17. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain.Shared/EasyAbp/EShop/Plugins/Booking/Localization/zh-Hans.json
  18. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain.Shared/EasyAbp/EShop/Plugins/Booking/Localization/zh-Hant.json
  19. 48
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory.cs
  20. 10
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs
  21. 18
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetManager.cs
  22. 28
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAsset.cs
  23. 12
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetManager.cs
  24. 10
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs
  25. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory/ViewModels/CreateProductAssetCategoryViewModel.cs
  26. 6
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory/ViewModels/EditProductAssetCategoryViewModel.cs
  27. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory/index.js
  28. 7
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod/ViewModels/CreateProductAssetCategoryPeriodViewModel.cs
  29. 8
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod/ViewModels/EditProductAssetCategoryPeriodViewModel.cs
  30. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod/index.js
  31. 3
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAsset/ViewModels/CreateProductAssetViewModel.cs
  32. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAsset/ViewModels/EditProductAssetViewModel.cs
  33. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAsset/index.js
  34. 5
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod/ViewModels/CreateProductAssetPeriodViewModel.cs
  35. 6
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod/ViewModels/EditProductAssetPeriodViewModel.cs
  36. 4
      plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod/index.js
  37. 4
      plugins/Booking/test/EasyAbp.EShop.Plugins.Booking.TestBase/BookingDataSeedContributor.cs
  38. 5440
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220701165019_AddedCurrencyProperties.Designer.cs
  39. 55
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220701165019_AddedCurrencyProperties.cs
  40. 14
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/EShopSampleDbContextModelSnapshot.cs

34
plugins/Booking/src/EasyAbp.EShop.Orders.Booking.Application/EasyAbp/EShop/Orders/Booking/BookingOrderLinePriceOverrider.cs

@ -61,10 +61,19 @@ public class BookingOrderLinePriceOverrider : IOrderLinePriceOverrider, ITransie
if (productAssetPeriod is not null) if (productAssetPeriod is not null)
{ {
await CheckCurrencyAsync(productAssetPeriod.Currency, effectiveCurrency);
return new Money(productAssetPeriod.Price, effectiveCurrency); return new Money(productAssetPeriod.Price, effectiveCurrency);
} }
return productAsset.Price.HasValue ? new Money(productAsset.Price.Value, effectiveCurrency) : null; if (productAsset.Price.HasValue)
{
await CheckCurrencyAsync(productAsset.Currency, effectiveCurrency);
return new Money(productAsset.Price.Value, effectiveCurrency);
}
return null;
} }
public virtual async Task<Money?> GetAssetCategoryBookingUnitPriceAsync(CreateOrderDto input, public virtual async Task<Money?> GetAssetCategoryBookingUnitPriceAsync(CreateOrderDto input,
@ -87,11 +96,28 @@ public class BookingOrderLinePriceOverrider : IOrderLinePriceOverrider, ITransie
if (productAssetCategoryPeriod is not null) if (productAssetCategoryPeriod is not null)
{ {
await CheckCurrencyAsync(productAssetCategoryPeriod.Currency, effectiveCurrency);
return new Money(productAssetCategoryPeriod.Price, effectiveCurrency); return new Money(productAssetCategoryPeriod.Price, effectiveCurrency);
} }
return productAssetCategory.Price.HasValue if (productAssetCategory.Price.HasValue)
? new Money(productAssetCategory.Price.Value, effectiveCurrency) {
: null; await CheckCurrencyAsync(productAssetCategory.Currency, effectiveCurrency);
return new Money(productAssetCategory.Price.Value, effectiveCurrency);
}
return null;
}
protected virtual Task CheckCurrencyAsync(string currency, Currency effectiveCurrency)
{
if (currency != effectiveCurrency.Code)
{
throw new UnexpectedCurrencyException(effectiveCurrency.Code);
}
return Task.CompletedTask;
} }
} }

17
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/CreateProductAssetCategoryDto.cs

@ -1,12 +1,12 @@
using System; using System;
using System.ComponentModel; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using EasyAbp.EShop.Stores.Stores; using EasyAbp.EShop.Stores.Stores;
namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
{ {
[Serializable] [Serializable]
public class CreateProductAssetCategoryDto : IMultiStore public class CreateProductAssetCategoryDto : IMultiStore, IValidatableObject
{ {
public Guid StoreId { get; set; } public Guid StoreId { get; set; }
@ -22,7 +22,20 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Price is not null && Currency.IsNullOrWhiteSpace())
{
yield return new ValidationResult(
"Currency should not be empty when the Price has a value!",
new[] { nameof(Currency) }
);
}
}
} }
} }

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/CreateProductAssetCategoryPeriodDto.cs

@ -1,5 +1,4 @@
using System; using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
@ -9,6 +8,9 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
{ {
public Guid PeriodId { get; set; } public Guid PeriodId { get; set; }
[Required]
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }
} }

2
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/ProductAssetCategoryDto.cs

@ -21,6 +21,8 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
public string Currency { get; set; }
public decimal? Price { get; set; } public decimal? Price { get; set; }
public List<ProductAssetCategoryPeriodDto> Periods { get; set; } public List<ProductAssetCategoryPeriodDto> Periods { get; set; }

2
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/ProductAssetCategoryPeriodDto.cs

@ -8,6 +8,8 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
{ {
public Guid PeriodId { get; set; } public Guid PeriodId { get; set; }
public string Currency { get; set; }
public decimal Price { get; set; } public decimal Price { get; set; }
} }
} }

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/UpdateProductAssetCategoryDto.cs

@ -11,6 +11,9 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
[Required]
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }
} }

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/Dtos/UpdateProductAssetCategoryPeriodDto.cs

@ -7,6 +7,9 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories.Dtos
[Serializable] [Serializable]
public class UpdateProductAssetCategoryPeriodDto public class UpdateProductAssetCategoryPeriodDto
{ {
[Required]
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }
} }

16
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/CreateProductAssetDto.cs

@ -1,11 +1,12 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using EasyAbp.EShop.Stores.Stores; using EasyAbp.EShop.Stores.Stores;
namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos
{ {
[Serializable] [Serializable]
public class CreateProductAssetDto : IMultiStore public class CreateProductAssetDto : IMultiStore, IValidatableObject
{ {
public Guid StoreId { get; set; } public Guid StoreId { get; set; }
@ -21,7 +22,20 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Price is not null && Currency.IsNullOrWhiteSpace())
{
yield return new ValidationResult(
"Currency should not be empty when the Price has a value!",
new[] { nameof(Currency) }
);
}
}
} }
} }

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/CreateProductAssetPeriodDto.cs

@ -8,6 +8,9 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos
{ {
public Guid PeriodId { get; set; } public Guid PeriodId { get; set; }
[Required]
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }
} }

2
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/ProductAssetDto.cs

@ -21,6 +21,8 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
public string Currency { get; set; }
public decimal? Price { get; set; } public decimal? Price { get; set; }
public List<ProductAssetPeriodDto> Periods { get; set; } public List<ProductAssetPeriodDto> Periods { get; set; }

2
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/ProductAssetPeriodDto.cs

@ -8,6 +8,8 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos
{ {
public Guid PeriodId { get; set; } public Guid PeriodId { get; set; }
public string Currency { get; set; }
public decimal Price { get; set; } public decimal Price { get; set; }
} }
} }

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/UpdateProductAssetDto.cs

@ -12,6 +12,9 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
[Required]
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }
} }

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application.Contracts/EasyAbp/EShop/Plugins/Booking/ProductAssets/Dtos/UpdateProductAssetPeriodDto.cs

@ -6,6 +6,9 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets.Dtos
[Serializable] [Serializable]
public class UpdateProductAssetPeriodDto public class UpdateProductAssetPeriodDto
{ {
[Required]
public string Currency { get; set; }
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }
} }

12
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryAppService.cs

@ -43,7 +43,8 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories
_productAssetCategoryManager = productAssetCategoryManager; _productAssetCategoryManager = productAssetCategoryManager;
} }
protected override async Task<IQueryable<ProductAssetCategory>> CreateFilteredQueryAsync(GetProductAssetCategoryListDto input) protected override async Task<IQueryable<ProductAssetCategory>> CreateFilteredQueryAsync(
GetProductAssetCategoryListDto input)
{ {
return (await base.CreateFilteredQueryAsync(input)) return (await base.CreateFilteredQueryAsync(input))
.WhereIf(input.StoreId.HasValue, x => x.StoreId == input.StoreId) .WhereIf(input.StoreId.HasValue, x => x.StoreId == input.StoreId)
@ -57,7 +58,7 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories
GetProductAssetCategoryListDto input) GetProductAssetCategoryListDto input)
{ {
await CheckMultiStorePolicyAsync(input.StoreId, GetListPolicyName); await CheckMultiStorePolicyAsync(input.StoreId, GetListPolicyName);
var query = await CreateFilteredQueryAsync(input); var query = await CreateFilteredQueryAsync(input);
var totalCount = await AsyncExecuter.CountAsync(query); var totalCount = await AsyncExecuter.CountAsync(query);
@ -118,12 +119,13 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories
protected override async Task<ProductAssetCategory> MapToEntityAsync(CreateProductAssetCategoryDto input) protected override async Task<ProductAssetCategory> MapToEntityAsync(CreateProductAssetCategoryDto input)
{ {
return await _productAssetCategoryManager.CreateAsync(input.StoreId, input.ProductId, input.ProductSkuId, return await _productAssetCategoryManager.CreateAsync(input.StoreId, input.ProductId, input.ProductSkuId,
input.AssetCategoryId, input.PeriodSchemeId, input.FromTime, input.ToTime, input.Price); input.AssetCategoryId, input.PeriodSchemeId, input.FromTime, input.ToTime, input.Currency, input.Price);
} }
protected override async Task MapToEntityAsync(UpdateProductAssetCategoryDto input, ProductAssetCategory entity) protected override async Task MapToEntityAsync(UpdateProductAssetCategoryDto input, ProductAssetCategory entity)
{ {
await _productAssetCategoryManager.UpdateAsync(entity, input.FromTime, input.ToTime, input.Price); await _productAssetCategoryManager.UpdateAsync(
entity, input.FromTime, input.ToTime, input.Currency, input.Price);
} }
public virtual async Task<ProductAssetCategoryDto> CreatePeriodAsync(Guid productAssetCategoryId, public virtual async Task<ProductAssetCategoryDto> CreatePeriodAsync(Guid productAssetCategoryId,
@ -170,4 +172,4 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories
return await MapToGetOutputDtoAsync(productAssetCategory); return await MapToGetOutputDtoAsync(productAssetCategory);
} }
} }
} }

8
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Application/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetAppService.cs

@ -57,7 +57,7 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets
GetProductAssetListDto input) GetProductAssetListDto input)
{ {
await CheckMultiStorePolicyAsync(input.StoreId, GetListPolicyName); await CheckMultiStorePolicyAsync(input.StoreId, GetListPolicyName);
var query = await CreateFilteredQueryAsync(input); var query = await CreateFilteredQueryAsync(input);
var totalCount = await AsyncExecuter.CountAsync(query); var totalCount = await AsyncExecuter.CountAsync(query);
@ -118,12 +118,12 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets
protected override async Task<ProductAsset> MapToEntityAsync(CreateProductAssetDto input) protected override async Task<ProductAsset> MapToEntityAsync(CreateProductAssetDto input)
{ {
return await _productAssetManager.CreateAsync(input.StoreId, input.ProductId, input.ProductSkuId, return await _productAssetManager.CreateAsync(input.StoreId, input.ProductId, input.ProductSkuId,
input.AssetId, input.PeriodSchemeId, input.FromTime, input.ToTime, input.Price); input.AssetId, input.PeriodSchemeId, input.FromTime, input.ToTime, input.Currency, input.Price);
} }
protected override async Task MapToEntityAsync(UpdateProductAssetDto input, ProductAsset entity) protected override async Task MapToEntityAsync(UpdateProductAssetDto input, ProductAsset entity)
{ {
await _productAssetManager.UpdateAsync(entity, input.FromTime, input.ToTime, input.Price); await _productAssetManager.UpdateAsync(entity, input.FromTime, input.ToTime, input.Currency, input.Price);
} }
public virtual async Task<ProductAssetDto> CreatePeriodAsync(Guid productAssetId, public virtual async Task<ProductAssetDto> CreatePeriodAsync(Guid productAssetId,
@ -170,4 +170,4 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets
return await MapToGetOutputDtoAsync(productAsset); return await MapToGetOutputDtoAsync(productAsset);
} }
} }
} }

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain.Shared/EasyAbp/EShop/Plugins/Booking/Localization/en.json

@ -15,6 +15,7 @@
"ProductAssetPeriodSchemeId": "Period Scheme ID", "ProductAssetPeriodSchemeId": "Period Scheme ID",
"ProductAssetFromTime": "From time", "ProductAssetFromTime": "From time",
"ProductAssetToTime": "To time", "ProductAssetToTime": "To time",
"ProductAssetCurrency": "Currency",
"ProductAssetPrice": "Price", "ProductAssetPrice": "Price",
"ProductAssetPeriods": "Period prices", "ProductAssetPeriods": "Period prices",
"CreateProductAsset": "New", "CreateProductAsset": "New",
@ -24,6 +25,7 @@
"Menu:ProductAssetPeriod": "Asset period prices", "Menu:ProductAssetPeriod": "Asset period prices",
"ProductAssetPeriod": "Asset period prices", "ProductAssetPeriod": "Asset period prices",
"ProductAssetPeriodPeriodId": "Period ID", "ProductAssetPeriodPeriodId": "Period ID",
"ProductAssetPeriodCurrency": "Currency",
"ProductAssetPeriodPrice": "Price", "ProductAssetPeriodPrice": "Price",
"CreateProductAssetPeriod": "New", "CreateProductAssetPeriod": "New",
"EditProductAssetPeriod": "Edit", "EditProductAssetPeriod": "Edit",
@ -38,6 +40,7 @@
"ProductAssetCategoryPeriodSchemeId": "Period Scheme ID", "ProductAssetCategoryPeriodSchemeId": "Period Scheme ID",
"ProductAssetCategoryFromTime": "From time", "ProductAssetCategoryFromTime": "From time",
"ProductAssetCategoryToTime": "To time", "ProductAssetCategoryToTime": "To time",
"ProductAssetCategoryCurrency": "Currency",
"ProductAssetCategoryPrice": "Price", "ProductAssetCategoryPrice": "Price",
"ProductAssetCategoryPeriods": "Period prices", "ProductAssetCategoryPeriods": "Period prices",
"CreateProductAssetCategory": "New", "CreateProductAssetCategory": "New",
@ -46,6 +49,7 @@
"Menu:ProductAssetCategoryPeriod": "Asset category period prices", "Menu:ProductAssetCategoryPeriod": "Asset category period prices",
"ProductAssetCategoryPeriod": "Asset category period prices", "ProductAssetCategoryPeriod": "Asset category period prices",
"ProductAssetCategoryPeriodPeriodId": "Period ID", "ProductAssetCategoryPeriodPeriodId": "Period ID",
"ProductAssetCategoryPeriodCurrency": "Currency",
"ProductAssetCategoryPeriodPrice": "Price", "ProductAssetCategoryPeriodPrice": "Price",
"CreateProductAssetCategoryPeriod": "New", "CreateProductAssetCategoryPeriod": "New",
"EditProductAssetCategoryPeriod": "Edit", "EditProductAssetCategoryPeriod": "Edit",

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain.Shared/EasyAbp/EShop/Plugins/Booking/Localization/zh-Hans.json

@ -15,6 +15,7 @@
"ProductAssetPeriodSchemeId": "时段方案 ID", "ProductAssetPeriodSchemeId": "时段方案 ID",
"ProductAssetFromTime": "生效时间", "ProductAssetFromTime": "生效时间",
"ProductAssetToTime": "结束时间", "ProductAssetToTime": "结束时间",
"ProductAssetCurrency": "币种",
"ProductAssetPrice": "价格", "ProductAssetPrice": "价格",
"ProductAssetPeriods": "时段价格", "ProductAssetPeriods": "时段价格",
"CreateProductAsset": "新建", "CreateProductAsset": "新建",
@ -24,6 +25,7 @@
"Menu:ProductAssetPeriod": "资产时段价格", "Menu:ProductAssetPeriod": "资产时段价格",
"ProductAssetPeriod": "资产时段价格", "ProductAssetPeriod": "资产时段价格",
"ProductAssetPeriodPeriodId": "时段 ID", "ProductAssetPeriodPeriodId": "时段 ID",
"ProductAssetPeriodCurrency": "币种",
"ProductAssetPeriodPrice": "价格", "ProductAssetPeriodPrice": "价格",
"CreateProductAssetPeriod": "新建", "CreateProductAssetPeriod": "新建",
"EditProductAssetPeriod": "编辑", "EditProductAssetPeriod": "编辑",
@ -38,6 +40,7 @@
"ProductAssetCategoryPeriodSchemeId": "时段方案 ID", "ProductAssetCategoryPeriodSchemeId": "时段方案 ID",
"ProductAssetCategoryFromTime": "生效时间", "ProductAssetCategoryFromTime": "生效时间",
"ProductAssetCategoryToTime": "结束时间", "ProductAssetCategoryToTime": "结束时间",
"ProductAssetCategoryCurrency": "币种",
"ProductAssetCategoryPrice": "价格", "ProductAssetCategoryPrice": "价格",
"ProductAssetCategoryPeriods": "时段价格", "ProductAssetCategoryPeriods": "时段价格",
"CreateProductAssetCategory": "新建", "CreateProductAssetCategory": "新建",
@ -46,6 +49,7 @@
"Menu:ProductAssetCategoryPeriod": "资产类目时段价格", "Menu:ProductAssetCategoryPeriod": "资产类目时段价格",
"ProductAssetCategoryPeriod": "资产类目时段价格", "ProductAssetCategoryPeriod": "资产类目时段价格",
"ProductAssetCategoryPeriodPeriodId": "时段 ID", "ProductAssetCategoryPeriodPeriodId": "时段 ID",
"ProductAssetCategoryPeriodCurrency": "币种",
"ProductAssetCategoryPeriodPrice": "价格", "ProductAssetCategoryPeriodPrice": "价格",
"CreateProductAssetCategoryPeriod": "新建", "CreateProductAssetCategoryPeriod": "新建",
"EditProductAssetCategoryPeriod": "编辑", "EditProductAssetCategoryPeriod": "编辑",

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain.Shared/EasyAbp/EShop/Plugins/Booking/Localization/zh-Hant.json

@ -15,6 +15,7 @@
"ProductAssetPeriodSchemeId": "時段方案 ID", "ProductAssetPeriodSchemeId": "時段方案 ID",
"ProductAssetFromTime": "生效時間", "ProductAssetFromTime": "生效時間",
"ProductAssetToTime": "結束時間", "ProductAssetToTime": "結束時間",
"ProductAssetCurrency": "幣種",
"ProductAssetPrice": "價格", "ProductAssetPrice": "價格",
"ProductAssetPeriods": "時段價格", "ProductAssetPeriods": "時段價格",
"CreateProductAsset": "新建", "CreateProductAsset": "新建",
@ -24,6 +25,7 @@
"Menu:ProductAssetPeriod": "資產時段價格", "Menu:ProductAssetPeriod": "資產時段價格",
"ProductAssetPeriod": "資產時段價格", "ProductAssetPeriod": "資產時段價格",
"ProductAssetPeriodPeriodId": "時段 ID", "ProductAssetPeriodPeriodId": "時段 ID",
"ProductAssetPeriodCurrency": "幣種",
"ProductAssetPeriodPrice": "價格", "ProductAssetPeriodPrice": "價格",
"CreateProductAssetPeriod": "新建", "CreateProductAssetPeriod": "新建",
"EditProductAssetPeriod": "編輯", "EditProductAssetPeriod": "編輯",
@ -38,6 +40,7 @@
"ProductAssetCategoryPeriodSchemeId": "時段方案 ID", "ProductAssetCategoryPeriodSchemeId": "時段方案 ID",
"ProductAssetCategoryFromTime": "生效時間", "ProductAssetCategoryFromTime": "生效時間",
"ProductAssetCategoryToTime": "結束時間", "ProductAssetCategoryToTime": "結束時間",
"ProductAssetCategoryCurrency": "幣種",
"ProductAssetCategoryPrice": "價格", "ProductAssetCategoryPrice": "價格",
"ProductAssetCategoryPeriods": "時段價格", "ProductAssetCategoryPeriods": "時段價格",
"CreateProductAssetCategory": "新建", "CreateProductAssetCategory": "新建",
@ -46,6 +49,7 @@
"Menu:ProductAssetCategoryPeriod": "資產類目時段價格", "Menu:ProductAssetCategoryPeriod": "資產類目時段價格",
"ProductAssetCategoryPeriod": "資產類目時段價格", "ProductAssetCategoryPeriod": "資產類目時段價格",
"ProductAssetCategoryPeriodPeriodId": "時段 ID", "ProductAssetCategoryPeriodPeriodId": "時段 ID",
"ProductAssetCategoryPeriodCurrency": "幣種",
"ProductAssetCategoryPeriodPrice": "價格", "ProductAssetCategoryPeriodPrice": "價格",
"CreateProductAssetCategoryPeriod": "新建", "CreateProductAssetCategoryPeriod": "新建",
"EditProductAssetCategoryPeriod": "編輯", "EditProductAssetCategoryPeriod": "編輯",

48
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory.cs

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using EasyAbp.EShop.Plugins.Booking.Shared; using EasyAbp.EShop.Plugins.Booking.Shared;
using EasyAbp.EShop.Stores.Stores; using EasyAbp.EShop.Stores.Stores;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
@ -16,34 +18,40 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
public class ProductAssetCategory : AuditedAggregateRoot<Guid>, IMultiStore, IMultiTenant public class ProductAssetCategory : AuditedAggregateRoot<Guid>, IMultiStore, IMultiTenant
{ {
public virtual Guid? TenantId { get; protected set; } public virtual Guid? TenantId { get; protected set; }
public virtual Guid StoreId { get; protected set; } public virtual Guid StoreId { get; protected set; }
public virtual Guid ProductId { get; protected set; } public virtual Guid ProductId { get; protected set; }
public virtual Guid ProductSkuId { get; protected set; } public virtual Guid ProductSkuId { get; protected set; }
public virtual Guid AssetCategoryId { get; protected set; } public virtual Guid AssetCategoryId { get; protected set; }
public virtual Guid PeriodSchemeId { get; protected set; } public virtual Guid PeriodSchemeId { get; protected set; }
/// <summary> /// <summary>
/// When will this mapping start taking effect. /// When will this mapping start taking effect.
/// </summary> /// </summary>
public virtual DateTime FromTime { get; protected set; } public virtual DateTime FromTime { get; protected set; }
/// <summary> /// <summary>
/// When will this mapping stop taking effect. /// When will this mapping stop taking effect.
/// Setting to <c>null</c> means until forever. /// Setting to <c>null</c> means until forever.
/// </summary> /// </summary>
public virtual DateTime? ToTime { get; protected set; } public virtual DateTime? ToTime { get; protected set; }
/// <summary>
/// Should set if the <see cref="Price"/> is not <c>null</c>.
/// </summary>
[CanBeNull]
public virtual string Currency { get; protected set; }
/// <summary> /// <summary>
/// Price for any period. /// Price for any period.
/// Fall back to the price of ProductSku if <c>null</c>. /// Fall back to the price of ProductSku if <c>null</c>.
/// </summary> /// </summary>
public virtual decimal? Price { get; protected set; } public virtual decimal? Price { get; protected set; }
/// <summary> /// <summary>
/// Customize prices for specified periods. /// Customize prices for specified periods.
/// </summary> /// </summary>
@ -63,6 +71,7 @@ public class ProductAssetCategory : AuditedAggregateRoot<Guid>, IMultiStore, IMu
Guid periodSchemeId, Guid periodSchemeId,
DateTime fromTime, DateTime fromTime,
DateTime? toTime, DateTime? toTime,
[CanBeNull] string currency,
decimal? price, decimal? price,
List<ProductAssetCategoryPeriod> periods List<ProductAssetCategoryPeriod> periods
) : base(id) ) : base(id)
@ -75,18 +84,29 @@ public class ProductAssetCategory : AuditedAggregateRoot<Guid>, IMultiStore, IMu
PeriodSchemeId = periodSchemeId; PeriodSchemeId = periodSchemeId;
FromTime = fromTime; FromTime = fromTime;
ToTime = toTime; ToTime = toTime;
Price = price; SetPrice(currency, price);
Periods = periods ?? new List<ProductAssetCategoryPeriod>(); Periods = periods ?? new List<ProductAssetCategoryPeriod>();
} }
internal void Update(DateTime fromTime, DateTime? toTime, decimal? price) internal void Update(DateTime fromTime, DateTime? toTime, [CanBeNull] string currency, decimal? price)
{ {
FromTime = fromTime; FromTime = fromTime;
ToTime = toTime; ToTime = toTime;
SetPrice(currency, price);
}
protected void SetPrice([CanBeNull] string currency, decimal? price)
{
if (price is not null)
{
Check.NotNull(currency, nameof(currency));
}
Currency = currency;
Price = price; Price = price;
} }
public void AddPeriod(ProductAssetCategoryPeriod productAssetCategoryPeriod) public void AddPeriod(ProductAssetCategoryPeriod productAssetCategoryPeriod)
{ {
if (FindPeriod(productAssetCategoryPeriod.PeriodId) is not null) if (FindPeriod(productAssetCategoryPeriod.PeriodId) is not null)
@ -111,4 +131,4 @@ public class ProductAssetCategory : AuditedAggregateRoot<Guid>, IMultiStore, IMu
{ {
return Periods.FirstOrDefault(x => x.PeriodId == periodId); return Periods.FirstOrDefault(x => x.PeriodId == periodId);
} }
} }

10
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod.cs

@ -1,4 +1,5 @@
using System; using System;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories; namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
@ -6,7 +7,10 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
public class ProductAssetCategoryPeriod : Entity<Guid> public class ProductAssetCategoryPeriod : Entity<Guid>
{ {
public virtual Guid PeriodId { get; protected set; } public virtual Guid PeriodId { get; protected set; }
[NotNull]
public virtual string Currency { get; protected set; }
public virtual decimal Price { get; protected set; } public virtual decimal Price { get; protected set; }
protected ProductAssetCategoryPeriod() protected ProductAssetCategoryPeriod()
@ -16,10 +20,12 @@ public class ProductAssetCategoryPeriod : Entity<Guid>
public ProductAssetCategoryPeriod( public ProductAssetCategoryPeriod(
Guid id, Guid id,
Guid periodId, Guid periodId,
[NotNull] string currency,
decimal price decimal price
) : base(id) ) : base(id)
{ {
PeriodId = periodId; PeriodId = periodId;
Currency = currency;
Price = price; Price = price;
} }
} }

18
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetManager.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Domain.Services; using Volo.Abp.Domain.Services;
@ -15,22 +16,25 @@ public class ProductAssetCategoryManager : DomainService
_repository = repository; _repository = repository;
} }
public virtual async Task<ProductAssetCategory> CreateAsync(Guid storeId, Guid productId, Guid productSkuId, Guid assetCategoryId, public virtual async Task<ProductAssetCategory> CreateAsync(Guid storeId, Guid productId, Guid productSkuId,
Guid periodSchemeId, DateTime fromTime, DateTime? toTime, decimal? price) Guid assetCategoryId,
Guid periodSchemeId, DateTime fromTime, DateTime? toTime, [CanBeNull] string currency, decimal? price)
{ {
var id = GuidGenerator.Create(); var id = GuidGenerator.Create();
if (await _repository.ExistConflictAsync( if (await _repository.ExistConflictAsync(
id, storeId, productId, productSkuId, assetCategoryId, periodSchemeId, fromTime)) id, storeId, productId, productSkuId, assetCategoryId, periodSchemeId, fromTime))
{ {
throw new BusinessException(BookingErrorCodes.ConflictingProductAssetCategory); throw new BusinessException(BookingErrorCodes.ConflictingProductAssetCategory);
} }
return new ProductAssetCategory(GuidGenerator.Create(), CurrentTenant.Id, storeId, productId, productSkuId, assetCategoryId, return new ProductAssetCategory(GuidGenerator.Create(), CurrentTenant.Id, storeId, productId, productSkuId,
periodSchemeId, fromTime, toTime, price, new List<ProductAssetCategoryPeriod>()); assetCategoryId,
periodSchemeId, fromTime, toTime, currency, price, new List<ProductAssetCategoryPeriod>());
} }
public virtual async Task UpdateAsync(ProductAssetCategory entity, DateTime fromTime, DateTime? toTime, decimal? price) public virtual async Task UpdateAsync(ProductAssetCategory entity, DateTime fromTime, DateTime? toTime,
[NotNull] string currency, decimal? price)
{ {
if (await _repository.ExistConflictAsync(entity.Id, entity.StoreId, entity.ProductId, entity.ProductSkuId, if (await _repository.ExistConflictAsync(entity.Id, entity.StoreId, entity.ProductId, entity.ProductSkuId,
entity.AssetCategoryId, entity.PeriodSchemeId, fromTime)) entity.AssetCategoryId, entity.PeriodSchemeId, fromTime))
@ -38,6 +42,6 @@ public class ProductAssetCategoryManager : DomainService
throw new BusinessException(BookingErrorCodes.ConflictingProductAssetCategory); throw new BusinessException(BookingErrorCodes.ConflictingProductAssetCategory);
} }
entity.Update(fromTime, toTime, price); entity.Update(fromTime, toTime, currency, price);
} }
} }

28
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAsset.cs

@ -4,6 +4,8 @@ using System.Linq;
using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories; using EasyAbp.EShop.Plugins.Booking.ProductAssetCategories;
using EasyAbp.EShop.Plugins.Booking.Shared; using EasyAbp.EShop.Plugins.Booking.Shared;
using EasyAbp.EShop.Stores.Stores; using EasyAbp.EShop.Stores.Stores;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
@ -40,6 +42,12 @@ public class ProductAsset : AuditedAggregateRoot<Guid>, IMultiStore, IMultiTenan
/// </summary> /// </summary>
public virtual DateTime? ToTime { get; protected set; } public virtual DateTime? ToTime { get; protected set; }
/// <summary>
/// Should set if the <see cref="Price"/> is not <c>null</c>.
/// </summary>
[CanBeNull]
public virtual string Currency { get; protected set; }
/// <summary> /// <summary>
/// Price for any period. /// Price for any period.
/// Fall back to the price of ProductSku if <c>null</c>. /// Fall back to the price of ProductSku if <c>null</c>.
@ -65,6 +73,7 @@ public class ProductAsset : AuditedAggregateRoot<Guid>, IMultiStore, IMultiTenan
Guid periodSchemeId, Guid periodSchemeId,
DateTime fromTime, DateTime fromTime,
DateTime? toTime, DateTime? toTime,
[CanBeNull] string currency,
decimal? price, decimal? price,
List<ProductAssetPeriod> periods List<ProductAssetPeriod> periods
) : base(id) ) : base(id)
@ -77,15 +86,26 @@ public class ProductAsset : AuditedAggregateRoot<Guid>, IMultiStore, IMultiTenan
PeriodSchemeId = periodSchemeId; PeriodSchemeId = periodSchemeId;
FromTime = fromTime; FromTime = fromTime;
ToTime = toTime; ToTime = toTime;
Price = price; SetPrice(currency, price);
Periods = periods ?? new List<ProductAssetPeriod>(); Periods = periods ?? new List<ProductAssetPeriod>();
} }
internal void Update(DateTime fromTime, DateTime? toTime, decimal? price) internal void Update(DateTime fromTime, DateTime? toTime, [CanBeNull] string currency, decimal? price)
{ {
FromTime = fromTime; FromTime = fromTime;
ToTime = toTime; ToTime = toTime;
SetPrice(currency, price);
}
protected void SetPrice([CanBeNull] string currency, decimal? price)
{
if (price is not null)
{
Check.NotNull(currency, nameof(currency));
}
Currency = currency;
Price = price; Price = price;
} }
@ -113,4 +133,4 @@ public class ProductAsset : AuditedAggregateRoot<Guid>, IMultiStore, IMultiTenan
{ {
return Periods.FirstOrDefault(x => x.PeriodId == periodId); return Periods.FirstOrDefault(x => x.PeriodId == periodId);
} }
} }

12
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetManager.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Domain.Services; using Volo.Abp.Domain.Services;
@ -16,10 +17,10 @@ public class ProductAssetManager : DomainService
} }
public virtual async Task<ProductAsset> CreateAsync(Guid storeId, Guid productId, Guid productSkuId, Guid assetId, public virtual async Task<ProductAsset> CreateAsync(Guid storeId, Guid productId, Guid productSkuId, Guid assetId,
Guid periodSchemeId, DateTime fromTime, DateTime? toTime, decimal? price) Guid periodSchemeId, DateTime fromTime, DateTime? toTime, [CanBeNull] string currency, decimal? price)
{ {
var id = GuidGenerator.Create(); var id = GuidGenerator.Create();
if (await _repository.ExistConflictAsync( if (await _repository.ExistConflictAsync(
id, storeId, productId, productSkuId, assetId, periodSchemeId, fromTime)) id, storeId, productId, productSkuId, assetId, periodSchemeId, fromTime))
{ {
@ -27,10 +28,11 @@ public class ProductAssetManager : DomainService
} }
return new ProductAsset(GuidGenerator.Create(), CurrentTenant.Id, storeId, productId, productSkuId, assetId, return new ProductAsset(GuidGenerator.Create(), CurrentTenant.Id, storeId, productId, productSkuId, assetId,
periodSchemeId, fromTime, toTime, price, new List<ProductAssetPeriod>()); periodSchemeId, fromTime, toTime, currency, price, new List<ProductAssetPeriod>());
} }
public virtual async Task UpdateAsync(ProductAsset entity, DateTime fromTime, DateTime? toTime, decimal? price) public virtual async Task UpdateAsync(ProductAsset entity, DateTime fromTime, DateTime? toTime,
[NotNull] string currency, decimal? price)
{ {
if (await _repository.ExistConflictAsync(entity.Id, entity.StoreId, entity.ProductId, entity.ProductSkuId, if (await _repository.ExistConflictAsync(entity.Id, entity.StoreId, entity.ProductId, entity.ProductSkuId,
entity.AssetId, entity.PeriodSchemeId, fromTime)) entity.AssetId, entity.PeriodSchemeId, fromTime))
@ -38,6 +40,6 @@ public class ProductAssetManager : DomainService
throw new BusinessException(BookingErrorCodes.ConflictingProductAsset); throw new BusinessException(BookingErrorCodes.ConflictingProductAsset);
} }
entity.Update(fromTime, toTime, price); entity.Update(fromTime, toTime, currency, price);
} }
} }

10
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Domain/EasyAbp/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod.cs

@ -1,4 +1,5 @@
using System; using System;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
namespace EasyAbp.EShop.Plugins.Booking.ProductAssets; namespace EasyAbp.EShop.Plugins.Booking.ProductAssets;
@ -6,7 +7,10 @@ namespace EasyAbp.EShop.Plugins.Booking.ProductAssets;
public class ProductAssetPeriod : Entity<Guid> public class ProductAssetPeriod : Entity<Guid>
{ {
public virtual Guid PeriodId { get; protected set; } public virtual Guid PeriodId { get; protected set; }
[NotNull]
public virtual string Currency { get; protected set; }
public virtual decimal Price { get; protected set; } public virtual decimal Price { get; protected set; }
protected ProductAssetPeriod() protected ProductAssetPeriod()
@ -16,10 +20,12 @@ public class ProductAssetPeriod : Entity<Guid>
public ProductAssetPeriod( public ProductAssetPeriod(
Guid id, Guid id,
Guid periodId, Guid periodId,
[NotNull] string currency,
decimal price decimal price
) : base(id) ) : base(id)
{ {
PeriodId = periodId; PeriodId = periodId;
Currency = currency;
Price = price; Price = price;
} }
} }

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory/ViewModels/CreateProductAssetCategoryViewModel.cs

@ -28,6 +28,9 @@ namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductA
[Display(Name = "ProductAssetCategoryToTime")] [Display(Name = "ProductAssetCategoryToTime")]
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
[Display(Name = "ProductAssetCategoryCurrency")]
public string Currency { get; set; }
[Display(Name = "ProductAssetCategoryPrice")] [Display(Name = "ProductAssetCategoryPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }

6
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory/ViewModels/EditProductAssetCategoryViewModel.cs

@ -1,7 +1,8 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategory.ViewModels namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategory.
ViewModels
{ {
public class EditProductAssetCategoryViewModel public class EditProductAssetCategoryViewModel
{ {
@ -11,6 +12,9 @@ namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductA
[Display(Name = "ProductAssetCategoryToTime")] [Display(Name = "ProductAssetCategoryToTime")]
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
[Display(Name = "ProductAssetCategoryCurrency")]
public string Currency { get; set; }
[Display(Name = "ProductAssetCategoryPrice")] [Display(Name = "ProductAssetCategoryPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategory/index.js

@ -56,6 +56,10 @@ $(function () {
title: l('ProductAssetCategoryAssetCategoryId'), title: l('ProductAssetCategoryAssetCategoryId'),
data: "assetCategoryId" data: "assetCategoryId"
}, },
{
title: l('ProductAssetCategoryCurrency'),
data: "currency"
},
{ {
title: l('ProductAssetCategoryPrice'), title: l('ProductAssetCategoryPrice'),
data: "price" data: "price"

7
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod/ViewModels/CreateProductAssetCategoryPeriodViewModel.cs

@ -1,13 +1,18 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategoryPeriod.ViewModels namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.
ProductAssetCategoryPeriod.ViewModels
{ {
public class CreateProductAssetCategoryPeriodViewModel public class CreateProductAssetCategoryPeriodViewModel
{ {
[Display(Name = "ProductAssetCategoryPeriodPeriodId")] [Display(Name = "ProductAssetCategoryPeriodPeriodId")]
public Guid PeriodId { get; set; } public Guid PeriodId { get; set; }
[Display(Name = "ProductAssetCategoryPeriodCurrency")]
[Required]
public string Currency { get; set; }
[Display(Name = "ProductAssetCategoryPeriodPrice")] [Display(Name = "ProductAssetCategoryPeriodPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }

8
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod/ViewModels/EditProductAssetCategoryPeriodViewModel.cs

@ -1,10 +1,14 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.ProductAssetCategoryPeriod.ViewModels namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssetCategories.
ProductAssetCategoryPeriod.ViewModels
{ {
public class EditProductAssetCategoryPeriodViewModel public class EditProductAssetCategoryPeriodViewModel
{ {
[Display(Name = "ProductAssetCategoryPeriodCurrency")]
[Required]
public string Currency { get; set; }
[Display(Name = "ProductAssetCategoryPeriodPrice")] [Display(Name = "ProductAssetCategoryPeriodPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssetCategories/ProductAssetCategoryPeriod/index.js

@ -58,6 +58,10 @@ $(function () {
title: l('ProductAssetCategoryPeriodPeriodId'), title: l('ProductAssetCategoryPeriodPeriodId'),
data: "periodId" data: "periodId"
}, },
{
title: l('ProductAssetCategoryPeriodCurrency'),
data: "currency"
},
{ {
title: l('ProductAssetCategoryPeriodPrice'), title: l('ProductAssetCategoryPeriodPrice'),
data: "price" data: "price"

3
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAsset/ViewModels/CreateProductAssetViewModel.cs

@ -28,6 +28,9 @@ namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductA
[Display(Name = "ProductAssetToTime")] [Display(Name = "ProductAssetToTime")]
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
[Display(Name = "ProductAssetCurrency")]
public string Currency { get; set; }
[Display(Name = "ProductAssetPrice")] [Display(Name = "ProductAssetPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAsset/ViewModels/EditProductAssetViewModel.cs

@ -1,5 +1,4 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAsset.ViewModels namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAsset.ViewModels
@ -12,6 +11,9 @@ namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductA
[Display(Name = "ProductAssetToTime")] [Display(Name = "ProductAssetToTime")]
public DateTime? ToTime { get; set; } public DateTime? ToTime { get; set; }
[Display(Name = "ProductAssetCurrency")]
public string Currency { get; set; }
[Display(Name = "ProductAssetPrice")] [Display(Name = "ProductAssetPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal? Price { get; set; } public decimal? Price { get; set; }

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAsset/index.js

@ -56,6 +56,10 @@ $(function () {
title: l('ProductAssetAssetId'), title: l('ProductAssetAssetId'),
data: "assetId" data: "assetId"
}, },
{
title: l('ProductAssetCurrency'),
data: "currency"
},
{ {
title: l('ProductAssetPrice'), title: l('ProductAssetPrice'),
data: "price" data: "price"

5
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod/ViewModels/CreateProductAssetPeriodViewModel.cs

@ -1,5 +1,4 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAssetPeriod.ViewModels namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAssetPeriod.ViewModels
@ -9,6 +8,10 @@ namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductA
[Display(Name = "ProductAssetPeriodPeriodId")] [Display(Name = "ProductAssetPeriodPeriodId")]
public Guid PeriodId { get; set; } public Guid PeriodId { get; set; }
[Display(Name = "ProductAssetPeriodCurrency")]
[Required]
public string Currency { get; set; }
[Display(Name = "ProductAssetPeriodPrice")] [Display(Name = "ProductAssetPeriodPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }

6
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod/ViewModels/EditProductAssetPeriodViewModel.cs

@ -1,11 +1,13 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAssetPeriod.ViewModels namespace EasyAbp.EShop.Plugins.Booking.Web.Pages.EShop.Plugins.Booking.ProductAssets.ProductAssetPeriod.ViewModels
{ {
public class EditProductAssetPeriodViewModel public class EditProductAssetPeriodViewModel
{ {
[Display(Name = "ProductAssetPeriodCurrency")]
[Required]
public string Currency { get; set; }
[Display(Name = "ProductAssetPeriodPrice")] [Display(Name = "ProductAssetPeriodPrice")]
[Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)] [Range(BookingConsts.MinimumPrice, BookingConsts.MaximumPrice)]
public decimal Price { get; set; } public decimal Price { get; set; }

4
plugins/Booking/src/EasyAbp.EShop.Plugins.Booking.Web/Pages/EShop/Plugins/Booking/ProductAssets/ProductAssetPeriod/index.js

@ -58,6 +58,10 @@ $(function () {
title: l('ProductAssetPeriodPeriodId'), title: l('ProductAssetPeriodPeriodId'),
data: "periodId" data: "periodId"
}, },
{
title: l('ProductAssetPeriodCurrency'),
data: "currency"
},
{ {
title: l('ProductAssetPeriodPrice'), title: l('ProductAssetPeriodPrice'),
data: "price" data: "price"

4
plugins/Booking/test/EasyAbp.EShop.Plugins.Booking.TestBase/BookingDataSeedContributor.cs

@ -52,11 +52,11 @@ public class BookingDataSeedContributor : IDataSeedContributor, ITransientDepend
await _productAssetRepository.InsertAsync(await _productAssetManager.CreateAsync(BookingTestConsts.Store1Id, await _productAssetRepository.InsertAsync(await _productAssetManager.CreateAsync(BookingTestConsts.Store1Id,
BookingTestConsts.BookingProduct1Id, BookingTestConsts.BookingProduct1Sku1Id, BookingTestConsts.Asset1Id, BookingTestConsts.BookingProduct1Id, BookingTestConsts.BookingProduct1Sku1Id, BookingTestConsts.Asset1Id,
BookingTestConsts.PeriodScheme1Id, DateTime.Parse("1970-1-1"), null, 5m)); BookingTestConsts.PeriodScheme1Id, DateTime.Parse("1970-1-1"), null, "USD", 5m));
await _productAssetCategoryRepository.InsertAsync(await _productAssetCategoryManager.CreateAsync( await _productAssetCategoryRepository.InsertAsync(await _productAssetCategoryManager.CreateAsync(
BookingTestConsts.Store1Id, BookingTestConsts.BookingProduct1Id, BookingTestConsts.BookingProduct1Sku1Id, BookingTestConsts.Store1Id, BookingTestConsts.BookingProduct1Id, BookingTestConsts.BookingProduct1Sku1Id,
BookingTestConsts.AssetCategory1Id, BookingTestConsts.PeriodScheme1Id, DateTime.Parse("1970-1-1"), null, BookingTestConsts.AssetCategory1Id, BookingTestConsts.PeriodScheme1Id, DateTime.Parse("1970-1-1"), null,
10m)); "USD", 10m));
} }
} }

5440
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220701165019_AddedCurrencyProperties.Designer.cs

File diff suppressed because it is too large

55
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/Migrations/20220701165019_AddedCurrencyProperties.cs

@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EShopSample.Migrations
{
public partial class AddedCurrencyProperties : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssets",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssetPeriods",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssetCategoryPeriods",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssetCategories",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssets");
migrationBuilder.DropColumn(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssetPeriods");
migrationBuilder.DropColumn(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssetCategoryPeriods");
migrationBuilder.DropColumn(
name: "Currency",
table: "EasyAbpEShopPluginsBookingProductAssetCategories");
}
}
}

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

@ -19,7 +19,7 @@ namespace EShopSample.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "6.0.5") .HasAnnotation("ProductVersion", "6.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
@ -873,6 +873,9 @@ namespace EShopSample.Migrations
.HasColumnType("uniqueidentifier") .HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId"); .HasColumnName("CreatorId");
b.Property<string>("Currency")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties") b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)") .HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties"); .HasColumnName("ExtraProperties");
@ -921,6 +924,9 @@ namespace EShopSample.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Currency")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("PeriodId") b.Property<Guid>("PeriodId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
@ -960,6 +966,9 @@ namespace EShopSample.Migrations
.HasColumnType("uniqueidentifier") .HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId"); .HasColumnName("CreatorId");
b.Property<string>("Currency")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties") b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)") .HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties"); .HasColumnName("ExtraProperties");
@ -1008,6 +1017,9 @@ namespace EShopSample.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Currency")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("PeriodId") b.Property<Guid>("PeriodId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");

Loading…
Cancel
Save