申请单获取费用明细时增加费用对象维度

dev
嵇文龙 3 months ago
parent 4aeee28be4
commit 496d8cf27e

@ -17,7 +17,7 @@ namespace DS.WMS.Core.Application.Dtos
/// <summary>
/// 业务信息
/// </summary>
public List<BizItem> Items { get; set; } = [];
public List<FeeClient> Items { get; set; } = [];
/// <summary>
/// 汇率转换信息

@ -0,0 +1,94 @@
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; }
}
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; }
}
}

@ -36,7 +36,7 @@ namespace DS.WMS.Core.Application.Interface
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params BizItem[] items);
Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params FeeClient[] items);
/// <summary>
/// 删除发票明细

@ -36,7 +36,7 @@ namespace DS.WMS.Core.Application.Interface
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
Task<DataResult<PaymentApplicaitonBiz>> GetFeesAsync(params BizItem[] items);
Task<DataResult<PaymentApplicaitonBiz>> GetFeesAsync(IEnumerable<FeeClient> items);
/// <summary>
/// 设置是否收到发票
@ -46,6 +46,5 @@ namespace DS.WMS.Core.Application.Interface
/// <returns></returns>
Task<DataResult> SetInvoiceReceivedAsync(bool isInvoiceReceived, params long[] ids);
}
}

