using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Org.BouncyCastle.Asn1.X509;

namespace JiaZhiQuan.Common
{

    public class UserInfoBase
    {
        public string id { get; set; }
        public string alias { get; set; }
        public int authType { get; set; }
        public string authName { get; set; }
        public string domainTalent { get; set; }
        public int vip { get; set; }
        public string headImage { get; set; }
        public string description { get; set; }

        public string publicTags { get; set; }
        public string official { get; set; }
        public string curProvince { get; set; }
        /// <summary>
        /// 用户下载自己内容时，是否加水印，默认为0，即不加
        /// </summary>
        public int watermark { get; set; }
    }


    public class UserInfoBaseWithFocusState : UserInfoBase
    {
        /// <summary>
        /// 当前用户是否关注此用户
        /// </summary>
        public int focused { get; set; }
        /// <summary>
        /// 此用户是当前用户的粉丝
        /// </summary>
        public int isFan { get; set; }

        /// <summary>
        /// 用户成长等级
        /// </summary>
        public int level { get; set; }
    }


    public class UserInfoBaseWithPost : UserInfoBaseWithFocusState
    {
        public bool status { get; set; }
        /// <summary>
        /// 最新的三条笔记数据 
        /// </summary>
        public List<PostThumbnails> posts { get; set; }
    }

    /// <summary>
    /// 笔记数据
    /// </summary>
    public class PostThumbnails
    {
        public long id { get; set; }

        public long userId { get; set; }

        public string title { get; set; }
        public string thumbnails { get; set; }
        public int categoryType { get; set; }
        public int type { get; set; }
    }

    /// <summary>
    /// 用户后台查询
    /// </summary>
    public class UserInfoFull : UserInfoBase
    {
        public int mpRole { get; set; }
        public int superior { get; set; }
        public string username { get; set; }
    }


    public class PostContentVideoObject
    {
        public int width { get; set; }
        public int height { get; set; }
        public string thumbnail { get; set; }
        public float duration { get; set; }
        public string url { get; set; }
        public string videoId { get; set; }
    }

    public class PostContentDetailObject
    {
        /// <summary>
        /// 0 为文本 1为图片 2为HTML
        /// </summary>
        public int type { get; set; }
        public string content { get; set; }
        public int width { get; set; }
        public int height { get; set; }
    }

    public class PostContentObject
    {
        public PostContentVideoObject video { get; set; }
        public List<PostContentDetailObject> detail { get; set; }
    }


    public class AppVersion
    {
        /// <summary>
        /// 最小版本号
        /// </summary>
        public string minVersion { get; set; }
        /// <summary>
        /// 最新版本号 
        /// </summary>
        public string latestVersion { get; set; }
        /// <summary>
        /// 最新的版本号名称
        /// </summary>
        public string latestVersionName { get; set; }
        /// <summary>
        /// 版本更新描述
        /// </summary>
        public string description { get; set; }
        /// <summary>
        /// 下载链接，仅Android有效
        /// </summary>
        public string download { get; set; }
    }


    public class AppPushTaskModel
    {
        public int id { get; set; }
        public string title { get; set; }
        public string alert { get; set; }
        public int platform { get; set; }
        public string audience { get; set; }
        public string extras { get; set; }
        public DateTime expiredAt { get; set; }
        public int badge { get; set; }
        public int pushStyle { get; set; }
        public string pushImg { get; set; }
    }

    public class UserMessagePushConfig
    {
        /// <summary>
        /// 不接受所有通知
        /// </summary>
        public bool all { get; set; }

        /// <summary>
        /// 不接受赞消息通知
        /// </summary>
        public bool thumbsup { get; set; }

        /// <summary>
        /// 不接受新粉丝消息通知
        /// </summary>
        public bool newfan { get; set; }

        /// <summary>
        /// 不接受评论消息通知
        /// </summary>
        public bool comment { get; set; }

        /// <summary>
        /// 不接受@消息通知
        /// </summary>
        public bool at { get; set; }

        /// <summary>
        /// 不接受关注人发布新内容消息通知
        /// </summary>
        public bool focusPost { get; set; }

        /// <summary>
        /// 不接受系统通知
        /// </summary>
        public bool sys { get; set; }

        /// <summary>
        /// 不接受推荐通知
        /// </summary>
        public bool recommend { get; set; }

        /// <summary>
        /// 不接受关注圈子的新动态通知
        /// </summary>
        public bool followTopic { get; set; }

    }


    public class PostCommentSetting
    {
        /// <summary>
        /// 禁止所有不能评论
        /// </summary>
        public int all { get; set; }
        /// <summary>
        /// 仅粉丝可以评论
        /// </summary>
        public int notFans { get; set; }
        /// <summary>
        /// 仅自己关注的可评论
        /// </summary>
        public int notFocused { get; set; }
        /// <summary>
        /// 禁止非自己
        /// </summary>
        public int notSelf { get; set; }

    }

