using Hotline.Orders;
using Hotline.Share.Enums.Push;
using SqlSugar;
using XF.Domain.Repository;

namespace Hotline.Push.FWMessage
{
    /// <summary>
    /// 推送消息
    /// </summary>
    public class Message : CreationEntity
    {
        /// <summary>
        /// 消息推送业务
        /// </summary>        
        [SugarColumn(ColumnDescription = "消息推送业务")]
        public EPushBusiness PushBusiness { get; set; }

        /// <summary>
        /// 外部业务唯一编号
        /// </summary>
        [SugarColumn(ColumnDescription = "外部业务唯一编号", ColumnDataType = "varchar(50)", IsNullable = true)]
        public string? ExternalId { get; set; }

        /// <summary>
        /// 业务系统短信ID
        /// </summary>
        [SugarColumn(ColumnDescription = "业务系统短信ID")]
        public int WaitSendId { get; set; } = 0;

        /// <summary>
        /// 推送平台
        /// </summary>
        [SugarColumn(ColumnDescription = "推送平台", IsNullable = true)]
        public EPushPlatform? PushPlatform { get; set; } = EPushPlatform.Sms;

        /// <summary>
        /// 推送状态
        /// </summary>
        [SugarColumn(ColumnDescription = "推送状态", ColumnDataType = "varchar(2)")]
        public EPushStatus Status { get; set; } = EPushStatus.Pushing;

        /// <summary>
        /// 模板
        /// </summary>
        [SugarColumn(ColumnDescription = "模板", ColumnDataType = "varchar(200)", IsNullable = true)]
        public string? Template { get; set; }

        /// <summary>
        /// 短信内容
        /// </summary>
        [SugarColumn(ColumnDescription = "短信内容", ColumnDataType = "varchar(255)")]
        public string Content { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(ColumnDescription = "备注", ColumnDataType = "varchar(500)", IsNullable = true)]
        public string? Remark { get; set; }

        /// <summary>
        /// 接收姓名
        /// </summary>
        [SugarColumn(ColumnDescription = "接收姓名", ColumnDataType = "varchar(20)")]
        public string Name { get; set; }

        /// <summary>
        /// 接收手机号码
        /// </summary>
        [SugarColumn(ColumnDescription = "接收手机号码", ColumnDataType = "varchar(20)")]
        public string TelNumber { get; set; }

        /// <summary>
        /// 关联工单编号
        /// </summary>
        [SugarColumn(ColumnDescription = "关联工单编号", ColumnDataType = "varchar(50)", IsNullable = true)]
        public string? OrderId { get; set; }

        /// <summary>
        /// 短信中心待发送ID
        /// </summary>
        [SugarColumn(ColumnDescription = "短信中心待发送ID", ColumnDataType = "varchar(20)", IsNullable = true)]
        public string? SmsWaitSendingId { get; set; }

        /// <summary>
        /// 短信中心已发送ID
        /// </summary>
        [SugarColumn(ColumnDescription = "短信中心已发送ID", ColumnDataType = "varchar(20)", IsNullable = true)]
        public string? SmsSendingCompletedId { get; set; }

        /// <summary>
        /// 发送短信使用的数量
        /// </summary>
        [SugarColumn(ColumnDescription = "发送短信使用的数量", IsNullable = true)]
        public int? MsgCount { get; set; }

        /// <summary>
        /// 短信发送状态
        /// </summary>
        [SugarColumn(ColumnDescription = "短信发送状态")]
        public ESendState SendState { get; set; }

        /// <summary>
        /// 发送时间
        /// </summary>
        [SugarColumn(ColumnDescription = "发送时间", IsNullable = true)]
        public DateTime? SendTime { get; set; }

        /// <summary>
        /// 短信回复是否回复
        /// </summary>   
        [SugarColumn(ColumnDescription = "短信回复是否回复")]
        public bool IsSmsReply { get; set; }

        /// <summary>
        /// 短信回复内容
        /// </summary>   
        [SugarColumn(ColumnDescription = "短信回复内容", ColumnDataType = "varchar(200)", IsNullable = true)]
        public string? SmsReplyContent { get; set; }

        /// <summary>
        /// 短信回复时间
        /// </summary>
        [SugarColumn(ColumnDescription = "短信回复时间", IsNullable = true)]
        public DateTime? SmsReplyTime { get; set; }

        /// <summary>
        /// 发送失败原因等
        /// </summary>
        [SugarColumn(ColumnDescription = "发送失败原因等", ColumnDataType = "varchar(200)", IsNullable = true)]
        public string? Reason { get; set; }

        /// <summary>
        /// 从发次数
        /// </summary>
        [SugarColumn(ColumnDescription = "从发次数")]
        public int? ResendCount { get; set; }

        /// <summary>
        /// 关联工单信息
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(OrderId))]//
        public Order? Order { get; set; }

        ///// <summary>
        ///// 参数
        ///// </summary>
        //[SqlSugar.SugarColumn(IsIgnore = true)]
        //public List<string> Params { get; set; }
    }
}
