|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
namespace DS.WMS.Core.Application.Dtos
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 业务ID与类型
|
|
|
/// </summary>
|
|
|
public class BizItem
|
|
|
{
|
|
|
public static readonly BizItemComparer DefaultComparer = new();
|
|
|
|
|
|
/// <summary>
|
|
|
/// 业务ID
|
|
|
/// </summary>
|
|
|
public long Id { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 业务类型
|
|
|
/// </summary>
|
|
|
public BusinessType BusinessType { get; set; }
|
|
|
|
|
|
|
|
|
public class BizItemComparer : IEqualityComparer<BizItem>
|
|
|
{
|
|
|
public bool Equals(BizItem? x, BizItem? y)
|
|
|
{
|
|
|
if (x == null || y == null)
|
|
|
return false;
|
|
|
|
|
|
return x.Id == y.Id && x.BusinessType == y.BusinessType;
|
|
|
}
|
|
|
|
|
|
public int GetHashCode([DisallowNull] BizItem obj)
|
|
|
{
|
|
|
return obj.Id.GetHashCode() ^ (int)obj.BusinessType;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 费用对象/单位
|
|
|
/// </summary>
|
|
|
public class FeeClient : BizItem
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 费用对象ID
|
|
|
/// </summary>
|
|
|
public long CustomerId { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 费用对象名称
|
|
|
/// </summary>
|
|
|
public string? CustomerName { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 汇率信息
|
|
|
/// </summary>
|
|
|
public List<CurrencyExchangeRate>? ExchangeRates { get; set; }
|
|
|
}
|
|
|
|
|
|
public class BizOperation : IValidatableObject
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 请求值(object类型,根据业务按需传值)
|
|
|
/// </summary>
|
|
|
public object Value { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 业务ID与类型
|
|
|
/// </summary>
|
|
|
public List<BizItem>? Items { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 业务ID
|
|
|
/// </summary>
|
|
|
[IgnoreDataMember]
|
|
|
public IEnumerable<long>? Ids => Items?.Select(x => x.Id).Distinct();
|
|
|
|
|
|
/// <summary>
|
|
|
/// 业务类型
|
|
|
/// </summary>
|
|
|
[IgnoreDataMember]
|
|
|
public IEnumerable<BusinessType>? Types => Items?.Select(x => x.BusinessType).Distinct();
|
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
|
{
|
|
|
if (Items == null || Items.Count == 0)
|
|
|
{
|
|
|
yield return new ValidationResult($"缺少请求参数:{nameof(Items)}");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public class BizOperation<T> : BizOperation
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 请求值(根据业务按需传值)
|
|
|
/// </summary>
|
|
|
public new T Value { get; set; }
|
|
|
}
|
|
|
}
|