    public class PostCommentState : PostCommentSetting
    {
        /// <summary>
        /// 自己能否评论
        /// </summary>
        public int canComment { get; set; }
    }

    /// <summary>
    /// 用户隐私设置
    /// </summary>
    public class UserPrivacySetting
    {
        /// <summary>
        /// 点赞记录是否隐藏
        /// </summary>
        public bool likePostRecordsHidden { get; set; }
        /// <summary>
        /// 收藏记录是否隐藏
        /// </summary>
        public bool collectPostRecordsHidden { get; set; }
        /// <summary>
        /// 关注列表是否隐藏
        /// </summary>
        public bool focusRecordsHidden { get; set; }
        /// <summary>
        /// 粉丝列表是否隐藏
        /// </summary>
        public bool fansHidden { get; set; }
        /// <summary>
        /// 个性化推荐是否关闭
        /// </summary>
        public bool personalRecommend { get; set; }
        /// <summary>
        ///是否开启水印
        /// </summary>
        public bool watermark { get; set; }

        public static UserPrivacySetting InstanceByIntValue(int value)
        {
            return new UserPrivacySetting
            {
                likePostRecordsHidden = (value & 0b1) == 0b1,
                collectPostRecordsHidden = (value & 0b10) == 0b10,
                focusRecordsHidden = (value & 0b100) == 0b100,
                fansHidden = (value & 0b1000) == 0b1000,
                personalRecommend = (value & 0b10000) == 0b10000,
                watermark = (value & 0b100000) == 0b100000,
            };
        }

        public int GetIntValue()
        {
            return (likePostRecordsHidden ? 0b1 : 0b0)
                | (collectPostRecordsHidden ? 0b10 : 0b0)
                | (focusRecordsHidden ? 0b100 : 0b0)
                | (fansHidden ? 0b1000 : 0b0)
                | (personalRecommend ? 0b10000 : 0b0)
                | (watermark ? 0b100000 : 0b0);
        }
    }

    public class UserTagModel
    {
        public DateTime createDate { get; set; }
        public string tag { get; set; }
        public int count { get; set; }
        public double hot { get; set; }
    }

    public class VideoUploadState
    {
        /// <summary>
        /// 0 待上传或上传中 1 完成
        /// </summary>
        public int uploadState { get; set; }
        /// <summary>
        /// 如果 长宽为0，则表示视频分析未完成
        /// </summary>
        public int width { get; set; }
        public int height { get; set; }
    }


    public class DateRange
    {
        public string startDate { get; set; }
        public string endDate { get; set; }
    }

    #region 活动配置Model

    /// <summary>
    /// 活动答题的配置
    /// </summary>
    public class ActivityDtConfig
    {

        /// <summary>
        /// 活动头图，一张
        /// </summary>
        public string headerImage { get; set; }

        /// <summary>
        /// 一天内最多可答题次数
        /// </summary>
        public int totalTimesPerDay { get; set; }

        /// <summary>
        /// 答题最大时间
        /// </summary>
        public float maxSecs { get; set; } = 1999.99f;

        /// <summary>
        /// 每次的题目数量
        /// </summary>
        public int qaCount { get; set; }

        /// <summary>
        /// 题库类型编码列表
        /// </summary>
        public List<int> qaTagIds { get; set; }

        /// <summary>
        /// 每次答对数量与奖励的对应关系，如果无对应关系表示不奖励价值币
        /// </summary>
        public Dictionary<int, int> correctCountAndPointsMap { get; set; }
    }

    /// <summary>
    /// 活动晒笔记的配置
    /// </summary>
    public class ActivitySbjConfig
    {
        /// <summary>
        /// 活动一天可参与多少次
        /// </summary>
        public int totalTimesPerDay { get; set; } = 1;

        /// <summary>
        /// 0 不限 1 仅图文 2 仅视频
        /// </summary>
        public int contentType { get; set; } = 0;

        /// <summary>
        /// 0 不限 大于0 则限定为某一个topic下的
        /// </summary>
        public int topicId { get; set; }

        /// <summary>
        /// 奖励的价值币数量
        /// </summary>
        public int points { get; set; }

        /// <summary>
        /// 活动头图，一张
        /// </summary>
        public string headerImage { get; set; }

        /// <summary>
        /// 活动页面展示的标题
        /// </summary>
        public string title { get; set; }

        /// <summary>
        /// 活动页面展示的描述
        /// </summary>
        public string description { get; set; }
    }

    /// <summary>
    /// 活动邀请好友的配置
    /// </summary>
    public class ActivityYqhyConfig
    {
        /// <summary>
        /// 全局背景色
        /// </summary>
        public string globalBackgroundColor { get; set; }

        /// <summary>
        /// 活动头图，一张
        /// </summary>
        public string headerImage { get; set; }

