using TakeoutSaaS.Domain.Membership.Entities;

namespace TakeoutSaaS.Domain.Membership.Repositories;

/// <summary>
/// 会员聚合仓储契约。
/// </summary>
public interface IMemberRepository
{
    /// <summary>
    /// 查询租户下会员档案。
    /// </summary>
    Task<IReadOnlyList<MemberProfile>> GetProfilesAsync(long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 按手机号集合查询会员档案。
    /// </summary>
    Task<IReadOnlyList<MemberProfile>> GetProfilesByMobilesAsync(
        long tenantId,
        IReadOnlyCollection<string> mobiles,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 按标识查询会员档案。
    /// </summary>
    Task<MemberProfile?> FindProfileByIdAsync(long tenantId, long memberId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增会员档案集合。
    /// </summary>
    Task AddProfilesAsync(IEnumerable<MemberProfile> profiles, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新会员档案。
    /// </summary>
    Task UpdateProfileAsync(MemberProfile profile, CancellationToken cancellationToken = default);

    /// <summary>
    /// 查询租户下会员等级。
    /// </summary>
    Task<IReadOnlyList<MemberTier>> GetTiersAsync(long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 按标识查询会员等级。
    /// </summary>
    Task<MemberTier?> FindTierByIdAsync(long tenantId, long tierId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增会员等级。
    /// </summary>
    Task AddTierAsync(MemberTier tier, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新会员等级。
    /// </summary>
    Task UpdateTierAsync(MemberTier tier, CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除会员等级。
    /// </summary>
    Task DeleteTierAsync(MemberTier tier, CancellationToken cancellationToken = default);

    /// <summary>
    /// 查询租户会员日配置。
    /// </summary>
    Task<MemberDaySetting?> GetMemberDaySettingAsync(long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增会员日配置。
    /// </summary>
    Task AddMemberDaySettingAsync(MemberDaySetting setting, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新会员日配置。
    /// </summary>
    Task UpdateMemberDaySettingAsync(MemberDaySetting setting, CancellationToken cancellationToken = default);

    /// <summary>
    /// 查询会员标签集合。
    /// </summary>
    Task<IReadOnlyList<MemberProfileTag>> GetProfileTagsAsync(
        long tenantId,
        long memberProfileId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 按会员集合批量查询标签。
    /// </summary>
    Task<IReadOnlyList<MemberProfileTag>> GetProfileTagsByMemberIdsAsync(
        long tenantId,
        IReadOnlyCollection<long> memberProfileIds,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 替换会员标签集合。
    /// </summary>
    Task ReplaceProfileTagsAsync(
        long tenantId,
        long memberProfileId,
        IReadOnlyCollection<string> tags,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 持久化变更。
    /// </summary>
    Task SaveChangesAsync(CancellationToken cancellationToken = default);
}
