// EN: Query to get shops.
// VI: Query để lấy danh sách shops.

using MediatR;

namespace MerchantService.API.Application.Queries.Shops;

/// <summary>
/// EN: Query to get current merchant's shops.
/// VI: Query để lấy danh sách shops của merchant hiện tại.
/// </summary>
public record GetMyShopsQuery : IRequest<IReadOnlyList<ShopDto>>;

/// <summary>
/// EN: Query to get a shop by ID.
/// VI: Query để lấy shop theo ID.
/// </summary>
public record GetShopByIdQuery(Guid ShopId) : IRequest<ShopDetailDto?>;

/// <summary>
/// EN: Query to get a shop by slug.
/// VI: Query để lấy shop theo slug.
/// </summary>
public record GetShopBySlugQuery(string Slug) : IRequest<ShopDetailDto?>;

/// <summary>
/// EN: Shop list DTO.
/// VI: DTO danh sách shop.
/// </summary>
public record ShopDto
{
    public Guid Id { get; init; }
    public string Name { get; init; } = null!;
    public string Slug { get; init; } = null!;
    public string Type { get; init; } = null!;
    public string Category { get; init; } = null!;
    public string Status { get; init; } = null!;
    public string? LogoUrl { get; init; }
    public int BranchCount { get; init; }
    public DateTime CreatedAt { get; init; }
}

/// <summary>
/// EN: Shop detail DTO.
/// VI: DTO chi tiết shop.
/// </summary>
public record ShopDetailDto
{
    public Guid Id { get; init; }
    public Guid MerchantId { get; init; }
    public string Name { get; init; } = null!;
    public string Slug { get; init; } = null!;
    public string Type { get; init; } = null!;
    public string Category { get; init; } = null!;
    public string Status { get; init; } = null!;
    public string? Description { get; init; }
    public string? LogoUrl { get; init; }
    public string? CoverImageUrl { get; init; }
    public ContactInfoDto? ContactInfo { get; init; }
    public OperatingHoursDto? OperatingHours { get; init; }
    public IReadOnlyList<ShopBranchDto> Branches { get; init; } = [];
    public DateTime CreatedAt { get; init; }
    public DateTime? UpdatedAt { get; init; }
}

public record ContactInfoDto
{
    public string? Phone { get; init; }
    public string? Email { get; init; }
    public string? Website { get; init; }
}

public record OperatingHoursDto
{
    public string OpenTime { get; init; } = null!;
    public string CloseTime { get; init; } = null!;
    public List<string> OpenDays { get; init; } = [];
}

public record ShopBranchDto
{
    public Guid Id { get; init; }
    public string Name { get; init; } = null!;
    public string? Code { get; init; }
    public AddressDto Address { get; init; } = null!;
    public GeoLocationDto? Location { get; init; }
    public string? Phone { get; init; }
    public bool IsActive { get; init; }
}

public record AddressDto
{
    public string Street { get; init; } = null!;
    public string? Ward { get; init; }
    public string District { get; init; } = null!;
    public string City { get; init; } = null!;
    public string? Province { get; init; }
    public string FullAddress { get; init; } = null!;
}

public record GeoLocationDto
{
    public double Latitude { get; init; }
    public double Longitude { get; init; }
}