        /// <summary>
        /// 活动尾图，多张
        /// </summary>
        public List<string> footerImages { get; set; }

        /// <summary>
        /// 活动配置的奖励项列表
        /// </summary>
        public List<int> rewardIds { get; set; }

        /// <summary>
        /// 排行榜数据一致时，0 排名并列 1 率先完成的排名在前，ID越低越优先
        /// </summary>
        public int orderType { get; set; }

        /// <summary>
        /// 排行榜结构，是否可以展开
        /// </summary>
        public bool expandable { get; set; }

        /// <summary>
        /// 默认显示多少名（条）
        /// </summary>
        public int defaultVisibleCount { get; set; }

        /// <summary>
        /// 展开后显示多少名（条）
        /// </summary>
        public int expandedVisibleCount { get; set; }

        /// <summary>
        /// 是否将“获利邀请”算入活动数据
        /// </summary>
        public bool ignoreProfit { get; set; }
    }

    /// <summary>
    /// 活动每日话题配置中话题配置项
    /// </summary>
    public class ActivityMrhtConfigTopicItem
    {
        /// <summary>
        /// 话题编号
        /// </summary>
        public int topicId { get; set; }
        /// <summary>
        /// 活动哪一天
        /// </summary>
        public DateTime date { get; set; }
    }

    /// <summary>
    /// 活动每日话题的配置
    /// </summary>
    public class ActivityMrhtConfig
    {
        /// <summary>
        /// 全局背景色
        /// </summary>
        public string globalBackgroundColor { get; set; }

        /// <summary>
        /// 活动头图，一张
        /// </summary>
        public string headerImage { get; set; }

        /// <summary>
        /// 活动尾图，多张
        /// </summary>
        public List<string> footerImages { get; set; }

        /// <summary>
        /// 活动配置的奖励项列表
        /// </summary>
        public List<int> rewardIds { get; set; }

        /// <summary>
        /// 排行榜数据一致时，0 排名并列 1 率先完成的排名在前，ID越低越优先
        /// </summary>
        public int orderType { get; set; }

        /// <summary>
        /// 排行榜结构，是否可以展开
        /// </summary>
        public bool expandable { get; set; }

        /// <summary>
        /// 默认显示多少名
        /// </summary>
        public int defaultVisibleCount { get; set; }

        /// <summary>
        /// 展开后显示多少名
        /// </summary>
        public int expandedVisibleCount { get; set; }

        /// <summary>
        /// 是否开启【看看别人怎么写】
        /// </summary>
        public bool recommendPosts { get; set; }

        /// <summary>
        /// 活动日对应的话题配置，如果找不到，则查找前一个日期的话题
        /// </summary>
        public List<ActivityMrhtConfigTopicItem> topics { get; set; }
    }

    /// <summary>
    /// 活动阅读量大比拼的配置
    /// </summary>
    public class ActivityYdldbpConfig
    {
        /// <summary>
        /// 全局背景色
        /// </summary>
        public string globalBackgroundColor { get; set; }

        /// <summary>
        /// 活动头图，一张
        /// </summary>
        public string headerImage { get; set; }

        /// <summary>
        /// 活动尾图，多张
        /// </summary>
        public List<string> footerImages { get; set; }

        /// <summary>
        /// 活动配置的奖励项列表
        /// </summary>
        public List<int> rewardIds { get; set; }

        /// <summary>
        /// 排行榜结构，是否可以展开
        /// </summary>
        public bool expandable { get; set; }

        /// <summary>
        /// 默认显示多少名
        /// </summary>
        public int defaultVisibleCount { get; set; }

        /// <summary>
        /// 展开后显示多少名
        /// </summary>
        public int expandedVisibleCount { get; set; }

    }

    public class ActivityDakaConfig
    {
        /// <summary>
        /// 全局背景色
        /// </summary>
        public string globalBackgroundColor { get; set; }

        /// <summary>
        /// 活动头图，一张
        /// </summary>
        public string headerImage { get; set; }

        /// <summary>
        /// 活动尾图，多张
        /// </summary>
        public List<string> footerImages { get; set; }

        /// <summary>
        /// 终极抽奖是否启用
        /// </summary>
        public bool finalDrawEnabled { get; set; }

        /// <summary>
        /// 终极抽奖开始时间
        /// </summary>
        public DateTime? finalDrawStartTime { get; set; }

        /// <summary>
        /// 终极抽奖结束时间
        /// </summary>
        public DateTime? finalDrawEndTime { get; set; }

        /// <summary>
        /// 普通抽奖模板编号
        /// </summary>
        public int normalTempId { get; set; }

        /// <summary>
        /// 普通抽奖面板图片
        /// </summary>
        public string normalPanelImage { get; set; }

        /// <summary>
        /// 普通抽奖指针图片
        /// </summary>
        public string normalIndicatorImage { get; set; }

