using Hotline.FlowEngine.Definitions;
using Hotline.Schedulings;
using Hotline.Share.Dtos.FlowEngine;
using Hotline.Share.Dtos.FlowEngine.Workflow;
using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.FlowEngine;

namespace Hotline.Orders
{
    public interface IOrderDomainService
    {
        #region OrderHandle

        Task<Order> GetOrderAsync(string? orderId, bool withHotspot = false, bool withAcceptor = false,
           bool withExtension = false, CancellationToken cancellationToken = default);

        Task<string> AddAsync(Order order, bool autoAccept = false, CancellationToken cancellationToken = default);

        /// <summary>
        /// 撤回或跳转前处理数据及校验
        /// <remarks>
        ///工单撤回时需校验工单当前是否存在待发布记录、待回访记录，若存在需删除对应记录（跳转同理）
        ///工单撤回时需校验工单是否存在甄别中记录，若存在不允许撤回当前工单（跳转同理）
        /// </remarks>
        /// </summary>
        Task ReadyToRecallAsync(string orderId, CancellationToken cancellationToken);

        ///// <summary>
        ///// 计算并赋值order的几个时长字段
        ///// </summary>
        ///// <returns></returns>
        //Task CalculateAndSetOrderDuration(bool setHandleDuration, bool setFileDuration, bool allDuration);

        #endregion

        #region OrderRedo

        Task<string> AddOrderRedoAsync(OrderRedo orderRedo, CancellationToken cancellationToken);

        Task RemoveOrderRedoAsync(string id, CancellationToken cancellationToken);

        Task UpdateOrderRedoAsync(OrderRedo orderRedo, CancellationToken cancellationToken);

        #endregion

        #region 扩展信息

        Task<OrderExtension?> GetOrderExtensionsAsync(string provinceNo, CancellationToken cancellationToken);

        Task UpdateExtensionAsync(OrderExtension orderExtension, CancellationToken cancellationToken);

        /// <summary>
        /// 新增工单扩展信息
        /// </summary>
        Task AddExtensionAsync(OrderExtension extension, CancellationToken cancellationToken);

        #endregion

        #region OrderComplement

        /// <summary>
        /// 新增工单补充信息
        /// </summary>
        Task<string> AddOrderComplementAsync(AddOrderComplementDto dto, CancellationToken cancellationToken);

        #endregion

        #region 平均派单

        /// <summary>
        /// 获取是否上班
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        Task<bool> SchedulingAtWork(string UserId);
		/// <summary>
		/// 平均派单
		/// </summary>
		/// <returns></returns>
		Task<StepAssignInfo> AverageOrder(CancellationToken cancellationToken);

        /// <summary>
        /// 登录平均派单
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task LogAverageOrder(string userId, Scheduling scheduling, CancellationToken cancellationToken);

        /// <summary>
        /// 触发平均派单
        /// </summary>
        /// <returns></returns>
        Task TriggerAverageOrder(CancellationToken cancellationToken);

		/// <summary>
		/// 提前触发平均派单
		/// </summary>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>
		Task AdvancedTriggerAverageOrder(CancellationToken cancellationToken);
		#endregion

		#region  工单校验- 交通类工单
		/// <summary>
		/// 工单校验  - 交通类工单
		/// </summary>
		/// <returns></returns>
		Task<OrderValidation> OrderValidation(AddOrderDto dto, CancellationToken cancellationToken);
        #endregion

        /// <summary>
        /// 验证是否是管理员
        /// </summary>
        /// <returns></returns>
        bool IsCheckAdmin();

        /// <summary>
        /// 推送即将超期和超期短信
        /// </summary>
        /// <returns></returns>
        Task SendOverTimeSms(CancellationToken cancellationToken);
        Task OrderPublishAsync(Order order, CancellationToken cancellationToken);
        Task OrderAutomaticPublishAsync(Order order, CancellationToken cancellationToken);

        /// <summary>
        /// 重办和退回工单时如果有取消发布的工单, 清除回访待办和回访列表中的数据
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task VisitNoneByCancelPublishAsync(string orderId, CancellationToken cancellationToken);

		/// <summary>
		/// 计算甄别申请截至日期
		/// </summary>
		/// <returns></returns>
		Task<DateTime> GetScreenByEndTime();

	}
}