|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
using SqlSugar;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
namespace DS.WMS.Core.Application.Dtos
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 用于申请/发票/结算的费用明细查询
|
|
|
/// </summary>
|
|
|
public class DetailInquiry
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 业务ID与费用对象的组合
|
|
|
/// </summary>
|
|
|
public List<FeeClient> Items { get; set; } = [];
|
|
|
|
|
|
/// <summary>
|
|
|
/// 费用查询条件
|
|
|
/// </summary>
|
|
|
public string QueryCondition { get; set; } = string.Empty;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取当前实例的查询条件
|
|
|
/// </summary>
|
|
|
/// <param name="client">SqlSugar对象</param>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="ArgumentNullException">当<paramref name="client"/>为null时引发</exception>
|
|
|
public List<IConditionalModel> GetConditionalModels(ISqlSugarClient client)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(QueryCondition))
|
|
|
return [];
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(client, nameof(client));
|
|
|
return client.Utilities.JsonToConditionalModels(QueryCondition);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <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>
|
|
|
/// 业务ID与费用对象的组合
|
|
|
/// </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; }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 业务操作
|
|
|
/// </summary>
|
|
|
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)}");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 业务操作
|
|
|
/// </summary>
|
|
|
public class BizOperation<T> : BizOperation
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 请求值(根据业务按需传值)
|
|
|
/// </summary>
|
|
|
public new T Value { get; set; }
|
|
|
}
|
|
|
}
|