using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XYY.ServiceStandard.TrackingService.Model
{
    public class TrackingDto
    {
        public string Id { get { return TrackingNumber; } }
        public string TrackingNumber
        {
            get; set;
        }

        public string LastTrackingNumber
        {
            get; set;
        }

        public int State
        {
            get; set;
        }
        public string Status
        {
            get
            {
                if (State == 7) return "delivered";
                else if (State == 1 || State == 4 || State == 5) return "transitting";
                else if (State == 6) return "exception";
                else if (State == 10) return "failed";
                else return "notFound";
            }
        }
        public string StatusName
        {
            get
            {
                if (Status == "delivered") return "成功签收";
                else if (Status == "transitting") return "运输中";
                else if (Status == "exception") return "异常";
                else if (Status == "failed") return "投递失败";
                else return "查询不到";
            }
        }
        public DateTime? UpdateTime
        {
            get; set;
        }
        public string LatestTime
        {
            get { return UpdateTime?.ToString("yyyy-MM-dd HH:mm:ss"); }
        }

        public string LatestTrack
        {
            get
            {
                if (Logs == null || Logs.Count == 0) return string.Empty;
                else
                {
                    return Logs.OrderByDescending(i => i.TriggerTime).First().StatusString;
                }
            }
        }

        public DateTime? ReceiverTime
        {
            get; set;
        }

        public List<TrackingLogDto> Logs
        {
            get; set;
        }

        public int ChannelId
        {
            get; set;
        }

        public string ReceiverCountryName
        {
            get; set;
        }

        public string SenderCountryName
        {
            get; set;
        }

        /// <summary>
        /// 渠道商名称
        /// </summary>
        public string SerivceCompanName
        {
            get;
            set;
        }

        /// <summary>
        /// 物流的追踪URL
        /// </summary>
        public string TrackingUrl
        {
            get;
            set;
        }
    }
}