@ -176,7 +176,7 @@ namespace DS.WMS.Core.Application.Method
var query1 = TenantDb.Queryable<SeaExport>()
.InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
.Where((s, f) => f.FeeStatus == FeeStatus.AuditPassed)
.GroupBy((s, f) => s.Id)
.GroupBy((s, f) => new { s.Id, f.CustomerId })
.Select((s, f) => new BizInvoiceApplication
{
Id = s.Id,
@ -231,10 +231,11 @@ namespace DS.WMS.Core.Application.Method
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params BizItem[] items)
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params FeeClient[] items)
{
var bizIds = items.Select(x => x.Id).ToList();
var types = items.Select(x => x.BusinessType).ToList();
var bizIds = items.Select(x => x.Id).Distinct();
var types = items.Select(x => x.BusinessType).Distinct();
var cIds = items.Select(x => x.CustomerId).Distinct();
var list = await TenantDb.Queryable<FeeRecord>()
.Where(f => bizIds.Contains(f.BusinessId) && types.Contains(f.BusinessType) && f.FeeStatus == FeeStatus.AuditPassed)
@ -412,11 +413,12 @@ namespace DS.WMS.Core.Application.Method
protected override async Task<List<ApplicationDetail>> GetDetailsAsync(ApplicationRequest<InvoiceApplication> request)
{
var ids1 = request.Items.Select(x => x.Id);
var ids2 = request.Items.Select(x => x.BusinessType);
var ids1 = request.Items.Select(x => x.Id).Distinct();
var ids2 = request.Items.Select(x => x.BusinessType).Distinct();
var ids3 = request.Items.Select(x => x.CustomerId).Distinct();
var list = await TenantDb.Queryable<FeeRecord>().Where(x =>
ids1.Contains(x.BusinessId) && ids2.Contains(x.BusinessType) && x.FeeStatus == FeeStatus.AuditPassed)
var list = await TenantDb.Queryable<FeeRecord>().Where(x => x.FeeStatus == FeeStatus.AuditPassed &&
ids1.Contains(x.BusinessId) && ids2.Contains(x.BusinessType) && ids3.Contains(x.CustomerId))
.Where(request.GetQueryConditions(Db))
.Select(x => new ApplicationDetail
{

@ -8,7 +8,6 @@ using DS.WMS.Core.Application.Interface;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using SqlSugar;
@ -123,15 +122,11 @@ namespace DS.WMS.Core.Application.Method
/// <returns></returns>
public async Task<DataResult<List<BizPaymentApplication>>> GetBizListAsync(PageRequest request)
{
var queryList = CreateBizQuery();
var query = CreateBizQuery();
var whereList = request.GetConditionalModels(Db);
query = query.Where(whereList);
if (!request.QueryCondition.IsNullOrEmpty())
{
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
queryList = queryList.Where(whereList);
}
var result = await queryList.ToQueryPageAsync(request.PageCondition);
var result = await query.ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0)
{
@ -164,17 +159,17 @@ namespace DS.WMS.Core.Application.Method
var query1 = TenantDb.Queryable<SeaExport>()
.InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
.Where((s, f) => f.FeeStatus == FeeStatus.AuditPassed)
.GroupBy((s, f) => s.Id)
.GroupBy((s, f) => new { s.Id, f.CustomerId })
.Select((s, f) => new BizPaymentApplication
{
Id = s.Id,
BusinessType = BusinessType.OceanShippingExport,
CustomerNo = s.CustomerNo, //委托编号
ClientName = s.CustomerName, //委托单位
MBLNO = s.MBLNO,
HBLNO = s.HBLNO,
CustomerId = s.CustomerId,
CustomerName = s.CustomerName,//结费单位
ClientName = s.CustomerName, //委托单位
CustomerId = f.CustomerId,
CustomerName = f.CustomerName, //结费单位
AccountDate = s.AccountDate,
BookingNO = s.BookingNo, //订舱编号
CntrTotal = s.CntrTotal,
@ -196,12 +191,14 @@ namespace DS.WMS.Core.Application.Method
f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount)),
UnpaidOther = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
f.FeeType == FeeType.Payable && f.Currency != FeeCurrency.USD_CODE && f.Currency != FeeCurrency.RMB_CODE).Select(f => SqlFunc.AggregateSum(f.Amount)),
UnreceivedRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
f.FeeType == FeeType.Receivable && f.Currency == FeeCurrency.RMB_CODE).Select(f => SqlFunc.AggregateSum(f.Amount)),
UnreceivedUSD = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
f.FeeType == FeeType.Receivable && f.Currency == FeeCurrency.USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount)),
UnreceivedOther = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
f.FeeType == FeeType.Receivable && f.Currency != FeeCurrency.USD_CODE && f.Currency != FeeCurrency.RMB_CODE).Select(f => SqlFunc.AggregateSum(f.Amount)),
UnpaidRMBInv = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
f.FeeType == FeeType.Payable && f.Currency == FeeCurrency.RMB_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount)),
UnpaidUSDInv = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed &&
@ -219,13 +216,15 @@ namespace DS.WMS.Core.Application.Method
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
public async Task<DataResult<PaymentApplicaitonBiz>> GetFeesAsync(params BizItem[] items)
public async Task<DataResult<PaymentApplicaitonBiz>> GetFeesAsync(IEnumerable<FeeClient> items)
{
var bizIds = items.Select(x => x.Id).ToList();
var types = items.Select(x => x.BusinessType).ToList();
var ids = items.Select(x => x.Id).Distinct();
var types = items.Select(x => x.BusinessType).Distinct();
var cIds = items.Select(x => x.CustomerId).Distinct();
var list = await TenantDb.Queryable<FeeRecord>()
.Where(f => bizIds.Contains(f.BusinessId) && types.Contains(f.BusinessType) && f.FeeStatus == FeeStatus.AuditPassed)
.Where(f => ids.Contains(f.BusinessId) && types.Contains(f.BusinessType) &&
cIds.Contains(f.CustomerId) && f.FeeStatus == FeeStatus.AuditPassed)
.Select(f => new FeePaymentDto
{
RecordId = f.Id,
@ -381,11 +380,12 @@ namespace DS.WMS.Core.Application.Method
protected override async Task<List<ApplicationDetail>> GetDetailsAsync(ApplicationRequest<PaymentApplication> request)
{
var ids1 = request.Items.Select(x => x.Id);
var ids2 = request.Items.Select(x => x.BusinessType);
var ids1 = request.Items.Select(x => x.Id).Distinct();
var ids2 = request.Items.Select(x => x.BusinessType).Distinct();
var ids3 = request.Items.Select(x => x.CustomerId).Distinct();
var list = await TenantDb.Queryable<FeeRecord>().Where(x =>
ids1.Contains(x.BusinessId) && ids2.Contains(x.BusinessType) && x.FeeStatus == FeeStatus.AuditPassed)
var list = await TenantDb.Queryable<FeeRecord>().Where(x => x.FeeStatus == FeeStatus.AuditPassed &&
ids1.Contains(x.BusinessId) && ids2.Contains(x.BusinessType) && ids3.Contains(x.CustomerId))
.Where(request.GetQueryConditions(Db))
.Select(x => new ApplicationDetail
{
@ -563,7 +563,7 @@ namespace DS.WMS.Core.Application.Method
}
}
}
}
protected override DataResult PreSubmitApproval(List<PaymentApplication> applications)

@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Op.Entity;
namespace DS.WMS.Core.Fee.Dtos
@ -56,51 +56,6 @@ namespace DS.WMS.Core.Fee.Dtos
public List<BizItem> Items { get; set; }
}
public class BizItem
{
public static readonly BizItemComparer DefaultComparer = new BizItemComparer();
/// <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;
}
}
}
public class BizOperation
{
/// <summary>
/// 请求值object类型根据业务按需传值
/// </summary>
public object Value { get; set; }
/// <summary>
/// 业务ID与类型
/// </summary>
public List<BizItem> Items { get; set; }
}
public class AuditDetailRequest : BizItem
{
public string? QueryCondition { get; set; }

@ -748,7 +748,7 @@ namespace DS.WMS.Core.Fee.Method
BillAuditStatus = x.BillAuditStatus
}).FirstAsync();
if (biz == null)
return DataResult.Failed(MultiLanguageConst.Operation_Failed);
return DataResult.Failed(MultiLanguageConst.EmptyData);
}
else
{
@ -761,7 +761,7 @@ namespace DS.WMS.Core.Fee.Method
BusinessType = x.BusinessType
}).FirstAsync();
if (fee == null)
return DataResult.Failed(MultiLanguageConst.Operation_Failed);
return DataResult.Failed(MultiLanguageConst.EmptyData);
fee.Reason = callback.RejectReason;
}

