using FluentValidation;
using OASystem.Domain.Dtos.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using OASystem.Domain.ViewModels.Groups;

namespace OASystem.Domain.Dtos.Statistics
{
    public class MarketingSalesUserPageFuncDtoBase
    {
        /// <summary>
        /// 请求端口分类
        /// 1 Web 2 Android 3 IOS
        /// </summary>
        public int PortType { get; set; } = 1;

        /// <summary>
        /// 用户Id
        /// </summary>
        public int UserId { get; set; }

        /// <summary>
        /// 页面Id
        /// </summary>
        public int PageId { get; set; } = 180;
    }

    public class MarketingSalesUserPageFuncDtoBaseFoalidator : AbstractValidator<MarketingSalesUserPageFuncDtoBase>
    {
        public MarketingSalesUserPageFuncDtoBaseFoalidator()
        {
            RuleFor(it => it.PortType).InclusiveBetween(1,3).WithMessage(MsgTips.Port);
            RuleFor(it => it.UserId).GreaterThan(1).WithMessage(MsgTips.UserId);
            RuleFor(it => it.PageId).GreaterThan(1).WithMessage(MsgTips.PageId);
        }
    }

    /// <summary>
    /// 市场部销售额 Dto
    /// </summary>
    public class MarketingSalesDto { }

    /// <summary>
    /// 市场部销售额 
    /// 市场部人员列表
    /// Dto
    /// </summary>
    public class MarketingSalesInitDataDto : MarketingSalesUserPageFuncDtoBase { }
    public class MarketingSalesInitDataDtoFoalidator : AbstractValidator<MarketingSalesInitDataDto>
    {
        public MarketingSalesInitDataDtoFoalidator() 
        {
            Include(new MarketingSalesUserPageFuncDtoBaseFoalidator());
        }
    }

    /// <summary>
    ///  市场部销售额
    ///  年度/季度/月度 报表
    /// </summary>
    public class MarketingSalesStatisticsDto : MarketingSalesUserPageFuncDtoBase 
    {
        /// <summary>
        /// 公司Id
        /// </summary>
        public int CompanyId { get; set; }

        /// <summary>
        /// 接团人Id
        /// </summary>
        public int GroupPickupUserId  { get; set; }

        public string BeginDt { get; set; }

        public string EndDt { get; set; }

    }
    public class MarketingSalesStatisticsDtoFoalidator : AbstractValidator<MarketingSalesStatisticsDto>
    {
        public MarketingSalesStatisticsDtoFoalidator()
        {
            Include(new MarketingSalesUserPageFuncDtoBaseFoalidator());
            RuleFor(it => it.BeginDt)
                .Must(dateString => DateTime.TryParse(dateString, out _))
                .WithMessage("请输入有效开始的日期");
            RuleFor(it => it.EndDt)
                .Must(dateString => DateTime.TryParse(dateString, out _))
                .WithMessage("请输入有效结束的日期");
        }
    }

    /// <summary>
    ///  市场部销售额
    ///  团组列表
    /// </summary>
    public class MarketingSalesGroupListDto : MarketingSalesStatisticsDto {

        public int PageIndex { get; set; } = 1;
        public int PageSize { get; set; } = 10;

        public string SearchCriteria { get; set; }
    }

    /// <summary>
    ///  市场部销售额
    ///  客户类型、客户等级 统计
    /// </summary>
    public class MarketingSalesGroupStatisticsDto : MarketingSalesStatisticsDto
    {
        /// <summary>
        /// 图形统计类型
        /// 1 客户类型 2 客户等级
        /// </summary>
        public int StatisticsType { get; set; } = 1;
    }

    /// <summary>
    ///  市场部销售额
    ///  接单排名
    /// </summary>
    public class MarketingSalesOrderRankingDto : MarketingSalesStatisticsDto
    {
        public int PageIndex { get; set; } = 1;
        public int PageSize { get; set; } = 5;
    }

    public class MarketingSalesVCListDto: MarketingSalesUserPageFuncDtoBase
    {
        public int PageIndex { get; set; } = 1;
        public int PageSize { get; set; } = 10;

        public int DiId { get; set; }
        public string Search { get; set; }
    }

    public class MarketingSalesVCOperrateDto : MarketingSalesUserPageFuncDtoBase
    {
        /// <summary>
        /// opearate 时
        /// Id > 0 修改
        /// Id < 1 添加
        /// </summary>
        public int Id { get; set; }
       
    }

    public class MarketingSalesVCSaveDto: MarketingSalesUserPageFuncDtoBase
    {
        public int DiId { get; set; }
        public List<VisitingClientsListView> Items { get; set; }
    }


    public class MarketingSalesVCDelDto
    {
        public int UserId { get; set; }
        public int Id { get; set; }
    }
}
