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#

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,
}
}