using System;
using System.Collections.Generic;
using System.Text;

namespace JiaZhiQuan.Common.Messaging.Models
{
    public enum StatisticActionType
    {
        /// <summary>
        /// **已废弃，使用POST_VIEW_COUNT。如果传入 用户Id时，则将插入浏览记录，并且当类别是动态时更新用户的标签画像
        /// </summary>
        POST_VIEW,

        POST_RECOMMEND,

        /// <summary>
        /// 当某一个用户的粉丝量变化时（用来同步粉丝数量到ES）
        /// </summary>
        USER_FANS_CHANGE,

        /// <summary>
        /// 整体更新用户的获赞数量
        /// </summary>
        UPDATE_THUMBSUP_USER,
        /// <summary>
        /// 整体更新动态的获赞数量
        /// </summary>
        UPDATE_THUMBSUP_POST,

        /// <summary>
        /// **已废弃，使用POST_VIEW_COUNT。更新用户的标签数据
        /// </summary>
        UPDATE_TAG_USER,

        /// <summary>
        /// 统计文章的阅读次数
        /// </summary>
        POST_VIEW_COUNT,

        /// <summary>
        /// 统计有效的分享数量
        /// </summary>
        POST_SHARE_COUNT,

        /// <summary>
        /// 用户个人主页访问次数
        /// </summary>
        USER_PERSONAL_PAGE_VIEW_COUNT,
        
        /// <summary>
        /// 用户省变更检测
        /// </summary>
        USER_PROVINCE_CHECK,
        
        /// <summary>
        /// 当某一批用户的粉丝量变化时（用来同步粉丝数量到ES）
        /// </summary>
        USER_FANS_CHANGE_BATCH,
        
        /// <summary>
        /// 商品推荐
        /// </summary>
        GOODS_RECOMMEND,

        /// <summary>
        /// 商品推荐
        /// </summary>
        GOODS_RECOMMEND_SCORE,

        /// <summary>
        /// IM，保存会话最后一条消息的id
        /// </summary>
        IM_CHAT_LASTMESSAGE,
    }

    public class StatisticActionModel
    {
        public StatisticActionType Type { get; set; }

        public string Content { get; set; }

        public static string GetMsgKey()
        {
            return "JZQ_Statistic_Action_Msg";
        }
    }

    public class SPostViewCountSubModel
    {
        public long PostId { get; set; }
        /// <summary>
        /// 是否是粉丝
        /// </summary>
        public bool IsFan { get; set; }
        public bool IsValid { get; set; }
        public long UserId { get; set; }
        public string IP { get; set; }
        public int CategoryType { get; set; }
        public string ClientId { get; set; }
        public DateTime CreateAt { get; set; }
    }

    public class SPostShareCountSubModel
    {
        public long PostId { get; set; }
        public long UserId { get; set; }
        public string IP { get; set; }
        public string ClientId { get; set; }
        public DateTime CreateAt { get; set; }
    }

    public class SUserPersonalPageViewCountSubModel
    {
        public long PageUserId { get; set; }
        public long UserId { get; set; }
        public string IP { get; set; }
        public string ClientId { get; set; }
        public DateTime CreateAt { get; set; }
    }

    //public class SPostViewSubModel
    //{
    //    public long PostId { get; set; }
    //    public long UserId { get; set; }
    //    /// <summary>
    //    /// 0 资讯 1 动态/笔记 2 研报
    //    /// </summary>
    //    public int Type { get; set; }
    //    /// <summary>
    //    /// 查看次数
    //    /// </summary>
    //    public int Count { get; set; } = 1;
    //    public bool IsFan { get; set; }
    //}

    // 暂时去除
    //public class SUserPostTagSubModel
    //{
    //    public long PostId { get; set; }
    //    public long UserId { get; set; }
    //    /// <summary>
    //    /// 浏览为1，点赞为5，收藏为8
    //    /// </summary>
    //    public int Weight { get; set; }
    //}

    public class SPostRecommendSubModel
    {
        /// <summary>
        /// 是否将推荐记录到数据库，用于Filter的定时移除
        /// </summary>
        public bool InsertIntoRecommend { get; set; }
        public long UserId { get; set; }
        /// <summary>
        /// 如果需要插入到BloomFilter中，如果登录情况下不传，如果未登录，则需要传客户端的GUID
        /// </summary>
        public string ClientId { get; set; }
        public IList<long> PostIds { get; set; }
    }

    public class SGoodsRecommendSubModel
    {
        /// <summary>
        /// 是否将推荐记录到数据库，用于Filter的定时移除
        /// </summary>
        public bool InsertIntoRecommend { get; set; }
        public long UserId { get; set; }
        /// <summary>
        /// 如果需要插入到BloomFilter中，如果登录情况下不传，如果未登录，则需要传客户端的GUID
        /// </summary>
        public string ClientId { get; set; }
        public IList<long> GoodsIds { get; set; }
    }

    /// <summary>
    /// 计算推荐分消息体
    /// </summary>
    public class RecommendScoreModel {
        /// <summary>
        /// 商品id
        /// </summary>
        public List<long> goodsIds { get; set; }
        /// <summary>
        /// 卖家用户id
        /// </summary>
        public long sellerId { get; set; }
        /// <summary>
        /// 来源 1寄售，2挂售
        /// </summary>
        public int source { get; set; }
    }

    public class SUserFansCountModel
    {
        public long UserId { get; set; }
    }

    public class SUserIdListModel
    {
        public List<long> UserIds { get; set; }
    }

    public class SPostIdListModel
    {
        public List<long> PostIds { get; set; }
    }

    public class SUserProvinceCheckModel
    {
        /// <summary>
        /// Key为用户编号，值为IP
        /// </summary>
        public List<KeyValuePair<long, string>> DataList { get; set; }
    }

    public class SIMChatLastMessageModel
    {
        public long ChatId { get; set; }

        public long MessageId { get; set; }

        public DateTime SendTime { get; set; }
    }
}
