using IRaCIS.Core.Infrastructure.Extention;

namespace IRaCIS.Application.Contracts.Pay
{
    public class PaymentDetailDTO
    {
        public Guid Id { get; set; }
        public Guid PaymentId { get; set; }
        public string YearMonth { get; set; } = String.Empty;
        public Guid DoctorId { get; set; }
        public Guid TrialId { get; set; }
        public string TrialCode { get; set; } = String.Empty;
        public string PaymentType { get; set; } = String.Empty;
        public int Count { get; set; }
        public decimal BasePrice { get; set; }
        public decimal PersonalAdditional { get; set; }

        public decimal? NewPersonalAdditional { get; set; }
        public decimal TrialAdditional { get; set; }
        public int ShowTypeOrder { get; set; }
        public int ShowCodeOrder { get; set; }

        public decimal ExchangeRate { get; set; }

        public decimal PaymentUSD { get; set; }
        public decimal PaymentCNY { get; set; }

        public bool? IsNewTrial { get; set; }

        public decimal TotalUnitPrice => BasePrice + PersonalAdditional + TrialAdditional;

        public AdjustmentDTO AdjustmentView { get; set; } = new AdjustmentDTO();

    }

    public class AdjustmentDTO
    {
        public decimal AdjustPaymentUSD { get; set; }

        public decimal AdjustPaymentCNY { get; set; }

        public string AdjustType
        {
            get
            {
                if (AdjustPaymentUSD > 0)
                {
                    return "+";
                }
                else if (AdjustPaymentUSD < 0)
                {
                    return "-";
                }
                else { return string.Empty; }
            }
        }
        public string Note { get; set; } = String.Empty;
    }


    public class PaymentDetailCommand : PaymentDetailDTO
    {

    }

    public class PayDetailDTO
    {
        public IEnumerable<PaymentDetailDTO> DetailList { get; set; } = new List<PaymentDetailDTO>();
        public DoctorPayInfo DoctorInfo { get; set; } = new DoctorPayInfo();
    }

    public class LockPaymentDTO
    {
        public List<Guid> ReviewerIdList { get; set; }=new List<Guid>();
        public DateTime Month { get; set; }

        public bool IsLock { get; set; } = true;
    }

    public class DoctorPayInfo
    {
        public Guid DoctorId { get; set; }
        public string ChineseName { get; set; } = String.Empty;
        public string FirstName { get; set; } = String.Empty;
        public string LastName { get; set; } = String.Empty;
        public string Phone { get; set; } = String.Empty;
        public string PayTitle { get; set; } = String.Empty;
        public string Code { get; set; } = String.Empty;
        public string YearMonth { get; set; } = String.Empty;
    }




   


    public class ReviewerPaymentUSD
    {
        public Guid RecordId { get; set; }
        public Guid DoctorId { get; set; }
        public decimal PaymentUSD { get; set; }
    }

    public class PaymentQueryDTO : PageInput
    {
        public string Reviewer { get; set; } = String.Empty;
        public DateTime BeginMonth { get; set; }
        public DateTime EndMonth { get; set; }
        public int? Nation { get; set; }
    }
    public class MonthlyPaymentDTO
    {
        public Guid ReviewerId { get; set; }
        public string ReviewerCode { get; set; } = String.Empty;
        public string ChineseName { get; set; } = String.Empty;
        public string FirstName { get; set; } = String.Empty;
        public string LastName { get; set; } = String.Empty;

        public string FullName { get; set; } = String.Empty;

        public decimal AdjustmentUSD { get; set; }
        public decimal AdjustmentCNY { get; set; }
        public decimal PaymentUSD { get; set; }
        public decimal PaymentCNY { get; set; }

        public decimal TotalUSD { get; set; }
        public decimal TotalCNY { get; set; }

    }

    public class VolumeStatisticsDTO
    {
        public Guid StatisticsId { get; set; }
        public string Month { get; set; } = String.Empty;
        public decimal VolumeReward { get; set; }
        public decimal ExchangeRate { get; set; }

        public decimal AdjustmentUSD { get; set; }
        public decimal AdjustmentCNY { get; set; }
        public decimal PaymentUSD { get; set; }
        public decimal PaymentCNY { get; set; }
        public decimal TotalCNY => AdjustmentCNY + PaymentCNY;
        public decimal TotalUSD => AdjustmentUSD + PaymentUSD;

        public List<TrialPaymentDTO> TrialPaymentList = new List<TrialPaymentDTO>();
    }

    public class TrialPaymentDTO
    {
        public Guid TrialId { get; set; }
        public string TrialCode { get; set; } = String.Empty;
        public decimal TrialPayment { get; set; }

    }
    public class VolumeQueryDTO
    {
        public DateTime BeginMonth { get; set; }
        public DateTime EndMonth { get; set; }
        public Guid ReviewerId { get; set; }
    }

    public class RevenuesDTO
    {
        public List<string> MissingTrialCodes = new List<string>();
        public Guid Id { get; set; }
        public string TrialCode { get; set; } = String.Empty;
        public Guid TrialId { get; set; }
        public string Indication { get; set; } = String.Empty;
        public Guid? CroId { get; set; }
        public string Cro { get; set; } = string.Empty;

        public int Expedited { get; set; }
        public string ChineseName { get; set; } = string.Empty;

        public string FirstName { get; set; } = string.Empty;
        public string LastName { get; set; } = string.Empty;
        public string ReviewerCode { get; set; } = string.Empty;

        public decimal Training { get; set; }
        public decimal Downtime { get; set; }
        public decimal Timepoint { get; set; }
        public decimal TimepointIn24H { get; set; }
        public decimal TimepointIn48H { get; set; }
        public decimal Adjudication { get; set; }
        public decimal AdjudicationIn24H { get; set; }
        public decimal AdjudicationIn48H { get; set; }
        public decimal Global { get; set; }
        public decimal Total { get; set; }

        public string YearMonth { get; set; } = String.Empty;
    }


}