68 lines
1.6 KiB
C#
68 lines
1.6 KiB
C#
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace Api.Framework.Data.TB
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 优惠券信息数据
|
|||
|
/// </summary>
|
|||
|
public class CouponData
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 优惠券金额
|
|||
|
/// </summary>
|
|||
|
public decimal CouponPrice { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 优惠券条件金额
|
|||
|
/// </summary>
|
|||
|
public decimal ConditionPrice { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 优惠券地址
|
|||
|
/// </summary>
|
|||
|
public string CouponUrl { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 优惠券ID
|
|||
|
/// </summary>
|
|||
|
public string ActivityId { get; set; }
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
public class CouponDataComparer : IComparer<CouponData>
|
|||
|
{
|
|||
|
public int Compare(CouponData x, CouponData y)
|
|||
|
{
|
|||
|
if (x == null || y == null)
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
if (x.ConditionPrice == y.ConditionPrice)
|
|||
|
{
|
|||
|
var result = x.CouponPrice - y.CouponPrice;
|
|||
|
if (result == 0)
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
if (result > 0)
|
|||
|
{
|
|||
|
return -1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return 1;
|
|||
|
}
|
|||
|
}
|
|||
|
else if (x.ConditionPrice > y.ConditionPrice)
|
|||
|
{
|
|||
|
return -1;
|
|||
|
}
|
|||
|
else if (x.ConditionPrice < y.ConditionPrice)
|
|||
|
{
|
|||
|
return 1;
|
|||
|
}
|
|||
|
return -1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|