using System.ComponentModel.DataAnnotations;
using TakeoutSaaS.Domain.Inventory.Enums;
using TakeoutSaaS.Shared.Abstractions.Entities;

namespace TakeoutSaaS.Domain.Inventory.Entities;

/// <summary>
/// 库存锁定记录。
/// </summary>
public sealed class InventoryLockRecord : MultiTenantEntityBase
{
    /// <summary>
    /// 门店 ID。
    /// </summary>
    public long StoreId { get; set; }

    /// <summary>
    /// SKU ID。
    /// </summary>
    public long ProductSkuId { get; set; }

    /// <summary>
    /// 锁定数量。
    /// </summary>
    public int Quantity { get; set; }

    /// <summary>
    /// 是否预售锁定。
    /// </summary>
    public bool IsPresale { get; set; }

    /// <summary>
    /// 幂等键。
    /// </summary>
    public string IdempotencyKey { get; set; } = string.Empty;

    /// <summary>
    /// 过期时间（UTC）。
    /// </summary>
    public DateTime? ExpiresAt { get; set; }

    /// <summary>
    /// 锁定状态。
    /// </summary>
    public InventoryLockStatus Status { get; set; } = InventoryLockStatus.Locked;

    /// <summary>
    /// 并发控制字段。
    /// </summary>
    [Timestamp]
    public byte[] RowVersion { get; set; } = Array.Empty<byte>();
}
