namespace HoneyBox.Admin.Business.Models.User;

#region 用户邀请统计

/// <summary>
/// 用户邀请统计查询请求
/// </summary>
public class InviteStatsQuery : PagedRequest
{
    /// <summary>
    /// 用户ID（支持字符串输入，会自动转换为整数）
    /// </summary>
    public string? UserIdStr { get; set; }

    /// <summary>
    /// 获取解析后的用户ID
    /// </summary>
    public int? UserId => !string.IsNullOrWhiteSpace(UserIdStr) && int.TryParse(UserIdStr.Trim(), out var id) ? id : null;

    /// <summary>
    /// 用户UID
    /// </summary>
    public string? Uid { get; set; }

    /// <summary>
    /// 最小邀请人数
    /// </summary>
    public int? MinInviteCount { get; set; }

    /// <summary>
    /// 开始时间
    /// </summary>
    public DateTime? StartTime { get; set; }

    /// <summary>
    /// 结束时间
    /// </summary>
    public DateTime? EndTime { get; set; }
}

/// <summary>
/// 用户邀请统计项
/// </summary>
public class InviteStatsItem
{
    /// <summary>
    /// 序号
    /// </summary>
    public int Index { get; set; }

    /// <summary>
    /// 用户ID
    /// </summary>
    public int UserId { get; set; }

    /// <summary>
    /// 用户UID
    /// </summary>
    public string? Uid { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    public string? Nickname { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Headimg { get; set; }

    /// <summary>
    /// 邀请人数
    /// </summary>
    public int InviteNumber { get; set; }

    /// <summary>
    /// 下级消费订单数
    /// </summary>
    public int SumOrder { get; set; }

    /// <summary>
    /// 下级消费总金额
    /// </summary>
    public decimal SumPrice { get; set; }

    /// <summary>
    /// 绑定手机号人数
    /// </summary>
    public int CountMobile { get; set; }

    /// <summary>
    /// 被邀请用户详情列表
    /// </summary>
    public List<InviteUserInfo>? Info { get; set; }
}

/// <summary>
/// 被邀请用户信息
/// </summary>
public class InviteUserInfo
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public int UserId { get; set; }

    /// <summary>
    /// 用户UID
    /// </summary>
    public string? Uid { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    public string? Nickname { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Headimg { get; set; }

    /// <summary>
    /// 手机号
    /// </summary>
    public string? Mobile { get; set; }

    /// <summary>
    /// 消费订单数
    /// </summary>
    public int OrderCount { get; set; }

    /// <summary>
    /// 消费总金额
    /// </summary>
    public decimal TotalPrice { get; set; }

    /// <summary>
    /// 注册时间
    /// </summary>
    public DateTime CreatedAt { get; set; }
}

#endregion

#region 用户登录统计

/// <summary>
/// 用户登录统计查询请求
/// </summary>
public class LoginStatsQuery
{
    /// <summary>
    /// 统计类型：day-按日, week-按周, month-按月
    /// </summary>
    public string Type { get; set; } = "day";

    /// <summary>
    /// 年份
    /// </summary>
    public int? Year { get; set; }

    /// <summary>
    /// 开始日期
    /// </summary>
    public DateTime? StartDate { get; set; }

    /// <summary>
    /// 结束日期
    /// </summary>
    public DateTime? EndDate { get; set; }
}

/// <summary>
/// 用户登录统计响应
/// </summary>
public class LoginStatsResponse
{
    /// <summary>
    /// 标签列表（日期/周/月）
    /// </summary>
    public List<string> Labels { get; set; } = new();

    /// <summary>
    /// 登录次数列表
    /// </summary>
    public List<int> Values { get; set; } = new();

    /// <summary>
    /// 总登录次数
    /// </summary>
    public int TotalLogins { get; set; }

    /// <summary>
    /// 活跃用户数
    /// </summary>
    public int? ActiveUsers { get; set; }
}

#endregion

#region 用户盈亏列表

/// <summary>
/// 用户盈亏列表查询请求
/// </summary>
public class ProfitLossListQuery : PagedRequest
{
    /// <summary>
    /// 用户UID
    /// </summary>
    public string? Uid { get; set; }

    /// <summary>
    /// 用户ID（支持字符串输入，会自动转换为整数）
    /// </summary>
    public string? UserIdStr { get; set; }

    /// <summary>
    /// 获取解析后的用户ID
    /// </summary>
    public int? UserId => !string.IsNullOrWhiteSpace(UserIdStr) && int.TryParse(UserIdStr.Trim(), out var id) ? id : null;

    /// <summary>
    /// 开始时间
    /// </summary>
    public DateTime? StartTime { get; set; }

    /// <summary>
    /// 结束时间
    /// </summary>
    public DateTime? EndTime { get; set; }
}

/// <summary>
/// 用户盈亏项
/// </summary>
public class ProfitLossItem
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public int UserId { get; set; }

    /// <summary>
    /// 用户UID
    /// </summary>
    public string? Uid { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    public string? Nickname { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Headimg { get; set; }

    /// <summary>
    /// 手机号
    /// </summary>
    public string? Mobile { get; set; }

    /// <summary>
    /// 余额
    /// </summary>
    public decimal Money { get; set; }

    /// <summary>
    /// 积分
    /// </summary>
    public decimal Integral { get; set; }

    /// <summary>
    /// 钻石
    /// </summary>
    public decimal Money2 { get; set; }

    /// <summary>
    /// 订单数量
    /// </summary>
    public int OrderCount { get; set; }

    /// <summary>
    /// 订单折后总金额
    /// </summary>
    public decimal OrderZheTotal { get; set; }

    /// <summary>
    /// RMB支付金额
    /// </summary>
    public decimal Money1 { get; set; }

    /// <summary>
    /// 钻石支付金额
    /// </summary>
    public decimal Money2Pay { get; set; }

    /// <summary>
    /// 用户支付金额
    /// </summary>
    public decimal UseMoney { get; set; }

    /// <summary>
    /// 发货金额
    /// </summary>
    public decimal FhMoney { get; set; }

    /// <summary>
    /// 背包金额
    /// </summary>
    public decimal BbMoney { get; set; }

    /// <summary>
    /// 剩余达达券
    /// </summary>
    public decimal SyMoney { get; set; }

    /// <summary>
    /// 盈亏金额
    /// </summary>
    public decimal YueMoney { get; set; }

    /// <summary>
    /// 盈亏状态：盈利/亏损
    /// </summary>
    public string ProfitStatus { get; set; } = string.Empty;
}

#endregion

#region 用户操作请求

/// <summary>
/// 绑定手机号请求
/// </summary>
public class BindMobileRequest
{
    /// <summary>
    /// 手机号
    /// </summary>
    public string Mobile { get; set; } = null!;
}

#endregion
