mirror of https://github.com/EasyAbp/EShop.git
committed by
GitHub
56 changed files with 6802 additions and 335 deletions
@ -1,50 +1,61 @@ |
|||
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 |
|||
{ |
|||
[NotNull] |
|||
string OrderNumber { get; } |
|||
|
|||
|
|||
Guid CustomerUserId { get; } |
|||
|
|||
|
|||
OrderStatus OrderStatus { get; } |
|||
|
|||
[NotNull] |
|||
string Currency { get; } |
|||
|
|||
|
|||
decimal ProductTotalPrice { get; } |
|||
|
|||
|
|||
decimal TotalDiscount { get; } |
|||
|
|||
|
|||
decimal TotalPrice { get; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// ActualTotalPrice = TotalPrice - TotalDiscount
|
|||
/// </summary>
|
|||
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<IOrderLine> OrderLines { get; } |
|||
|
|||
IEnumerable<IOrderExtraFee> OrderExtraFees { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace EasyAbp.EShop.Orders.Orders |
|||
{ |
|||
public interface IOrderExtraFee |
|||
{ |
|||
Guid OrderId { get; } |
|||
|
|||
[NotNull] |
|||
string Name { get; } |
|||
|
|||
[CanBeNull] |
|||
string Key { get; } |
|||
|
|||
decimal Fee { get; } |
|||
|
|||
decimal RefundAmount { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
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 decimal Fee { get; set; } |
|||
|
|||
public decimal RefundAmount { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace EasyAbp.EShop.Products.Products; |
|||
|
|||
public interface IHasAttributeOptionIds |
|||
{ |
|||
List<Guid> AttributeOptionIds { get; } |
|||
} |
|||
@ -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<IProductAttribute> 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<IProductSku> ProductSkus { get; } |
|||
} |
|||
} |
|||
@ -1,13 +1,19 @@ |
|||
using Volo.Abp.Data; |
|||
using System.Collections.Generic; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace EasyAbp.EShop.Products.Products |
|||
{ |
|||
public interface IProductAttribute : IHasExtraProperties |
|||
{ |
|||
[NotNull] |
|||
string DisplayName { get; } |
|||
|
|||
|
|||
[CanBeNull] |
|||
string Description { get; } |
|||
|
|||
|
|||
int DisplayOrder { get; } |
|||
|
|||
IEnumerable<IProductAttributeOption> ProductAttributeOptions { get; } |
|||
} |
|||
} |
|||
@ -1,13 +1,16 @@ |
|||
using Volo.Abp.Data; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace EasyAbp.EShop.Products.Products |
|||
{ |
|||
public interface IProductAttributeOption : IHasExtraProperties |
|||
{ |
|||
[NotNull] |
|||
string DisplayName { get; } |
|||
|
|||
|
|||
[CanBeNull] |
|||
string Description { get; } |
|||
|
|||
|
|||
int DisplayOrder { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using EasyAbp.EShop.Stores.Stores; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace EasyAbp.EShop.Products.Products |
|||
{ |
|||
public interface IProductBase : IHasExtraProperties, IMultiStore |
|||
{ |
|||
string ProductGroupName { 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; } |
|||
} |
|||
} |
|||
@ -1,26 +1,28 @@ |
|||
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; } |
|||
|
|||
[CanBeNull] |
|||
string Name { get; } |
|||
|
|||
|
|||
[NotNull] |
|||
string Currency { get; } |
|||
|
|||
|
|||
decimal? OriginalPrice { get; } |
|||
|
|||
|
|||
decimal Price { get; } |
|||
|
|||
int OrderMinQuantity { get; } |
|||
|
|||
|
|||
int OrderMaxQuantity { get; } |
|||
|
|||
|
|||
[CanBeNull] |
|||
string MediaResources { get; } |
|||
|
|||
|
|||
Guid? ProductDetailId { get; } |
|||
} |
|||
} |
|||
@ -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<string> FormatAsync(string serializedAttributeOptionIds) |
|||
{ |
|||
return await SerializeAsync(await DeserializeAsync(serializedAttributeOptionIds)); |
|||
} |
|||
|
|||
public Task<string> SerializeAsync(IEnumerable<Guid> attributeOptionIds) |
|||
{ |
|||
if (attributeOptionIds == null) |
|||
{ |
|||
return Task.FromResult(string.Empty); |
|||
} |
|||
|
|||
return Task.FromResult(_jsonSerializer.Serialize(attributeOptionIds.OrderBy(x => x))); |
|||
} |
|||
|
|||
public Task<IEnumerable<Guid>> DeserializeAsync(string serializedAttributeOptionIds) |
|||
{ |
|||
return Task.FromResult(_jsonSerializer.Deserialize<IEnumerable<Guid>>(serializedAttributeOptionIds)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace EasyAbp.EShop.Products.Products |
|||
{ |
|||
public interface IAttributeOptionIdsSerializer |
|||
{ |
|||
Task<string> FormatAsync(string serializedAttributeOptionIds); |
|||
|
|||
Task<string> SerializeAsync(IEnumerable<Guid> attributeOptionIds); |
|||
|
|||
Task<IEnumerable<Guid>> DeserializeAsync(string serializedAttributeOptionIds); |
|||
} |
|||
} |
|||
@ -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<List<Guid>> |
|||
{ |
|||
public AttributeOptionIdsValueComparer() |
|||
: base( |
|||
(d1, d2) => d1.SequenceEqual(d2), |
|||
d => d.Aggregate(0, (k, v) => HashCode.Combine(k, v.GetHashCode())), |
|||
d => new List<Guid>(d)) |
|||
{ |
|||
} |
|||
} |
|||
@ -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<List<Guid>, string> |
|||
{ |
|||
public AttributeOptionIdsValueConverter() : base( |
|||
v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null), |
|||
v => JsonSerializer.Deserialize<List<Guid>>(v, (JsonSerializerOptions)null)) |
|||
{ |
|||
} |
|||
} |
|||
@ -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<IHasAttributeOptionIds>()) |
|||
{ |
|||
b.Property(nameof(IHasAttributeOptionIds.AttributeOptionIds)) |
|||
.HasConversion<AttributeOptionIdsValueConverter>() |
|||
.Metadata.SetValueComparer(new AttributeOptionIdsValueComparer()); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,28 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace EShopSample.Migrations |
|||
{ |
|||
/// <inheritdoc />
|
|||
public partial class RenamedToAttributeOptionIds : Migration |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.RenameColumn( |
|||
name: "SerializedAttributeOptionIds", |
|||
table: "EasyAbpEShopProductsProductSkus", |
|||
newName: "AttributeOptionIds"); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.RenameColumn( |
|||
name: "AttributeOptionIds", |
|||
table: "EasyAbpEShopProductsProductSkus", |
|||
newName: "SerializedAttributeOptionIds"); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue