using TakeoutSaaS.Domain.Stores.Enums;
using TakeoutSaaS.Shared.Abstractions.Entities;

namespace TakeoutSaaS.Domain.Stores.Entities;

/// <summary>
/// 门店资质证照。
/// </summary>
public sealed class StoreQualification : MultiTenantEntityBase
{
    /// <summary>
    /// 门店标识。
    /// </summary>
    public long StoreId { get; set; }

    /// <summary>
    /// 资质类型。
    /// </summary>
    public StoreQualificationType QualificationType { get; set; }

    /// <summary>
    /// 证照文件 URL。
    /// </summary>
    public string FileUrl { get; set; } = string.Empty;

    /// <summary>
    /// 证照编号。
    /// </summary>
    public string? DocumentNumber { get; set; }

    /// <summary>
    /// 签发日期。
    /// </summary>
    public DateOnly? IssuedAt { get; set; }

    /// <summary>
    /// 到期日期。
    /// </summary>
    public DateOnly? ExpiresAt { get; set; }

    /// <summary>
    /// 是否已过期。
    /// </summary>
    public bool IsExpired => ExpiresAt.HasValue
        && ExpiresAt.Value < DateOnly.FromDateTime(DateTime.UtcNow);

    /// <summary>
    /// 是否即将过期（30天内）。
    /// </summary>
    public bool IsExpiringSoon => ExpiresAt.HasValue
        && ExpiresAt.Value >= DateOnly.FromDateTime(DateTime.UtcNow)
        && ExpiresAt.Value <= DateOnly.FromDateTime(DateTime.UtcNow).AddDays(30);

    /// <summary>
    /// 排序值。
    /// </summary>
    public int SortOrder { get; set; } = 100;
}
