117 lines
3.2 KiB
C#
117 lines
3.2 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Dlhis.Entity.Canteen.Enums;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
|
|
namespace Dlhis.Canteen.Order.Request;
|
|
|
|
public class BalanceHainingImportRequest : IValidatableObject
|
|
{
|
|
/// <summary>
|
|
/// 工号
|
|
/// </summary>
|
|
[Required(ErrorMessage = "工号不可为空")]
|
|
public string UserCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 流水号
|
|
/// </summary>
|
|
[Required(ErrorMessage = "流水号不可为空")]
|
|
public string No { get; set; }
|
|
|
|
/// <summary>
|
|
/// 设备号
|
|
/// </summary>
|
|
public string DeviceUniqueNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 金额
|
|
/// </summary>
|
|
public decimal Amount { get; set; }
|
|
|
|
/// <summary>
|
|
/// 消费数据类型
|
|
/// </summary>
|
|
[Required]
|
|
[EnumDataType(typeof(CanteenApplicationTypeEnumType), ErrorMessage = "消费数据类型有误")]
|
|
public CanteenApplicationTypeEnumType ApplicationType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 餐次
|
|
/// </summary>
|
|
[Required]
|
|
[EnumDataType(typeof(ShiftEnumType), ErrorMessage = "餐次类型有误")]
|
|
public ShiftEnumType ShiftType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 营业点
|
|
/// </summary>
|
|
public string BusinessPlaceCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 消费类型 0:消费, 1:充值
|
|
/// </summary>
|
|
[Required]
|
|
[EnumDataType(typeof(BalanceRecordTypeEnumType), ErrorMessage = "消费类型有误")]
|
|
public BalanceRecordTypeEnumType Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// 消费来源
|
|
/// </summary>
|
|
[EnumDataType(typeof(BalanceRecordSourceEnumType), ErrorMessage = "消费来源有误")]
|
|
public BalanceRecordSourceEnumType Source { get; set; }
|
|
|
|
/// <summary>
|
|
/// 成本日期
|
|
/// </summary>
|
|
[Required]
|
|
public DateTime CostDate { get; set; }
|
|
|
|
/// <summary>
|
|
/// 消费时间
|
|
/// </summary>
|
|
[Required]
|
|
public DateTime CostDateTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 厂区
|
|
/// </summary>
|
|
[Required(ErrorMessage = "厂区不可为空")]
|
|
public string Factory { get; set; }
|
|
|
|
/// <summary>
|
|
/// 备注
|
|
/// </summary>
|
|
[Required(ErrorMessage = "备注不可为空")]
|
|
public string Remark { get; set; }
|
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (Type == BalanceRecordTypeEnumType.Out)
|
|
{
|
|
Amount = -Math.Abs(Amount);
|
|
|
|
if (DeviceUniqueNo.IsEmpty())
|
|
{
|
|
yield return new ValidationResult("消费设备号不能为空", new[] { nameof(DeviceUniqueNo) });
|
|
}
|
|
|
|
if (ApplicationType != CanteenApplicationTypeEnumType.Device)
|
|
{
|
|
yield return new ValidationResult("仅支持设备消费", new[] { nameof(ApplicationType) });
|
|
}
|
|
|
|
if (BusinessPlaceCode.IsEmpty())
|
|
{
|
|
yield return new ValidationResult("营业掉不可为空", new[] { nameof(BusinessPlaceCode) });
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ApplicationType != CanteenApplicationTypeEnumType.MealSupplement)
|
|
{
|
|
yield return new ValidationResult("只支持餐补充值", new[] { nameof(ApplicationType) });
|
|
}
|
|
}
|
|
}
|
|
} |