订单微服务实体实现

This commit is contained in:
administrator committed 2024-08-29 23:07:14 +08:00
1 parent b0b9491dfe
commit 2201f36422
69 files changed
+1042 -67

No files matched your search

@@ -0,0 +1,33 @@
// Copyright (c) HelloShop Corporation. All rights reserved.
// See the license file in the project root for more information.
namespace HelloShop.OrderingService.Entities.Orders
{
public record Address
{
/// <summary>
/// 国家
/// </summary>
public required string Country { get; set; }
/// <summary>
/// 省份
/// </summary>
public required string State { get; set; }
/// <summary>
/// 城市
/// </summary>
public required string City { get; set; }
/// <summary>
/// 街道
/// </summary>
public required string Street { get; set; }
/// <summary>
/// 邮编
/// </summary>
public required string ZipCode { get; set; }
}
}
@@ -0,0 +1,40 @@
// Copyright (c) HelloShop Corporation. All rights reserved.
// See the license file in the project root for more information.
using System.Diagnostics.CodeAnalysis;
namespace HelloShop.OrderingService.Entities.Orders
{
public class Order
{
public int Id { get; set; }
public DateTimeOffset OrderDate { get; private set; } = DateTimeOffset.UtcNow;
public required Address Address { get; init; }
public OrderStatus OrderStatus { get; set; } = OrderStatus.Submitted;
public int BuyerId { get; set; }
public int? PaymentMethodId { get; set; }
public required IReadOnlyCollection<OrderItem> OrderItems { get; init; }
public string? Description { get; set; }
/// <summary>
/// EF Core cannot set navigation properties using a constructor.
/// The constructor can be public, private, or have any other accessibility.
/// </summary>
private Order() { }
[SetsRequiredMembers]
public Order(int buyerId, Address address, IEnumerable<OrderItem> orderItems)
{
Address = address;
BuyerId = buyerId;
OrderItems = orderItems.ToList();
}
}
}
@@ -0,0 +1,22 @@
// Copyright (c) HelloShop Corporation. All rights reserved.
// See the license file in the project root for more information.
namespace HelloShop.OrderingService.Entities.Orders
{
public class OrderItem
{
public int Id { get; set; }
public int OrderId { get; set; }
public int ProductId { get; set; }
public required string ProductName { get; set; }
public required string PictureUrl { get; set; }
public decimal UnitPrice { get; set; }
public int Units { get; set; }
}
}
@@ -0,0 +1,15 @@
// Copyright (c) HelloShop Corporation. All rights reserved.
// See the license file in the project root for more information.
namespace HelloShop.OrderingService.Entities.Orders
{
public enum OrderStatus
{
Submitted = 1,
AwaitingValidation = 2,
StockConfirmed = 3,
Paid = 4,
Shipped = 5,
Cancelled = 6
}
}