using Hotline.Share.Dtos.File;
using Hotline.Share.Enums.Order;
using Hotline.Share.Requests;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.Order
{
	public class OrderSecondaryHandlingDto: OrderSecondaryHandlingBaseDto
	{
		/// <summary>
		/// 工单ID
		/// </summary>
		public string OrderId { get; set; }

		/// <summary>
		/// 状态
		/// </summary>
		public ESecondaryHandlingState? State { get; set; }

		public string StateText => State.GetDescription();

		/// <summary>
		/// 重提办理
		/// </summary>
		public int? SendBackNum { get; set; }

		public string SendBack => SendBackNum is > 0 ? "是" : "否";

		/// <summary>
		/// 申请理由
		/// </summary>
		public string? Content { get; set; }

		/// <summary>
		/// 退回意见
		/// </summary>
		public string? SendBackContent { get; set; }


		/// <summary>
		/// 审批意见
		/// </summary>
		public string? AuditContent { get; set; }

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

		/// <summary>
		/// 回访
		/// </summary>
		public OrderVisitDetailDto VisitDetail { get; set; }

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

		/// <summary>
		/// 审批人ID
		/// </summary>
		public string? AuditId { get; set; }

		public string? AuditUser { get; set; }

		/// <summary>
		/// 审批时间
		/// </summary>
		public DateTime? AuditTime { get; set; }

		/// <summary>
		/// 申请部门ID
		/// </summary>
		public string ApplyOrgId { get; set; }

		/// <summary>
		/// 申请部门名称
		/// </summary>
		public string ApplyOrgName { get; set; }

		/// <summary>
		/// 附件列表
		/// </summary>
		public List<FileDto> Files { get; set; } = new();

	}

	public class AddOrderSecondaryHandlingDto {

		public string Id { get; set; }

		/// <summary>
		/// 工单ID
		/// </summary>
		public string OrderId { get; set; }

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

		/// <summary>
		/// 回访明细id
		/// </summary>
		public string VisitDetailId { get; set; }

		/// <summary>
		/// 申请理由
		/// </summary>
		public string? Content { get; set; }

		/// <summary>
		/// 附件列表
		/// </summary>
		public List<FileDto> Files { get; set; } = new();

		public List<FileJson>? FileJson { get; set; }
	}

	public class AuditOrderSecondaryHandlingDto
	{
		public string Id { get; set; }
		/// <summary>
		/// 状态
		/// </summary>
		public ESecondaryHandlingState? State { get; set; }


		/// <summary>
		/// 审批意见
		/// </summary>
		public string? AuditContent { get; set; }

		public List<string> Ids { get; set; }
	}

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

		/// <summary>
		/// 退回意见
		/// </summary>
		public string? SendBackContent { get; set; }
	}

	public class OrderSecondaryHandlingBaseDto
	{
		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 SecondaryHandlingListDto : PagedKeywordRequest
	{
		/// <summary>
		/// 申请状态
		/// </summary>
		public ESecondaryHandlingState? Status { get; set; }

		public DateTime? CreationTimeStart { get; set; }
		public DateTime? CreationTimeEnd { get; set; }

		public string? OrderId { get; set; }

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

		/// <summary>
		/// 工单标题
		/// </summary>
		public string? Title { get; set;}

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

        /// <summary>
        /// 重提办理
        /// </summary>
        public int? SendBack { get; set; }

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

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

        /// <summary>
        /// 申请人
        /// </summary>
        public string? ApplyName { get; set; }

        /// <summary>
        /// 申请部门
        /// </summary>
        public string? ApplyOrgName { get; set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime? ApplyTimeStart { get; set; }
        public DateTime? ApplyTimeEnd { get; set; }
    }
}
