using System; using System.Collections.Generic; using System.Linq; using System.Text; using Newtonsoft.Json; using NPoco; using POSV.Entity; namespace POSV.ShoppingCart { [Serializable] [JsonObject(MemberSerialization.OptIn)] [TableName("pos_order_item_promotion")] [PrimaryKey(new string[] { "id" } , AutoIncrement = false)] public class PromotionItem : BaseEntity,IEqualityComparer { public PromotionItem() { } /// /// 租户ID /// [JsonProperty(PropertyName = "tenantId")] [Column("tenantId")] public string TenantId { get; set; } /// /// 订单ID /// [JsonProperty(PropertyName = "orderId")] [Column("orderId")] public string OrderId { get; set; } /// /// 订单号 /// [JsonProperty(PropertyName = "tradeNo")] [Column("tradeNo")] public string TradeNo { get; set; } /// /// ItemId /// [JsonProperty(PropertyName = "itemId")] [Column("itemId")] public string ItemId { get; set; } /// /// 优惠类型 /// [JsonProperty(PropertyName = "promotionType")] [Column("promotionType")] public PromotionType PromotionType { get; set; } /// /// 优惠前的金额 /// [JsonProperty(PropertyName = "amount")] [Column("amount")] public decimal Amount { get; set; } /// /// 优惠金额 /// [JsonProperty(PropertyName = "discountAmount")] [Column("discountAmount")] public decimal DiscountAmount { get; set; } /// /// 优惠后的金额 /// [JsonProperty(PropertyName = "receivableAmount")] [Column("receivableAmount")] public decimal ReceivableAmount { get; set; } /// /// 优惠率 /// [JsonProperty(PropertyName = "discountRate")] [Column("discountRate")] public decimal DiscountRate { get; set; } /// /// 是否启用该优惠 /// [JsonProperty(PropertyName = "enabled")] [Column("enabled")] public bool Enabled { get; set; } = false; /// /// 整单优惠分摊对应的关系 /// [JsonProperty(PropertyName = "relationId")] [Column("relationId")] public string RelationId { get; set; } = string.Empty; /// /// 订单完成时间(格式:yyyy-MM-dd HH:mm:ss) /// [JsonProperty(PropertyName = "finishDate")] [Column("finishDate")] public string FinishDate { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); /// /// 方案编号 /// [JsonProperty(PropertyName = "planNo")] [Column("planNo")] public string PlanNo { get; set; } /// /// 议价的价格,用于单品议价优惠计算 /// [Ignore] public decimal DiscountPrice { get; set; } private string _planName = string.Empty; /// /// 方案名称 /// [JsonProperty(PropertyName = "planName")] [Column("planName")] public string PlanName { get { if (string.IsNullOrEmpty(_planName)) { return this.PromotionType.ToString(); } else { return _planName; } } set { _planName = value; } } /// /// 扩展字段1 /// [JsonProperty(PropertyName = "ext1")] [Column("ext1")] public string Ext1 { get; set; } /// /// 优惠券ID /// [Ignore] public string CouponId { get; set; } public override string ToString() { return string.Format("{0},优惠{1}元",this.PromotionType.ToString(),this.DiscountAmount.ToString("0.00")); } public bool Equals(PromotionItem x , PromotionItem y) { return x.Id.Equals(y.Id); } public int GetHashCode(PromotionItem obj) { if (obj == null) return 0; return obj.GetHashCode(); } /// /// 套餐主菜的优惠 /// [Ignore] public decimal MainProductRate { get; set; } } public enum PromotionType { None = -1, 赠送 = 0, 折扣 = 1, 优惠券 = 2, 会员价 = 3, 满减 = 4, 满送 = 5, 议价 = 6, 兑换 = 7, 立减 = 8, 整单立减 = 9, 免单 = 10, 会员等级优惠 = 11, 做法折扣 = 12, 整单折扣 = 21, 整单议价= 26, 外卖扣费=30, 企迈订单优惠 = 31, 道菜分摊 = 50, 卡友日 = 60, 满减促销 = 61, 商品促销 = 62, 实体优惠券 = 63, 双数特价优惠 = 64, 双数特价赠送 = 65, 商品优惠券 = 66, 电子代金券 = 80, 电子折扣券 = 81, 电子兑换券 = 82, 电子商品券 = 83, 美团团购券 = 90, } }