using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Atomx.Common.Entities
{
    /// <summary>
    /// 订单
    /// </summary>
    [Table("Orders")]
    public class Order
    {
        // <summary>
        /// 数据ID
        /// </summary>
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 订单号
        /// </summary>
        public long OrderNumber { get; set; }

        /// <summary>
        /// 平台ID，1自有商城，2淘宝，3天猫，4京东，5拼多多，6抖音，7快手，8小红书等
        /// </summary>
        public int PlatformId { get; set; }

        /// <summary>
        /// 平台订单号
        /// </summary>
        public long PlatformOrderNumber { get; set; }

        /// <summary>
        /// 订单类型
        /// </summary>
        public int Type { get; set; }

        /// <summary>
        /// 是否虚拟数据
        /// </summary>
        public bool IsVirtual { get; set; }

        /// <summary>
        /// 订单商品供应商ID
        /// </summary>
        public long VendorId { get; set; }

        /// <summary>
        /// 成交店铺ID
        /// </summary>
        public long StoreId { get; set; }

        /// <summary>
        /// 归属公司ID
        /// </summary>
        public long CorporationId { get; set; }

        /// <summary>
        /// 销售人员Id
        /// </summary>
        public long SalespersonId { get; set; }

        /// <summary>
        /// 下单用户
        /// </summary>
        public long UserId { get; set; }

        /// <summary>
        /// 收件人姓名
        /// </summary>
        [Column(TypeName = "varchar(128)")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 邮件地址
        /// </summary>
        [Column(TypeName = "varchar(255)")]
        public string Email { get; set; } = string.Empty;

        /// <summary>
        /// 电话号码
        /// </summary>
        [Column(TypeName = "varchar(20)")]
        public string Phone { get; set; } = string.Empty;

        /// <summary>
        /// 公司
        /// </summary>
        [Column(TypeName = "varchar(255)")]
        public string Company { get; set; } = string.Empty;

        /// <summary>
        /// 国家ID
        /// </summary>
        public long CountryId { get; set; }

        /// <summary>
        /// 国家
        /// </summary>
        [Column(TypeName = "varchar(50)")]
        public string Country { get; set; } = string.Empty;

        /// <summary>
        /// 省份
        /// </summary>
        public long ProvinceId { get; set; }

        /// <summary>
        /// 省、州
        /// </summary>
        [Column(TypeName = "varchar(100)")]
        public string Province { get; set; } = string.Empty;

        /// <summary>
        /// 城市
        /// </summary>
        public long CityId { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        [Column(TypeName = "varchar(100)")]
        public string City { get; set; } = string.Empty;

        /// <summary>
        /// 地区
        /// </summary>
        public long RegionId { get; set; }

        /// <summary>
        /// 地区街
        /// </summary>
        [Column(TypeName = "varchar(100)")]
        public string Region { get; set; } = string.Empty;

        /// <summary>
        /// 邮政编码
        /// </summary>
        [Column(TypeName = "varchar(15)")]
        public string PostalCode { get; set; } = string.Empty;

        /// <summary>
        /// 详细地址
        /// </summary>
        [Column(TypeName = "varchar(256)")]
        public string AddressDetails { get; set; } = string.Empty;

        /// <summary>
        /// 完整地址
        /// </summary>
        [Column(TypeName = "varchar(1024)")]
        public string FullAddress { get; set; } = string.Empty;

        /// <summary>
        /// 地址所在经度
        /// </summary>
        [Column(TypeName = "decimal(10,6)")]
        public decimal Longitude { get; set; }

        /// <summary>
        /// 地址所在纬度
        /// </summary>
        [Column(TypeName = "decimal(10,6)")]
        public decimal Latitude { get; set; }

        /// <summary>
        /// 订单原市场总价
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]

        public decimal TotalMarketPrice { get; set; }

        /// <summary>
        /// 商品销售总价
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]

        public decimal TotalPrice { get; set; }

        /// <summary>
        /// 折扣总额
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal DiscountAmount { get; set; }

        /// <summary>
        /// 订单总价
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal OrderPrice { get; set; }

        /// <summary>
        /// 订单个数
        /// </summary>
        public int ProductCount { get; set; }

        /// <summary>
        /// 购买产品总数量
        /// </summary>
        public int TotalQuantity { get; set; }

        /// <summary>
        /// 税费
        /// </summary>
        [Column(TypeName = "decimal(8,4)")]
        public decimal Taxes { get; set; }

        /// <summary>
        /// 运费
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal ShippingCost { get; set; }

        /// <summary>
        /// 订单使用的优惠券ID
        /// </summary>
        public long CouponId { get; set; }

        /// <summary>
        /// 客户支付单ID
        /// </summary>
        public long OrderPaymentId { get; set; }

        /// <summary>
        /// 付款方式，支付通道
        /// </summary>
        public int PaymentChannel { get; set; }

        /// <summary>
        /// 订单实付总额
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal PaymentAmount { get; set; }

        /// <summary>
        /// 支付状态
        /// </summary>
        public int PaymentStatus { get; set; }

        /// <summary>
        /// 付款时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? PaymentTime { get; set; }

        /// <summary>
        /// 卖家利润
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal StoreProfit { get; set; }

        /// <summary>
        /// 卖家店铺是否提货
        /// </summary>
        public bool StorePickedUp { get; set; }

        /// <summary>
        /// 卖点店铺提货时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? StorePickedUpTime { get; set; }

        /// <summary>
        /// 卖家回款时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? StorePaybackTime { get; set; }

        /// <summary>
        /// 卖家订单利润结算时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? StoreProfitSettlementTime { get; set; }

        /// <summary>
        /// 供应商是否确认订单
        /// </summary>
        public bool IsConfirmed { get; set; }

        /// <summary>
        /// 供应商订单确认时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? ConfirmedTime { get; set; }

        /// <summary>
        /// 是否已评论
        /// </summary>
        public bool Reviewed { get; set; }

        /// <summary>
        /// 扩展信息
        /// </summary>
        [Column(TypeName = "text")]
        public string Extended { get; set; } = string.Empty;

        /// <summary>
        /// 订单状态，（待付款，待发货，待签收，待结算，订单取消，订单过期，支付失败）
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 订单备注说明
        /// </summary>
        [Column(TypeName = "varchar(255)")]
        public string? Remark { get; set; } = string.Empty;

        /// <summary>
        /// 卖家下单备注信息
        /// </summary>
        [Column(TypeName = "varchar(255)")]
        public string? Message { get; set; } = string.Empty;

        /// <summary>
        /// 物流快递公司编号
        /// </summary>
        public long ExpressId { get; set; }

        /// <summary>
        /// 快递公司
        /// </summary>
        [Column(TypeName = "varchar(25)")]
        public string ExpressName { get; set; } = string.Empty;

        /// <summary>
        /// 快递单号
        /// </summary>
        [Column(TypeName = "varchar(30)")]
        public string WaybillNumber { get; set; } = string.Empty;

        /// <summary>
        /// 发货状态
        /// </summary>
        public int DeliveryStatus { get; set; }

        /// <summary>
        /// 发货时间
        /// </summary>
        [Column(TypeName = "timestamptz")]

        public DateTime? DeliveryTime { get; set; }

        /// <summary>
        /// 包裹签收时间
        /// </summary>
        [Column(TypeName = "timestamptz")]

        public DateTime? SigningTime { get; set; }

        /// <summary>
        /// 下单时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? UpdateTime { get; set; }
    }
}
