You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
225 lines
5.7 KiB
C#
225 lines
5.7 KiB
C#
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<PromotionItem>
|
|
{
|
|
public PromotionItem()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 租户ID
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "tenantId")]
|
|
[Column("tenantId")]
|
|
public string TenantId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 订单ID
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "orderId")]
|
|
[Column("orderId")]
|
|
public string OrderId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 订单号
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "tradeNo")]
|
|
[Column("tradeNo")]
|
|
public string TradeNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// ItemId
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "itemId")]
|
|
[Column("itemId")]
|
|
public string ItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠类型
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "promotionType")]
|
|
[Column("promotionType")]
|
|
public PromotionType PromotionType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠前的金额
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "amount")]
|
|
[Column("amount")]
|
|
public decimal Amount { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠金额
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "discountAmount")]
|
|
[Column("discountAmount")]
|
|
public decimal DiscountAmount { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠后的金额
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "receivableAmount")]
|
|
[Column("receivableAmount")]
|
|
public decimal ReceivableAmount { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠率
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "discountRate")]
|
|
[Column("discountRate")]
|
|
public decimal DiscountRate { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否启用该优惠
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "enabled")]
|
|
[Column("enabled")]
|
|
public bool Enabled { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// 整单优惠分摊对应的关系
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "relationId")]
|
|
[Column("relationId")]
|
|
public string RelationId { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 订单完成时间(格式:yyyy-MM-dd HH:mm:ss)
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "finishDate")]
|
|
[Column("finishDate")]
|
|
public string FinishDate { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
/// <summary>
|
|
/// 方案编号
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "planNo")]
|
|
[Column("planNo")]
|
|
public string PlanNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 议价的价格,用于单品议价优惠计算
|
|
/// </summary>
|
|
[Ignore]
|
|
public decimal DiscountPrice { get; set; }
|
|
|
|
|
|
private string _planName = string.Empty;
|
|
/// <summary>
|
|
/// 方案名称
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "planName")]
|
|
[Column("planName")]
|
|
public string PlanName
|
|
{
|
|
get
|
|
{
|
|
if (string.IsNullOrEmpty(_planName))
|
|
{
|
|
return this.PromotionType.ToString();
|
|
}
|
|
else
|
|
{
|
|
return _planName;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_planName = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 扩展字段1
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "ext1")]
|
|
[Column("ext1")]
|
|
public string Ext1 { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠券ID
|
|
/// </summary>
|
|
[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();
|
|
}
|
|
/// <summary>
|
|
/// 套餐主菜的优惠
|
|
/// </summary>
|
|
[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,
|
|
}
|
|
}
|