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

namespace Atomx.Common.Entities
{
    /// <summary>
    /// 订单详情数据
    /// </summary>
    [Table("OrderItems")]
    public class OrderItem
    {
        /// <summary>
        /// 订单商品明细ID
        /// </summary>
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 订单ID
        /// </summary>
        public long OrderId { get; set; }

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

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

        /// <summary>
        /// 仓库ID
        /// </summary>
        public long WarehouseId { get; set; }

        /// <summary>
        /// 产品ID
        /// </summary>
        public long ProductId { get; set; }

        /// <summary>
        /// 商城产品信息ID
        /// </summary>
        public long ProductListingId { get; set; }

        /// <summary>
        /// 销售产品的店铺ID
        /// </summary>
        public long StoreId { get; set; }

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

        /// <summary>
        /// SKU ID，0则表示无SKU ID
        /// </summary>
        public long SkuId { get; set; }

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

        /// <summary>
        /// 品牌ID
        /// </summary>
        public long ManufacturerId { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        [Column(TypeName = "varchar(255)")]
        public string Title { get; set; } = string.Empty;

        /// <summary>
        /// 商品封面图
        /// </summary>
        [Column(TypeName = "varchar(256)")]
        public string Image { get; set; } = string.Empty;

        /// <summary>
        /// 购买数量
        /// </summary>
        public int Quantity { get; set; }

        /// <summary>
        /// 是否允许退货
        /// </summary>
        public bool AllowReturn { get; set; }

        /// <summary>
        /// 是否允许换货
        /// </summary>
        public bool AllowExchange { get; set; }

        /// <summary>
        /// SKU数据 JSON信息
        /// </summary>
        [Column(TypeName = "text")]
        public string AttributesJson { get; set; } = string.Empty;

        /// <summary>
        /// 产品SKU编码
        /// </summary>
        [Column(TypeName = "varchar(20)")]
        public string SkuNumber { get; set; } = string.Empty;

        /// <summary>
        /// 运费模板ID,0表示全国免费包邮
        /// </summary>
        public long ShippingId { get; set; }

        /// <summary>
        /// 发货省份
        /// </summary>
        public long ProvinceId { get; set; }
        /// <summary>
        /// 发货城市
        /// </summary>

        public long CityId { get; set; }

        /// <summary>
        /// 市场价
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal MarketPrice { get; set; }

        /// <summary>
        /// 成本价单价
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal? ProductCost { get; set; }

        /// <summary>
        /// 销售价
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal Price { get; set; }

        /// <summary>
        /// 分摊优惠金额单价
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal DiscountAmount { get; set; }

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

        /// <summary>
        /// 售后状态
        /// </summary>
        public int AfterSalesStatus { get; set; }

        /// <summary>
        /// 售后退款金额
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal RefundAmount { get; set; }

        /// <summary>
        /// 是否已晒单
        /// </summary>
        public bool Reviewed { get; set; }

        /// <summary>
        /// 商品留言
        /// </summary>
        [Column(TypeName = "varchar(100)")]
        public string? Message { get; set; } = string.Empty;

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