using TakeoutSaaS.Application.App.Stores.Dto;
using TakeoutSaaS.Domain.Merchants.Entities;
using TakeoutSaaS.Domain.Stores.Entities;

namespace TakeoutSaaS.Application.App.Stores;

/// <summary>
/// 门店相关映射助手。
/// </summary>
public static class StoreMapping
{
    /// <summary>
    /// 映射营业时段 DTO。
    /// </summary>
    /// <param name="hour">营业时段实体。</param>
    /// <returns>DTO。</returns>
    public static StoreBusinessHourDto ToDto(StoreBusinessHour hour) => new()
    {
        Id = hour.Id,
        TenantId = hour.TenantId,
        StoreId = hour.StoreId,
        DayOfWeek = hour.DayOfWeek,
        HourType = hour.HourType,
        StartTime = hour.StartTime,
        EndTime = hour.EndTime,
        CapacityLimit = hour.CapacityLimit,
        Notes = hour.Notes,
        CreatedAt = hour.CreatedAt
    };

    /// <summary>
    /// 映射配送区域 DTO。
    /// </summary>
    /// <param name="zone">配送区域实体。</param>
    /// <returns>DTO。</returns>
    public static StoreDeliveryZoneDto ToDto(StoreDeliveryZone zone) => new()
    {
        Id = zone.Id,
        TenantId = zone.TenantId,
        StoreId = zone.StoreId,
        ZoneName = zone.ZoneName,
        PolygonGeoJson = zone.PolygonGeoJson,
        MinimumOrderAmount = zone.MinimumOrderAmount,
        DeliveryFee = zone.DeliveryFee,
        EstimatedMinutes = zone.EstimatedMinutes,
        SortOrder = zone.SortOrder,
        CreatedAt = zone.CreatedAt
    };

    /// <summary>
    /// 映射节假日 DTO。
    /// </summary>
    /// <param name="holiday">节假日实体。</param>
    /// <returns>DTO。</returns>
    public static StoreHolidayDto ToDto(StoreHoliday holiday) => new()
    {
        Id = holiday.Id,
        TenantId = holiday.TenantId,
        StoreId = holiday.StoreId,
        Date = holiday.Date,
        IsClosed = holiday.IsClosed,
        Reason = holiday.Reason,
        CreatedAt = holiday.CreatedAt
    };

    /// <summary>
    /// 映射桌台区域 DTO。
    /// </summary>
    /// <param name="area">区域实体。</param>
    /// <returns>DTO。</returns>
    public static StoreTableAreaDto ToDto(StoreTableArea area) => new()
    {
        Id = area.Id,
        TenantId = area.TenantId,
        StoreId = area.StoreId,
        Name = area.Name,
        Description = area.Description,
        SortOrder = area.SortOrder,
        CreatedAt = area.CreatedAt
    };

    /// <summary>
    /// 映射桌台 DTO。
    /// </summary>
    /// <param name="table">桌台实体。</param>
    /// <returns>DTO。</returns>
    public static StoreTableDto ToDto(StoreTable table) => new()
    {
        Id = table.Id,
        TenantId = table.TenantId,
        StoreId = table.StoreId,
        AreaId = table.AreaId,
        TableCode = table.TableCode,
        Capacity = table.Capacity,
        Tags = table.Tags,
        Status = table.Status,
        QrCodeUrl = table.QrCodeUrl,
        CreatedAt = table.CreatedAt
    };

    /// <summary>
    /// 映射排班 DTO。
    /// </summary>
    /// <param name="shift">排班实体。</param>
    /// <returns>DTO。</returns>
    public static StoreEmployeeShiftDto ToDto(StoreEmployeeShift shift) => new()
    {
        Id = shift.Id,
        TenantId = shift.TenantId,
        StoreId = shift.StoreId,
        StaffId = shift.StaffId,
        ShiftDate = shift.ShiftDate,
        StartTime = shift.StartTime,
        EndTime = shift.EndTime,
        RoleType = shift.RoleType,
        Notes = shift.Notes,
        CreatedAt = shift.CreatedAt
    };

    /// <summary>
    /// 映射门店员工 DTO。
    /// </summary>
    /// <param name="staff">员工实体。</param>
    /// <returns>DTO。</returns>
    public static StoreStaffDto ToDto(MerchantStaff staff) => new()
    {
        Id = staff.Id,
        TenantId = staff.TenantId,
        MerchantId = staff.MerchantId,
        StoreId = staff.StoreId,
        Name = staff.Name,
        Phone = staff.Phone,
        Email = staff.Email,
        RoleType = staff.RoleType,
        Status = staff.Status
    };
}
