using System.ComponentModel;
using Hotline.Share.Enums.CallCenter;
using SqlSugar;
using XF.Domain.Entities;
using XF.Domain.Repository;

namespace Hotline.CallCenter.Calls
{
    /// <summary>
    /// 通话记录
    /// </summary>
    [Description("通话记录")]
    public class Call : FullStateEntity
    {
        /// <summary>
        /// 呼叫方向，呼入/呼出
        /// </summary>
        [SugarColumn(ColumnDescription = "呼叫方向，呼入/呼出")]
        public ECallDirection CallDirection { get; set; }

        /// <summary>
        /// 通话状态
        /// </summary>
        [SugarColumn(ColumnDescription = "通话状态")]
        public ECallStatus CallStatus { get; set; }

        /// <summary>
        /// 通话类型
        /// </summary>
        [SugarColumn(ColumnDescription = "通话类型")]
        public ECallType CallType { get; set; }

        /// <summary>
        /// 主叫号码
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "主叫号码")]
        public string? FromNo { get; set; }

        /// <summary>
        /// 被叫号码
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "被叫号码")]
        public string? ToNo { get; set; }

        /// <summary>
        /// 被叫号码扩展字段（标准手机号，外地号码去零）
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "被叫号码扩展字段（标准手机号，外地号码去零）")]
        public string? ToNoExt { get; set; }

        /// <summary>
        /// 通话结束方
        /// </summary>
        [SugarColumn(ColumnDescription = "通话结束方")]
        public EEndBy? EndBy { get; set; }

        /// <summary>
        /// 扩展内容（讯时设备产生的临时唯一标识：VisitorId 或 OuterId）
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "扩展内容（讯时设备产生的临时唯一标识：VisitorId 或 OuterId）")]
        public string? ConversationId { get; set; }

        /// <summary>
        /// 中继线路
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "中继线路")]
        public string? Trunk { get; set; }

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

        /// <summary>
        /// 通话时长
        /// </summary>
        [SugarColumn(ColumnDescription = "通话时长")]
        public double? Duration { get; set; }

        /// <summary>
        /// 通话记录详情
        /// </summary>
        [SugarColumn(ColumnDescription = "通话记录详情")]
        [Navigate(NavigateType.OneToMany, nameof(CallDetail.CallId))]
        public List<CallDetail> CallDetails { get; set; }

        /// <summary>
        /// 用户ID
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "用户ID")]
        public string? UserId { get; set; }

        /// <summary>
        /// 用户名称
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "用户名称")]
        public string? UserName { get; set; }

        /// <summary>
        /// 挂断类型
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "挂断类型")]
        public ERingOffType? RingOffType { get; set; }

        /// <summary>
        /// 运营商
        /// </summary>
        [SugarColumn(ColumnDescription = "运营商")]
        public EPhoneISP? PhoneIsp { get; set; }

        /// <summary>
        /// 归属地
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "归属地")]
        public string? Attribution { get; set; }

        /// <summary>
        /// 进入IVR时间
        /// </summary>
        public DateTime? InIvrTime { get; set; }

        /// <summary>
        /// 进入队列时间
        /// </summary>
        public DateTime? InQueueTime { get; set; }

        /// <summary>
        /// 振铃时间
        /// </summary>
        public DateTime? RingTime { get; set; }

        /// <summary>
        /// 接听时间
        /// </summary>
        public DateTime? AnsweredTime { get; set; }

        /// <summary>
        /// 挂断时间
        /// </summary>
        public DateTime? ByeTime { get; set; }

        /// <summary>
        /// 通话保持时间
        /// </summary>
        public int HoldDuration { get; set; }
    }
}
