using System;
using System.Collections.Generic;
using XYY.Common.Standard;
using XYY.Common.Standard.Attributes;
using XYY.Core.Standard;

namespace XYY.Model.Standard.Finance
{
    public class View_Finance_Logistics_LadingBill : Finance_Logistics_LadingBill
    {

        public EstimateClearanceChargeMethod ClearanceChargeMethod
        {
            get; set;
        }

        public string ChannelName
        {
            get; set;
        }

        public int SysBoxQty
        {
            get; set;
        }

        public int SysWeight
        {
            get; set;
        }

        public int SysPieces
        {
            get; set;
        }



        public decimal AvgWeightCusetomerFee
        {
            get
            {
                try
                {
                    if (Weight > 0 || SysWeight > 0)
                    {
                        return (CusetomerFee) / (Weight > 0 ? Weight : SysWeight / 1000);
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public decimal AvgPiecesCusetomerFee
        {
            get
            {
                if (Pieces > 0 || SysPieces > 0)
                {
                    return (CusetomerFee) / (Pieces > 0 ? Pieces : SysPieces);
                }
                return 0;
            }
        }



        public decimal AvgWeightFristFee
        {
            get
            {
                try
                {
                    if (Weight > 0 || SysWeight > 0)
                    {
                        return (FristFee) / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public decimal AvgPiecesFristFee
        {
            get
            {
                if (Pieces > 0 || SysPieces > 0)
                {
                    return (FristFee) / (decimal)(Pieces > 0 ? Pieces : SysPieces);
                }
                return 0;
            }
        }


        public decimal AvgWeightDomesticClearFee
        {
            get
            {
                if (Weight > 0 || SysWeight > 0)
                {
                    return DomesticClearFee / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                }
                return 0;
            }
        }


        public decimal AvgWeightOverseasClearFee
        {
            get
            {
                if (Weight > 0 || SysWeight > 0)
                {
                    return OverseasClearFee / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                }
                return 0;
            }
        }


        public decimal AvgPiecesDomesticClearFee
        {
            get
            {
                if (Pieces > 0 || SysPieces > 0)
                {
                    return DomesticClearFee / (decimal)(Pieces > 0 ? Pieces : SysPieces);
                }
                return 0;
            }
        }


        public decimal AvgPiecesOverseasClearFee
        {
            get
            {
                if (Pieces > 0 || SysPieces > 0)
                {
                    return OverseasClearFee / (decimal)(Pieces > 0 ? Pieces : SysPieces);
                }
                return 0;
            }
        }

        /// <summary>
        /// 平均估计每Kg头程费用
        /// </summary>
        public decimal FirstLegUnitPrice
        {
            get; set;
        }

        /// <summary>
        /// 平均估计每Kg国外清关费用
        /// </summary>
        public decimal ClearanceUnitWeightPrice
        {
            get; set;
        }

        /// <summary>
        /// 平均估计每票国外清关费用
        /// </summary>
        public decimal ClearanceUnitPiecesPrice
        {
            get; set;
        }

        /// <summary>
        /// 平均估计每Kg国内报关费用
        /// </summary>
        public decimal DeclareUnitPrice
        {
            get; set;
        }

        /// <summary>
        /// 汇总估计每Kg费用
        /// </summary>
        public decimal AvgEstimateWeightSum
        {
            get; set;
        }

        public string Destination
        {
            get; set;
        }

        public string ServiceName
        {
            get; set;
        }
        public decimal FirstTransferPrice { get; set; }
        public decimal AvgFirstTransferPrice
        {
            get
            {
                if (Weight > 0 || SysWeight > 0)
                {
                    return FirstTransferPrice / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                }
                return 0;
            }
        }
        public decimal SecondTransferPrice { get; set; }
        public decimal AvgSecondTransferPrice
        {
            get
            {
                if (Weight > 0 || SysWeight > 0)
                {
                    return SecondTransferPrice / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                }
                return 0;
            }
        }
        public decimal OverSeaTransferPrice { get; set; }
        public decimal AvgOverSeaTransferPrice
        {
            get
            {
                if (Weight > 0 || SysWeight > 0)
                {
                    return OverSeaTransferPrice / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                }
                return 0;
            }
        }

        public decimal TaxPrice { get; set; }
        public decimal AvgTaxPrice
        {
            get
            {
                if (Weight > 0 || SysWeight > 0)
                {
                    return TaxPrice / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                }
                return 0;
            }
        }
        public decimal SubsidyPrice { get; set; }
        public decimal AvgSubsidyPrice
        {
            get
            {
                if (Weight > 0 || SysWeight > 0)
                {
                    return SubsidyPrice / (decimal)(Weight > 0 ? Weight : SysWeight / 1000);
                }
                return 0;
            }
        }
        #region 导出才使用的数据字段
        /// <summary>
        /// 客户报价
        /// </summary>
        [NoDb]
        public string CustomerQuotation { get; set; }
        [NoDb]
        public string CustomerQuotationNote { get; set; }
        /// <summary>
        /// 代理报价
        /// </summary>
        [NoDb]
        public string AgencyQuotation { get; set; }
        [NoDb]
        public string AgencyQuotationNote { get; set; }

        #endregion
    }

    public class Finance_Logistics_LadingBillLogDto
    {
        public string OldPaymentClearFee
        {
            get; set;
        }

        public string NewPaymentClearFee
        {
            get; set;
        }

        public string PaymentClearFee
        {
            get; set;
        }

        public string OldPaymentFristFee
        {
            get; set;
        }

        public string NewPaymentFristFee
        {
            get; set;
        }

        public string PaymentFristFee
        {
            get; set;
        }

        public string OldPayment
        {
            get; set;
        }

        public string NewPayment
        {
            get; set;
        }

        public string Payment
        {
            get; set;
        }

        public DateTime CreateTime
        {
            get; set;
        }
    }


    public class Finance_Logistics_LadingBillLog : BaseLogEntity
    {
        public string Remark { get; set; }
    }

    public class FinanceLadingBillDto : Finance_Logistics_LadingBill
    {

        public string DataBindRole { get; set; }
        public List<Finance_Incidental> IncidentalFees
        {
            get; set;
        }

        public FinanceIncidentalTypeEnum Type
        {
            get; set;
        }
    }




    [TrackTable(typeof(Finance_Logistics_LadingBillLog))]
    public class Finance_Logistics_LadingBill : BaseEntity
    {

        public string DataBindRole
        {
            get; set;
        }

        public decimal CustomerIncome
        {
            get; set;
        }

        public decimal DeliveryCost
        {
            get; set;
        }
        public decimal Cost
        {
            get; set;
        }

        public string DeliveryCostCurreny
        {
            get; set;
        }

        public DateTime? LastUpDateCostTime
        {
            get; set;
        }


        /// <summary>
        /// 头程付款状态
        /// </summary>
        public PaymentStatus PaymentFristFeeStatus
        {
            get; set;
        }

        /// <summary>
        /// 报关付款状态
        /// </summary>
        public PaymentStatus PaymentDomesticClearFeeStatus
        {
            get; set;
        }

        /// <summary>
        /// 清关付款状态
        /// </summary>
        public PaymentStatus PaymentOverseasClearFeeStatus
        {
            get; set;
        }

        /// <summary>
        /// 客户收款状态
        /// </summary>
        public PaymentStatus CusetomerChequesStatus
        {
            get; set;
        }
        /// <summary>
        /// 一级中转收款状态
        /// </summary>
        public PaymentStatus PaymentFirstTransferStatus
        {
            get; set;
        }
        /// <summary>
        /// 二级中转收款状态
        /// </summary>
        public PaymentStatus PaymentSecondTransferStatus
        {
            get; set;
        }
        /// <summary>
        /// 关税收款状态
        /// </summary>
        public PaymentStatus PaymentTaxStatus
        {
            get; set;
        }
        /// <summary>
        /// 海外中转收款状态
        /// </summary>
        public PaymentStatus PaymentOverSeaTransferStatus
        {
            get; set;
        }
        /// <summary>
        /// 补贴收款状态
        /// </summary>
        public PaymentStatus PaymentSubsidyStatus
        {
            get; set;
        }

        [Track("备注")]
        public new string Remark
        {
            get; set;
        }

        public DateTime? CustomerBillTime
        {
            get; set;
        }

        public DateTime? FristBillTime
        {
            get; set;
        }

        public DateTime? OverseasClearBillTime
        {
            get; set;
        }

        public DateTime? DomesticClearBillTime
        {
            get; set;
        }

        public int ChannelId
        {
            get; set;
        }

        public string CustomerName
        {
            get; set;
        }


        public string BillNumber
        {
            get; set;
        }

        public BillType BillType
        {
            get; set;
        }

        public string _Destination
        {
            get; set;
        }

        public string Departure
        {
            get; set;
        }

        public string FristServiceName
        {
            get; set;
        }


        public string OverseasClearServiceName
        {
            get; set;
        }

        public string DomesticClearServiceName
        {
            get; set;
        }


        public decimal FristFee
        {
            get; set;
        }

        public decimal DomesticClearFee
        {
            get; set;
        }


        public decimal OverseasClearFee
        {
            get; set;
        }


        public string OverseasClearCurreny
        {
            get; set;
        }


        public int BoxQty
        {
            get; set;
        }

        public decimal Weight
        {
            get; set;
        }

        /// <summary>
        /// 毛重
        /// </summary>
        public decimal GrossWeight
        {
            get; set;
        }

        /// <summary>
        /// 体积重
        /// </summary>
        public decimal VolumeWeight
        {
            get; set;
        }

        public int Pieces
        {
            get; set;
        }

        public string FristFileUrl
        {
            get; set;
        }

        public string DomesticClearFileUrl
        {
            get; set;
        }
        public string OverseasClearFileUrl
        {
            get; set;
        }

        [Track("支付头程")]
        public decimal PaymentFristFee
        {
            get; set;
        }

        [Track("支付国内清关")]
        public decimal PaymentDomesticClearFee
        {
            get; set;
        }


        [Track("支付海外清关")]
        public decimal PaymentOverseasClearFee
        {
            get; set;
        }

        [Track("支付一级中转费用")]
        public decimal PaymentFirstTransferFee { get; set; }
        [Track("支付二级中转费用")]
        public decimal PaymentSecondTransferFee { get; set; }
        [Track("支付关税")]
        public decimal PaymentTaxFee { get; set; }
        [Track("支付海外中转费用")]
        public decimal PaymentOverseaTransferFee { get; set; }
        [Track("支付补贴")]
        public decimal PaymentSubsidy { get; set; }


        /// <summary>
        /// 客户费用
        /// </summary>
        public decimal CusetomerFee
        {
            get; set;
        }

        /// <summary>
        /// 客户已付费用
        /// </summary>
        [Track("客户已付费用")]
        public decimal CusetomerCheques
        {
            get; set;
        }

        public string FristCurrency
        {
            get; set;
        }

        public string DomesticClearCurrency
        {
            get; set;
        }

        public string CustomerIncomeCurrency
        {
            get; set;
        }

        #region 一级中转
        public DateTime? FirstTransferBillTime
        {
            get; set;
        }
        public decimal FirstTransferFee
        {
            get; set;
        }

        public string FirstTransferFileUrl
        {
            get; set;
        }

        public string FirstTransferServiceName
        {
            get; set;
        }
        #endregion

        #region 二级中转
        public DateTime? SecondTransferBillTime
        {
            get; set;
        }
        public decimal SecondTransferFee
        {
            get; set;
        }

        public string SecondTransferFileUrl
        {
            get; set;
        }

        public string SecondTransferServiceName
        {
            get; set;
        }
        #endregion

        #region 关税
        public DateTime? TaxBillTime
        {
            get; set;
        }
        public decimal TaxFee
        {
            get; set;
        }

        public string TaxFileUrl
        {
            get; set;
        }

        public string TaxServiceName
        {
            get; set;
        }
        public string TaxFeeCurrency
        {
            get; set;
        }
        #endregion

        #region 海外中转
        public DateTime? OverSeaTransferBillTime
        {
            get; set;
        }
        public decimal OverSeaTransferFee
        {
            get; set;
        }

        public string OverSeaTransferFileUrl
        {
            get; set;
        }

        public string OverSeaTransferServiceName
        {
            get; set;
        }
        public string OverSeaTransferFeeCurrency
        {
            get; set;
        }
        #endregion

        #region 补贴
        public DateTime? SubsidyBillTime
        {
            get; set;
        }
        public decimal SubsidyFee
        {
            get; set;
        }

        public string SubsidyFileUrl
        {
            get; set;
        }

        public string SubsidyServiceName
        {
            get; set;
        }
        public string SubsidyCurrency
        {
            get; set;
        }
        #endregion

        #region 客户监控
        public int CollectionBillStatus { get; set; }
        public string ShipRoute { get; set; }
        public string Salesman { get; set; }
        public string Airline { get; set; }
        public string ClearanceNote { get; set; }
        public string FlightNumber { get; set; }
        public decimal? DeliveryWeight { get; set; }
        public decimal? DeliveryVolume { get; set; }
        public decimal? PoundWeight { get; set; }
        public DateTime? BookedOffTime { get; set; }
        public DateTime? ActualBookedOffTime { get; set; }
        public string CustomerMonitoringRemarks { get; set; }
        public string IsForecast { get; set; }
        public decimal? TypeWeight { get; set; }
        #endregion
    }
}