@ -21,8 +21,7 @@ namespace DS.WMS.Core.Invoice.Interface
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params BizItem[] items);
Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params FeeClient[] items);
}
}

@ -56,7 +56,7 @@ namespace DS.WMS.Core.Invoice.Method
if (!request.QueryCondition.IsNullOrEmpty())
{
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var whereList = request.GetConditionalModels(Db);
query = query.Where(whereList);
}
@ -120,13 +120,15 @@ namespace DS.WMS.Core.Invoice.Method
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params BizItem[] items)
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync(params FeeClient[] items)
{
var bizIds = items.Select(x => x.Id).ToList();
var types = items.Select(x => x.BusinessType).ToList();
var bizIds = items.Select(x => x.Id).Distinct();
var types = items.Select(x => x.BusinessType).Distinct();
var cIds = items.Select(x => x.CustomerId).Distinct();
var list = await TenantDb.Queryable<FeeRecord>()
.Where(f => bizIds.Contains(f.BusinessId) && types.Contains(f.BusinessType) && AllowedStatus.Contains(f.FeeStatus))
.Where(f => bizIds.Contains(f.BusinessId) && types.Contains(f.BusinessType) && cIds.Contains(f.CustomerId) &&
AllowedStatus.Contains(f.FeeStatus))
.Select(f => new FeeInvoiceDto
{
RecordId = f.Id,

@ -149,8 +149,6 @@ namespace DS.WMS.Core.Invoice.Method
return Task.Factory.StartNew(UpdateInvoiceApplications, new List<Entity.Invoice> { invoice });
}
protected override async Task OnDeleteDetailAsync(List<Entity.Invoice> invoices, DeleteOption deleteOption)
{
var list = invoices.SelectMany(x => x.Details).Where(x => x.DetailId.HasValue).Select(x => new ApplicationDetail

@ -53,7 +53,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
[HttpPost, Route("GetFees")]
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync([FromBody] BizItem[] items)
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync([FromBody] FeeClient[] items)
{
return await _service.GetFeesAsync(items);
}

@ -66,7 +66,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="items">业务ID和类型</param>
/// <returns></returns>
[HttpPost, Route("GetFees")]
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync([FromBody] params BizItem[] items)
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync([FromBody] params FeeClient[] items)
{
if (items == null || items.Length == 0)
return DataResult<InvoiceApplicaitonBiz>.Failed("缺少请求参数");

@ -60,10 +60,10 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary>
/// 根据业务编号及类型获取关联费用记录
/// </summary>
/// <param name="items">业务ID和类型</param>
/// <param name="items"></param>
/// <returns></returns>
[HttpPost, Route("GetFees")]
public async Task<DataResult<PaymentApplicaitonBiz>> GetFeesAsync([FromBody] params BizItem[] items)
public async Task<DataResult<PaymentApplicaitonBiz>> GetFeesAsync([FromBody] params FeeClient[] items)
{
if (items == null || items.Length == 0)
return DataResult<PaymentApplicaitonBiz>.Failed("缺少请求参数");

Loading…
Cancel
Save