using Hotline.Share.Enums.CallCenter;
using Hotline.Share.Enums.Snapshot;
using Hotline.Share.Requests;
using Hotline.Share.Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.Snapshot;

public class PointsDto
{
}

public class UpdateIsSecurityMaxAsync
{
    /// <summary>
    /// 用户Id
    /// </summary>
    [Required]
    public string UserId { get; set; }

    /// <summary>
    /// 是否安全卫士
    /// </summary>
    [Required]
    public bool IsSecurityMax { get; set; }
}

public record PointsItemsInDto : PagedKeywordRequest
{
    /// <summary>
    /// 联系方式
    /// </summary>
    public string? PhoneNumber { get; set; }

    /// <summary>
    /// 区域名称
    /// </summary>
    public string? County { get; set; }

    public DateTime? StartTime { get; set; }

    public DateTime? EndTime { get; set; }
}

public class PointsItemsOutDto
{
    /// <summary>
    /// 联系方式
    /// </summary>
    public string PhoneNumber { get; set; }

    /// <summary>
    /// 姓名
    /// </summary>
    public string UserName { get; set; }

    /// <summary>
    /// 总积分
    /// </summary>
    public int TotalPoints { get; set; }

    /// <summary>
    /// 已兑换积分
    /// </summary>
    public int OutPoints { get; set; }

    /// <summary>
    /// 当前可用积分
    /// </summary>
    public int ValidPoints => TotalPoints - OutPoints;

    /// <summary>
    /// 已使用积分
    /// </summary>
    [JsonIgnore]
    [Newtonsoft.Json.JsonIgnore]
    public int OutTotalPoint { get; set; }

    /// <summary>
    /// 排名
    /// </summary>
    public int Rank { get; set; }

    /// <summary>
    /// 是否安全卫士
    /// </summary>
    public bool IsSecurityMax { get; set; }

    [JsonIgnore]
    [Newtonsoft.Json.JsonIgnore]
    public int InTotalPoint { get; set; }

    /// <summary>
    /// UserId
    /// </summary>
    public string UserId { get; set; }
}


public class PointsRankOutDto
{
    /// <summary>
    /// 当前可用积分
    /// </summary>
    public int ValidPoints { get; set; }

    /// <summary>
    /// 排行
    /// </summary>
    public IList<PointsRankUserDto> Ranks { get; set; }

    /// <summary>
    /// 视频公告
    /// </summary>
    public VideoBulletinOutDto VideoBulletin { get; set; }

    /// <summary>
    /// 通知公告
    /// </summary>
    public PointsBulletinOutDto Bulletins { get; set; }
}

public class PointsBulletinOutDto
{
    /// <summary>
    /// 未读个数
    /// </summary>
    public int UnReadCount { get; set; }

    /// <summary>
    /// Summary
    /// </summary>
    public IList<PointsBulletinItemsOutDto> Items { get; set; }
}

public class PointsBulletinItemsOutDto
{
    /// <summary>
    /// Id
    /// </summary>
    public string BulletinId { get; set; }

    /// <summary>
    /// 通知Id
    /// </summary>
    public string NotificationId { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; }
}

public class VideoBulletinOutDto
{
    /// <summary>
    /// Id
    /// </summary>
    public string BulletinId { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 栏目
    /// </summary>
    public string SnapshotBulletinTypeName { get; set; }

    /// <summary>
    /// 视频封面
    /// </summary>
    public string VideoCoverImgUrl { get; set; }

    /// <summary>
    /// 未读个数
    /// </summary>
    public int UnReadCount { get; set; }

    /// <summary>
    /// 视频地址
    /// </summary>
    public string? VideoPath { get; set; }
}

public class PointsRankUserDto
{
    /// <summary>
    /// 用户名
    /// </summary>
    public string UserName { get; set; }

    private string _phoneNumber;
    /// <summary>
    /// 联系电话
    /// </summary>
    public string PhoneNumber
    {
        get
        {
            return _phoneNumber.MaskPhoneNumber();
        }
        set { _phoneNumber = value; }
    }

    /// <summary>
    /// 排名
    /// </summary>
    public int Rank { get; set; }

    /// <summary>
    /// 积分
    /// </summary>
    public int Points { get; set; }

    /// <summary>
    /// UserId
    /// </summary>
    public string CitizenId { get; set; }

    /// <summary>
    /// 是否安全卫士
    /// </summary>
    public bool IsSecurityMax { get; set; }

    /// <summary>
    /// 头像地址
    /// </summary>
    public string HeadUrl { get; set; }
}

public class PointItemsInDto : QueryFixedDto
{
    /// <summary>
    /// 收入或者支出
    /// </summary>
    public EPointsDirection Direction { get; set; }
}

public class PointItemsOutDto
{
    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 积分来源
    /// </summary>
    public EPointsSource Source { get; set; }

    /// <summary>
    /// 积分来源
    /// </summary>
    public string SourceTxt => Source.GetDescription();

    /// <summary>
    /// 积分
    /// </summary>
    public int Points { get; set; }
}
