
using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.Order;
using Hotline.Share.Enums.Quality;
using Hotline.Share.Requests;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.Quality
{
    public class QualityAddDto
    {
        /// <summary>
        /// 工单ID
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 回访ID
        /// </summary>
        public string? VisitId { get; set; }

        /// <summary>
        /// 质检方式
        /// </summary>
        public string? Mode { get; set; }


        /// <summary>
        /// 质检分数
        /// </summary>
        public int? Grade { get; set; }

        /// <summary>
        /// 质检评价
        /// </summary>
        public string? Content { get; set; }

        /// <summary>
        /// 质检状态
        /// </summary>
        public EQualityState State { get; set; }

        /// <summary>
        /// 质检来源
        /// </summary>
        public EQualitySource Source { get; set; }

		/// <summary>
		/// 质检明细
		/// </summary>
		public List<QualityDetailDto> QualityDetails { get; set; } = new List<QualityDetailDto>();	
	}
	public class UpdateQualityDto : QualityAddDto
	{
		public string Id { get; set; }
	}

	public class TransferUpdate
	{
		/// <summary>
		/// 质检ID
		/// </summary>
		public string Id { get; set; }
		/// <summary>
		/// 转写内容
		/// </summary>
		public List<Transfer>? Transfer { get; set; }
	}
	public class DeleteQualityDto
	{
		public List<string> Ids { get; set; }
	}
	public class QualityDetailDto : QualityBaseDto
	{
		/// <summary>
		/// 工单ID
		/// </summary>
		public string QualityId { get; set; }

        /// <summary>
        /// 扣分时间点- 秒
        /// </summary>
        public int Second { get; set; }

        /// <summary>
        /// 扣分时间点- 秒
        /// </summary>
        public int EndSecond { get; set; }

        /// <summary>
        /// 质检项目名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 扣分内容
        /// </summary>
        public string? Content { get; set; }

        /// <summary>
        /// 分值
        /// </summary>
        public int Grade { get; set; }

        /// <summary>
        /// 智能质检
        /// </summary>
        public bool? Intelligent { get; set; }

        /// <summary>
        /// 勾选
        /// </summary>
        public bool? Check { get; set; }
    }
    public class QualityDto : QualityBaseDto
    {
        /// <summary>
        /// 工单ID
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 回访ID
        /// </summary>
        public string? VisitId { get; set; }

        /// <summary>
        /// 质检方式
        /// </summary>
        public string? Mode { get; set; }


        /// <summary>
        /// 质检分数
        /// </summary>
        public int Grade { get; set; }

        /// <summary>
        /// 质检评价
        /// </summary>
        public string? Content { get; set; }

        /// <summary>
        /// 质检人
        /// </summary>
        public string? UserName { get; set; }

        /// <summary>
        /// 质检时间
        /// </summary>
        public DateTime? QualityTime { get; set; }

        /// <summary>
        /// 质检状态
        /// </summary>
        public EQualityState State { get; set; }

        public string StateText => State.GetDescription();

        /// <summary>
        /// 质检状态
        /// </summary>
        public EQualitySource Source { get; set; }

        public string SourceText => Source.GetDescription();

        /// <summary>
        /// 
        /// </summary>
        public OrderDto Order { get; set; }


        /// <summary>
        /// 回访
        /// </summary>
        public OrderVisitDto Visit { get; set; }

        /// <summary>
        /// 质检明细
        /// </summary>
        public List<QualityDetailDto> QualityDetails { get; set; }

        /// <summary>
        /// 智能质检
        /// </summary>
        public bool AiQuality { get; set; }

        /// <summary>
        /// 转写状态
        /// </summary>
        public EQualityTransferState? TransferState { get; set; }

        public string TransferStateText => TransferState.HasValue ? TransferState.GetDescription() : string.Empty;

        /// <summary>
        /// 转写内容
        /// </summary>
        public List<Transfer>? Transfer { get; set; }

    }
    public class QualityBaseDto
    {
        public DateTime? LastModificationTime { get; set; }

        public bool IsDeleted { get; set; }

        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime? DeletionTime { get; set; }


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

        public string Id { get; set; }

        /// <summary>
        /// 组织Id
        /// </summary>
        public string? CreatorOrgId { get; set; }


        public string? CreatorOrgName { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string? CreatorId { get; set; }

        public string? CreatorName { get; set; }
    }
    public record QualityListDto : PagedKeywordRequest
    {
        /// <summary>
        /// 质检状态
        /// </summary>
        public EQualityState? State { get; set; }

        /// <summary>
        /// 质检来源
        /// </summary>
        public EQualitySource? Source { get; set; }
        public DateTime? CreationTimeStart { get; set; }
        public DateTime? CreationTimeEnd { get; set; }

        /// <summary>
        /// 最大质检分数
        /// </summary>
        public int? MaxGrade { get; set; }

        /// <summary>
        /// 最小质检分数
        /// </summary>
        public int? MinGrade { get; set; }

        /// <summary>
        /// 工单编码
        /// </summary>
        public string? No { get; set; }

        /// <summary>
        /// 质检方式 true 智能质检 false 人工质检
        /// </summary>
        public bool? AiQuality { get; set; }

        /// <summary>
        /// 来源渠道
        /// </summary>
        public string? Channel { get; set; }

        /// <summary>
        /// 受理时间(工单创建时间)
        /// </summary>
        public DateTime? AcceptanceTimeStart { get; set; }
        public DateTime? AcceptanceTimeEnd { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>
        public EOrderStatus? Status { get; set; }

        /// <summary>
        /// 受理类型
        /// </summary>
        public string? AcceptTypeCode { get; set; }

        /// <summary>
        /// 热点分类关键词
        /// </summary>
        public string? Hotspot { get; set; }

        /// <summary>
        /// 受理坐席名字或工号
        /// </summary>
        public string? NameOrNo { get; set; }

        /// <summary>
        /// 来电号码
        /// </summary>
        public string? FromPhone { get; set; }

        /// <summary>
        /// 质检人
        /// </summary>
        public string? UserName { get; set; }

        /// <summary>
        /// 质检时间
        /// </summary>
        public DateTime? QualityTimeStar { get; set; }
        public DateTime? QualityTimeEnd { get; set; }
    }

    public class AiQualityXTDto
    {
        public string Id { get; set; }
    }
}