        /// <summary>
        /// 打卡一次获取普通抽奖次数
        /// </summary>
        public int normalDrawTimes { get; set; } = 1;

        /// <summary>
        /// 终极抽奖模板编号
        /// </summary>
        public int finalTempId { get; set; }

        /// <summary>
        /// 终极抽奖面板图片
        /// </summary>
        public string finalPanelImage { get; set; }

        /// <summary>
        /// 终极抽奖指针图片
        /// </summary>
        public string finalIndicatorImage { get; set; }

        /// <summary>
        /// 价值币购买次数是否开启
        /// </summary>
        public bool boughtEnabled { get; set; }

        /// <summary>
        /// 一次购买所需价值币
        /// </summary>
        public int points { get; set; }

        /// <summary>
        /// 单日最大购买次数
        /// </summary>
        public int maxBoughtTimesPerDay { get; set; }

        /// <summary>
        /// 奖池列表图片
        /// </summary>
        public string prizeListImage { get; set; }
        
        /// <summary>
        /// 最终奖池列表图片
        /// </summary>
        public string finalPrizeListImage { get; set; }

    }

    #endregion 活动配置Model

    /// <summary>
    /// 网页爬取行情程序，在Redis存入的实时行情数据项结构
    /// </summary>
    public class QTLiveData
    {
        public string 名称 { get; set; }
        public DateTime 数据刷新时间 { get; set; }
        public Decimal? 当前价格 { get; set; }
        public Decimal? 今开 { get; set; }
        public Decimal? 昨收 { get; set; }
        public Decimal? 最高 { get; set; }
        public Decimal? 最低 { get; set; }
        /// <summary>
        /// 百分比
        /// </summary>
        public Decimal? 涨跌幅 { get; set; }
        /// <summary>
        /// 涨跌多少
        /// </summary>
        public Decimal? 涨跌额 { get; set; }
        /// <summary>
        /// 百分比
        /// </summary>
        public Decimal? 换手 { get; set; }
        /// <summary>
        /// 百分比
        /// </summary>
        public Decimal? 振幅 { get; set; }
        public string 成交量 { get; set; }
        public string 成交额 { get; set; }
    }

    /// <summary>
    /// 从AKShare获取的停牌信息
    /// </summary>
    public class QTSuspensionData
    {
        public string 代码 { get; set; }
        public string 名称 { get; set; }
        public DateTime? 停牌时间 { get; set; }
        public DateTime? 停牌截止时间 { get; set; }
        /// <summary>
        /// 如果值为【盘中停牌】，则表示仅只是部分交易时段停牌，当天还是交易的
        /// </summary>
        public string 停牌期限 { get; set; }
        public string 停牌原因 { get; set; }
        public string 所属市场 { get; set; }
        public DateTime? 预计复牌时间 { get; set; }
    }

    /// <summary>
    /// 奖励发放实体
    /// </summary>
    public class ReceiveReward
    {
        /// <summary>
        /// 来源id
        /// </summary>
        public int sourceId { get; set; }
        /// <summary>
        /// 来源名称
        /// </summary>
        public string sourceName { get; set; }
        /// <summary>
        /// 商品id
        /// </summary>
        public long goodsId { get; set; }
        /// <summary>
        /// 商品类型
        /// </summary>
        public int goodsType { get; set; }
        /// <summary>
        /// 商品数量
        /// </summary>
        public int goodsQuantity { get; set; }
        /// <summary>
        /// 商品缩略图
        /// </summary>
        public string goodsThumbnail { get; set; }
        /// <summary>
        /// 商品名称
        /// </summary>
        public string goodsTitle { get; set; }
        /// <summary>
        /// 用户id
        /// </summary>
        public long userId { get; set; }
        /// <summary>
        /// 奖励id 如果是打卡，n_activity_drawpool_temp_goods表的id
        /// </summary>
        public int rewardId { get; set; }
        /// <summary>
        /// 是否支付宝红包
        /// </summary>
        public bool isAlipayRed { get; set; }
    }

    public class SysMessageRecordTask
    {
        public int id { get; set; }
        public int messageId { get; set; }
        public string cont { get; set; }
        public DateTime execTime { get; set; }
        public int state { get; set; }
        public DateTime createAt { get; set; }
    }

    public class SysMessageRecord
    {
        public int id { get; set; }
        public string title { get; set; }
        public string pushTitle { get; set; }
        public string targets { get; set; }
        public string content { get; set; }
        public string pushContent { get; set; }
        public DateTime createAt { get; set; }
        public DateTime pushSendAt { get; set; }
        public string pushStyle { get; set; }
        public string pushImg { get; set; }
        public string image { get; set; }
        public string actionType { get; set; }
        public string actionSubType { get; set; }
        public string actionLink { get; set; }
    }
}
