From ca8f7f4043a93f19a81d91382412b11dd5a8bf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Thu, 11 Jul 2024 11:15:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DOnDeleteDetailAsync=E6=9C=AA?= =?UTF-8?q?=E8=83=BD=E6=9B=B4=E6=96=B0=E7=8A=B6=E6=80=81=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.WMS.Core/Settlement/Dtos/FeeItem.cs | 32 +++- .../Settlement/Dtos/PaymentSettlementDto.cs | 4 +- .../IPaymentFreeSettlementService.cs | 24 ++- .../Interface/IPaymentSettlementService.cs | 18 +- .../Method/PaymentFreeSettlementService.cs | 167 +++++++++--------- .../Method/PaymentSettlementService.cs | 134 +++++++------- .../Settlement/Method/SettlementService`1.cs | 27 +-- .../PaymentFreeSettlementController.cs | 41 ++++- .../PaymentSettlementController.cs | 19 +- .../DS.WMS.FeeApi/Logs/internal-nlog.txt | 91 ++++++++++ 10 files changed, 378 insertions(+), 179 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Dtos/FeeItem.cs b/ds-wms-service/DS.WMS.Core/Settlement/Dtos/FeeItem.cs index 31a57406..b137812d 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Dtos/FeeItem.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Dtos/FeeItem.cs @@ -25,11 +25,12 @@ namespace DS.WMS.Core.Settlement.Dtos _items = source; UnchargedRMB = Items.FindAll(x => x.Currency == FeeServiceBase.RMB_CODE && x.FeeType == FeeType.Receivable).Sum(x => x.RestAmount); - UnchargedUSD = Items.FindAll(x => x.Currency == FeeServiceBase.RMB_CODE && x.FeeType == FeeType.Receivable).Sum(x => x.RestAmount); - UnchargedOther = Items.FindAll(x => x.Currency == FeeServiceBase.RMB_CODE && x.FeeType == FeeType.Receivable).Sum(x => x.RestAmount); + UnchargedUSD = Items.FindAll(x => x.Currency == FeeServiceBase.USD_CODE && x.FeeType == FeeType.Receivable).Sum(x => x.RestAmount); + UnchargedOther = Items.FindAll(x => x.Currency != FeeServiceBase.RMB_CODE && x.Currency != FeeServiceBase.USD_CODE && x.FeeType == FeeType.Receivable).Sum(x => x.RestAmount); + UnpaidRMB = Items.FindAll(x => x.Currency == FeeServiceBase.RMB_CODE && x.FeeType == FeeType.Payable).Sum(x => x.RestAmount); - UnpaidUSD = Items.FindAll(x => x.Currency == FeeServiceBase.RMB_CODE && x.FeeType == FeeType.Payable).Sum(x => x.RestAmount); - UnpaidOther = Items.FindAll(x => x.Currency == FeeServiceBase.RMB_CODE && x.FeeType == FeeType.Payable).Sum(x => x.RestAmount); + UnpaidUSD = Items.FindAll(x => x.Currency == FeeServiceBase.USD_CODE && x.FeeType == FeeType.Payable).Sum(x => x.RestAmount); + UnpaidOther = Items.FindAll(x => x.Currency != FeeServiceBase.RMB_CODE && x.Currency != FeeServiceBase.USD_CODE && x.FeeType == FeeType.Payable).Sum(x => x.RestAmount); } /// @@ -71,7 +72,7 @@ namespace DS.WMS.Core.Settlement.Dtos /// /// 费用记录ID /// - public long Id { get; set; } + public long RecordId { get; set; } /// /// 业务ID @@ -83,11 +84,21 @@ namespace DS.WMS.Core.Settlement.Dtos /// public BusinessType BusinessType { get; set; } + /// + /// 客户ID + /// + public long CustomerId { get; set; } + /// /// 客户名称 /// public string? CustomerName { get; set; } + /// + /// 费用ID + /// + public long FeeId { get; set; } + /// /// 费用名称 /// @@ -99,9 +110,9 @@ namespace DS.WMS.Core.Settlement.Dtos public FeeType FeeType { get; set; } /// - /// 金额 + /// 总金额 /// - public decimal Amount { get; set; } + public decimal TotalAmount { get; set; } /// /// 币别 @@ -116,7 +127,12 @@ namespace DS.WMS.Core.Settlement.Dtos /// /// 本次结算金额 /// - public decimal SettlementAmount { get; set; } + public decimal Amount { get; set; } + + /// + /// 本次结算原始金额 + /// + public decimal OriginalAmount { get; set; } /// /// 原始汇率 diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Dtos/PaymentSettlementDto.cs b/ds-wms-service/DS.WMS.Core/Settlement/Dtos/PaymentSettlementDto.cs index 078138a0..081d107d 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Dtos/PaymentSettlementDto.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Dtos/PaymentSettlementDto.cs @@ -157,9 +157,9 @@ namespace DS.WMS.Core.Settlement.Dtos } /// - /// 付费自由结算 + /// 付费自由结算返回明细 /// - public class FreePaymentSettlementDto : PaymentSettlementDto + public class FreeSettlement { /// /// 结算明细 diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentFreeSettlementService.cs b/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentFreeSettlementService.cs index bacc386b..fe1bdaeb 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentFreeSettlementService.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentFreeSettlementService.cs @@ -1,5 +1,6 @@ using DS.Module.Core; using DS.WMS.Core.Application.Interface; +using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Settlement.Dtos; using DS.WMS.Core.Settlement.Entity; @@ -11,11 +12,32 @@ namespace DS.WMS.Core.Settlement.Interface public interface IPaymentFreeSettlementService : ISettlementService { /// - /// 获取待结算费用分页列表 + /// 获取待结算业务分页列表 /// /// /// /// 查询条件请参考中定义的字段 Task>> GetBizListAsync(PageRequest request); + + /// + /// 根据业务编号及类型获取关联费用记录 + /// + /// 业务ID与业务类型 + /// + Task> GetFeesAsync(params BizItem[] items); + + /// + /// 获取付费自由结算单 + /// + /// 结算单ID + /// + Task> GetAsync(long id); + + /// + /// 获取付费结算明细 + /// + /// + /// + Task> GetDetailsAsync(PageRequest request); } } diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentSettlementService.cs b/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentSettlementService.cs index e7a3a887..2f701a49 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentSettlementService.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Interface/IPaymentSettlementService.cs @@ -7,7 +7,7 @@ using DS.WMS.Core.Settlement.Entity; namespace DS.WMS.Core.Settlement.Interface { /// - /// 付费结算 + /// 付费申请结算 /// public interface IPaymentSettlementService : ISettlementService { @@ -19,12 +19,19 @@ namespace DS.WMS.Core.Settlement.Interface Task>> GetListAsync(PageRequest request); /// - /// 获取付费结算及其明细 + /// 获取付费申请结算单 /// /// 结算单ID /// Task> GetAsync(long id); + /// + /// 获取付费结算明细 + /// + /// + /// + Task>> GetDetailsAsync(PageRequest request); + /// /// 获取付费申请分页列表 /// @@ -45,12 +52,5 @@ namespace DS.WMS.Core.Settlement.Interface /// 申请单明细ID /// Task>> GetApplicationDetailsAsync(long[] ids); - - /// - /// 提交结算单 - /// - /// - /// - Task> SaveAsync(SettlementRequest request); } } diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentFreeSettlementService.cs b/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentFreeSettlementService.cs index 3bc4ac37..97cf2eb6 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentFreeSettlementService.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentFreeSettlementService.cs @@ -153,33 +153,41 @@ namespace DS.WMS.Core.Settlement.Method (f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount) != 0) .Select(f => new FeeItem { - Id = f.Id, + RecordId = f.Id, BusinessId = f.BusinessId, BusinessType = f.BusinessType, + CustomerId = f.CustomerId, CustomerName = f.CustomerName, + FeeId = f.FeeId, FeeName = f.FeeName, FeeType = f.FeeType, - Amount = f.Amount, + TotalAmount = f.Amount, Currency = f.Currency, OriginalRate = f.ExchangeRate, RestAmount = f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount, - SettlementAmount = f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount, InvoiceAmount = f.InvoiceAmount, AccTaxRate = f.AccTaxRate, Remark = f.Remark }).ToListAsync(); + foreach (var item in list) + { + //本次结算金额默认等于剩余金额 + item.Amount = item.RestAmount; + item.OriginalAmount = item.RestAmount; + } + return DataResult.Success(new FeeForm(list)); } /// - /// 获取付费自由结算及其明细 + /// 获取付费自由结算单 /// /// 结算单ID /// - public async Task> GetAsync(long id) + public async Task> GetAsync(long id) { - var model = await TenantDb.Queryable().Select(x => new FreePaymentSettlementDto + var model = await TenantDb.Queryable().Select(x => new PaymentSettlementDto { Id = x.Id, ApplicationNO = x.ApplicationNO, //申请编号 @@ -220,11 +228,20 @@ namespace DS.WMS.Core.Settlement.Method AdvanceAmount = x.AdvanceAmount, //预收支资料 AdvanceCurrency = x.AdvanceCurrency, AdvanceRate = x.AdvanceRate, - }).FirstAsync(); + }).FirstAsync(x => x.Id == id && x.Mode == SettlementMode.FreeSettlement); - if (model != null) - { - model.Details = await TenantDb.Queryable().Where(x => x.ApplicationId == id && x.Category == FeeCategory.PaidFreeSettlement) + return DataResult.Success(model); + } + + /// + /// 获取付费自由结算明细 + /// + /// + /// + public async Task> GetDetailsAsync(PageRequest request) + { + var model = new FreeSettlement(); + model.Details = await TenantDb.Queryable().Where(x => x.ApplicationId == request.OtherQueryCondition && x.Category == FeeCategory.PaidFreeSettlement) .InnerJoin((d, f) => d.RecordId == f.Id) .Select((d, f) => new FreeSettlementDetailDto { @@ -244,74 +261,76 @@ namespace DS.WMS.Core.Settlement.Method Note = d.Note }).ToListAsync(); - var gList = model.Details.GroupBy(x => x.BusinessType); - foreach (var g in gList) + var gList = model.Details.GroupBy(x => x.BusinessType); + foreach (var g in gList) + { + var ids = g.Select(x => x.BusinessId); + switch (g.Key) { - var ids = g.Select(x => x.BusinessId); - switch (g.Key) - { - case BusinessType.OceanShippingExport: - var list1 = await TenantDb.Queryable().Where(x => ids.Contains(x.Id)) - .LeftJoin((s, cs) => s.SourceId == cs.Id) - .Select((s, cs) => new - { - s.Id, - s.MBLNO, - s.HBLNO, - s.CustomerNo, - ClientName = s.CustomerName, - s.ETD, - cs.SourceName, - s.Sale, - s.AccountDate, - s.Vessel, - Voyage = s.Voyno, - s.Carrier, - s.Enterprise, - s.CustomNo - }).ToListAsync(); - - foreach (var item in g) + case BusinessType.OceanShippingExport: + var list1 = await TenantDb.Queryable().Where(x => ids.Contains(x.Id)) + .LeftJoin((s, cs) => s.SourceId == cs.Id) + .Select((s, cs) => new + { + s.Id, + s.MBLNO, + s.HBLNO, + s.CustomerNo, + ClientName = s.CustomerName, + s.ETD, + cs.SourceName, + s.Sale, + s.AccountDate, + s.Vessel, + Voyage = s.Voyno, + s.Carrier, + s.Enterprise, + s.CustomNo + }).ToListAsync(); + + foreach (var item in g) + { + var biz = list1.Find(x => x.Id == item.BusinessId); + if (biz != null) { - var biz = list1.Find(x => x.Id == item.BusinessId); - if (biz != null) - { - item.MBLNO = biz.MBLNO; - item.HBLNO = biz.HBLNO; - item.CustomerNo = biz.CustomerNo; - item.ClientName = biz.ClientName; - item.ETD = biz.ETD; - item.SourceName = biz.SourceName; - item.Sale = biz.Sale; - item.AccountDate = biz.AccountDate; - item.Vessel = biz.Vessel; - item.Voyage = biz.Voyage; - item.Carrier = biz.Carrier; - item.Enterprise = biz.Enterprise; - item.CustomNo = biz.CustomNo; - } + item.MBLNO = biz.MBLNO; + item.HBLNO = biz.HBLNO; + item.CustomerNo = biz.CustomerNo; + item.ClientName = biz.ClientName; + item.ETD = biz.ETD; + item.SourceName = biz.SourceName; + item.Sale = biz.Sale; + item.AccountDate = biz.AccountDate; + item.Vessel = biz.Vessel; + item.Voyage = biz.Voyage; + item.Carrier = biz.Carrier; + item.Enterprise = biz.Enterprise; + item.CustomNo = biz.CustomNo; } + } - break; + break; - case BusinessType.OceanShippingImport: - break; - } + case BusinessType.OceanShippingImport: + break; } - - model.SummaryItems = model.Details.GroupBy(x => new { x.FeeType, x.Currency }).Select(x => new SummaryItem - { - FeeType = x.Key.FeeType, - Currency = x.Key.Currency, - Amount = x.Sum(y => y.ApplyAmount) - }).ToList(); } - return DataResult.Success(model); + model.SummaryItems = model.Details.GroupBy(x => new { x.FeeType, x.Currency }).Select(x => new SummaryItem + { + FeeType = x.Key.FeeType, + Currency = x.Key.Currency, + Amount = x.Sum(y => y.ApplyAmount) + }).ToList(); + + return DataResult.Success(model); } protected override async Task PreSaveAsync(PaymentSettlement settlement) { + settlement.Mode = SettlementMode.FreeSettlement; + settlement.BillType = SettlementBillType.Payment; + //获取剩余待结算金额 var ids = settlement.Details.Select(x => x.RecordId); var fees = await TenantDb.Queryable().Where(x => ids.Contains(x.Id) && x.FeeStatus == FeeStatus.AuditPassed) @@ -324,7 +343,7 @@ namespace DS.WMS.Core.Settlement.Method StringBuilder sb = new(); foreach (var detail in settlement.Details) { - var item = fees.Find(x => x.Id == detail.DetailId); + var item = fees.Find(x => x.Id == detail.RecordId); if (item == null) { sb.Append(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.EmptyData))); @@ -343,6 +362,8 @@ namespace DS.WMS.Core.Settlement.Method sb.Append(";"); continue; } + + detail.Category = FeeCategory.PaidApplicationSettlement; } return sb.Length > 0 ? DataResult.Failed(sb.ToString()) : DataResult.Success; @@ -356,17 +377,5 @@ namespace DS.WMS.Core.Settlement.Method return DataResult.Success; } - //protected override async Task OnDeleteDetailAsync(List settlements) - //{ - // await base.OnDeleteDetailAsync(settlements); - - // var detailList = settlements.SelectMany(x => x.Details); - // //还原费用表的已结算金额 - // var fees = detailList.Select(x => new FeeRecord { Id = x.RecordId, SettlementAmount = x.OriginalAmount }).ToList(); - // await TenantDb.Updateable(fees) - // .PublicSetColumns(it => it.SettlementAmount, "-") - // .UpdateColumns(x => new { x.SettlementAmount }) - // .ExecuteCommandAsync(); - //} } } diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentSettlementService.cs b/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentSettlementService.cs index 809d6aed..48b00c79 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentSettlementService.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentSettlementService.cs @@ -105,7 +105,7 @@ namespace DS.WMS.Core.Settlement.Method } /// - /// 获取付费结算及其明细 + /// 获取付费结算单 /// /// 结算单ID /// @@ -152,69 +152,10 @@ namespace DS.WMS.Core.Settlement.Method AdvanceAmount = x.AdvanceAmount, //预收支资料 AdvanceCurrency = x.AdvanceCurrency, AdvanceRate = x.AdvanceRate, - }).FirstAsync(x => x.Id == id); + }).FirstAsync(x => x.Id == id && x.Mode == SettlementMode.Payment); if (model != null) { - var details = await TenantDb.Queryable() - .InnerJoin((d, pd) => d.DetailId == pd.Id) - .InnerJoin((d, pd, pa) => pd.ApplicationId == pa.Id) - .Where(d => d.ApplicationId == id) - .Select((d, pd, pa) => new - { - d.Id, - d.ApplicationId, - d.ApplyAmount, - //d.Currency, - d.OriginalCurrency, - d.OriginalAmount, - pa.ApplicationNO, - pa.Status, - pa.CreateTime, - pa.CreateBy, - pa.PaymentDate, - pa.Note - }).ToListAsync(); - - var gp = details.GroupBy(x => x.ApplicationId); - model.Details = new List(); - foreach (var g in gp) - { - var firstItem = g.FirstOrDefault(); - - var dto = new SettlementDetailDto - { - ApplicationId = g.Key, - Ids = g.Select(x => x.Id), - RMBApplyAmount = g.Where(x => x.OriginalCurrency == RMB_CODE).Sum(x => x.ApplyAmount), - USDApplyAmount = g.Where(x => x.OriginalCurrency == USD_CODE).Sum(x => x.ApplyAmount), - ApplicationNO = firstItem.ApplicationNO, - Status = firstItem.Status, - CreateTime = firstItem?.CreateTime, - CreateBy = firstItem?.CreateBy, - PaymentDate = firstItem?.PaymentDate, - Note = firstItem?.Note - }; - - //包含多个币别 - if (g.GroupBy(x => x.OriginalCurrency).Select(x => x.Key).Count() > 1) - { - //原始币别=不等于结算单币别的首个币别(参考DS7) - dto.OriginalCurrency = g.Where(x => x.OriginalCurrency != model.Currency).Select(x => x.OriginalCurrency).FirstOrDefault(); - //原始金额=当前结算单的币别合计 - dto.OriginalAmount = g.Where(x => x.OriginalCurrency == model.Currency).Sum(x => x.ApplyAmount); - } - else - { - dto.OriginalCurrency = firstItem?.OriginalCurrency; - dto.OriginalAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount); - } - - //结算金额=原申请的原始币别合计 - dto.SettlementAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount); - model.Details.Add(dto); - } - if (model.Details.Count > 0) { //关联用户名称 @@ -231,6 +172,75 @@ namespace DS.WMS.Core.Settlement.Method return DataResult.Success(model); } + /// + /// 获取付费结算明细 + /// + /// + /// + public async Task>> GetDetailsAsync(PageRequest request) + { + var list = await TenantDb.Queryable() + .InnerJoin((d, pd) => d.DetailId == pd.Id) + .InnerJoin((d, pd, pa) => pd.ApplicationId == pa.Id) + .Where(d => d.ApplicationId == request.OtherQueryCondition) + .Select((d, pd, pa) => new + { + d.Id, + d.ApplicationId, + d.ApplyAmount, + d.Currency, + d.OriginalCurrency, + d.OriginalAmount, + pa.ApplicationNO, + pa.Status, + pa.CreateTime, + pa.CreateBy, + pa.PaymentDate, + pa.Note + }).ToListAsync(); + var gp = list.GroupBy(x => x.ApplicationId); + + var details = new List(); + foreach (var g in gp) + { + var firstItem = g.FirstOrDefault(); + + var dto = new SettlementDetailDto + { + ApplicationId = g.Key, + Ids = g.Select(x => x.Id), + RMBApplyAmount = g.Where(x => x.OriginalCurrency == RMB_CODE).Sum(x => x.ApplyAmount), + USDApplyAmount = g.Where(x => x.OriginalCurrency == USD_CODE).Sum(x => x.ApplyAmount), + ApplicationNO = firstItem.ApplicationNO, + Status = firstItem.Status, + CreateTime = firstItem?.CreateTime, + CreateBy = firstItem?.CreateBy, + PaymentDate = firstItem?.PaymentDate, + Note = firstItem?.Note + }; + + //包含多个币别 + if (g.GroupBy(x => x.OriginalCurrency).Select(x => x.Key).Count() > 1) + { + //原始币别=不等于结算单币别的首个币别(参考DS7) + dto.OriginalCurrency = g.Select(x => x.OriginalCurrency).FirstOrDefault(); + //原始金额=当前结算单的币别合计 + dto.OriginalAmount = g.Sum(x => x.ApplyAmount); + } + else + { + dto.OriginalCurrency = firstItem?.OriginalCurrency; + dto.OriginalAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount); + } + + //结算金额=原申请的原始币别合计 + dto.SettlementAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount); + details.Add(dto); + } + + return DataResult>.Success(details); + } + /// /// 获取付费申请分页列表 /// @@ -481,6 +491,8 @@ namespace DS.WMS.Core.Settlement.Method sb.Append(";"); continue; } + + detail.Category = FeeCategory.PaidFreeSettlement; } return sb.Length > 0 ? DataResult.Failed(sb.ToString()) : DataResult.Success; diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs b/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs index 33e54a33..c0952ffd 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs @@ -84,7 +84,6 @@ namespace DS.WMS.Core.Settlement.Method FeeId = x.FeeId, FeeName = x.FeeName, FeeType = x.FeeType, - Category = FeeCategory.PaidApplicationSettlement, ApplyAmount = x.Amount, Currency = x.Currency, ExchangeRate = x.ExchangeRate, @@ -236,6 +235,7 @@ namespace DS.WMS.Core.Settlement.Method ApplicationId = x.ApplicationId, RecordId = x.RecordId, DetailId = x.DetailId, + ApplyAmount = x.ApplyAmount, OriginalAmount = x.OriginalAmount, ProcessedAmount = x.ProcessedAmount, OriginalProcessedAmount = x.OriginalProcessedAmount @@ -251,7 +251,10 @@ namespace DS.WMS.Core.Settlement.Method }).ToListAsync(); foreach (var app in apps) + { app.Details = details.FindAll(x => x.ApplicationId == app.Id); + app.Amount = app.Details.Sum(x => x.ApplyAmount); + } var result = PreDelete(apps); if (!result.Succeeded) @@ -264,13 +267,9 @@ namespace DS.WMS.Core.Settlement.Method await TenantDb.Deleteable(details).ExecuteCommandAsync(); //更新结算单的结算总金额 - var apps2 = await TenantDb.Queryable().Where(x => appIds.Contains(x.ApplicationId) && !ids.Contains(x.Id)) - .GroupBy(x => x.ApplicationId).Select(x => new TEntity - { - Id = x.ApplicationId, - Amount = SqlFunc.AggregateSum(x.ApplyAmount) - }).ToListAsync(); - await TenantDb.Updateable(apps2).UpdateColumns(x => new { x.Amount }).ExecuteCommandAsync(); + await TenantDb.Updateable(apps) + .PublicSetColumns(it => it.Amount, "-").UpdateColumns(x => new { x.Amount }) + .ExecuteCommandAsync(); await TenantDb.Ado.CommitTranAsync(); return DataResult.Success; @@ -356,9 +355,10 @@ namespace DS.WMS.Core.Settlement.Method //还原费用表的已结算金额 var fees = settlements.SelectMany(x => x.Details).Select(x => new FeeRecord { Id = x.RecordId, SettlementAmount = x.OriginalAmount }).ToList(); await TenantDb.Updateable(fees) - .PublicSetColumns(it => it.SettlementAmount, "-") - .UpdateColumns(x => new { x.SettlementAmount }) - .ExecuteCommandAsync(); + .PublicSetColumns(it => it.SettlementAmount, "-").UpdateColumns(x => new { x.SettlementAmount }) + .ExecuteCommandAsync(); + + await UpdateFeeStatus(fees.Select(x => x.Id)); } #endregion @@ -441,6 +441,11 @@ namespace DS.WMS.Core.Settlement.Method item.FeeStatus = FeeStatus.PartialSettlement; list.Add(item); } + else if (item.SettlementAmount == 0) + { + item.FeeStatus = FeeStatus.AuditPassed; + list.Add(item); + } } await TenantDb.Updateable(list).UpdateColumns(x => new { x.FeeStatus }).ExecuteCommandAsync(); diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentFreeSettlementController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentFreeSettlementController.cs index a3df0c6d..9a05bf92 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentFreeSettlementController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentFreeSettlementController.cs @@ -1,5 +1,6 @@ using DS.Module.Core; using DS.Module.Core.Data; +using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Settlement.Dtos; using DS.WMS.Core.Settlement.Entity; using DS.WMS.Core.Settlement.Interface; @@ -24,17 +25,49 @@ namespace DS.WMS.FeeApi.Controllers } /// - /// 获取待结算费用分页列表 + /// 获取待结算业务分页列表 /// /// /// - [HttpPost, Route("GetFeeList")] - public async Task>> GetFeeListAsync([FromBody] PageRequest request) + [HttpPost, Route("GetBizList")] + public async Task>> GetBizListAsync([FromBody] PageRequest request) { return await _service.GetBizListAsync(request); } - + /// + /// 根据业务编号及类型获取关联费用记录 + /// + /// 业务ID与业务类型 + /// + [HttpPost, Route("GetFees")] + public async Task> GetFeesAsync([FromBody] BizItem[] items) + { + return await _service.GetFeesAsync(items); + } + + /// + /// 获取付费自由结算单 + /// + /// 结算单ID + /// + [HttpGet, Route("Get")] + public async Task> GetAsync(long id) + { + return await _service.GetAsync(id); + } + + /// + /// 获取付费自由结算明细 + /// + /// + /// + [HttpPost, Route("GetDetails")] + public async Task> GetDetailsAsync(PageRequest request) + { + return await _service.GetDetailsAsync(request); + } + /// /// 根据付费申请创建结算单 /// diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentSettlementController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentSettlementController.cs index 3c39d86e..662ea004 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentSettlementController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentSettlementController.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Mvc; namespace DS.WMS.FeeApi.Controllers { /// - /// 付费结算API + /// 付费申请结算API /// public class PaymentSettlementController : ApiController { @@ -36,7 +36,7 @@ namespace DS.WMS.FeeApi.Controllers } /// - /// 获取付费结算及其明细 + /// 获取付费申请结算单 /// /// 结算单ID /// @@ -46,6 +46,17 @@ namespace DS.WMS.FeeApi.Controllers return await _service.GetAsync(id); } + /// + /// 获取付费自由结算明细 + /// + /// + /// + [HttpPost, Route("GetDetails")] + public async Task>> GetDetailsAsync(PageRequest request) + { + return await _service.GetDetailsAsync(request); + } + /// /// 获取付费申请分页列表 /// @@ -62,7 +73,7 @@ namespace DS.WMS.FeeApi.Controllers /// /// 付费申请单ID /// - [HttpGet, Route("GetApplicationDetails")] + [HttpGet, Route("GetApplicationDetailsById")] public async Task>> GetApplicationDetailsAsync(long id) { return await _service.GetApplicationDetailsAsync(id); @@ -73,7 +84,7 @@ namespace DS.WMS.FeeApi.Controllers /// /// 申请明细ID /// - [HttpPost, Route("GetDetails")] + [HttpPost, Route("GetApplicationDetailsByDetail")] public async Task>> GetApplicationDetailsAsync([FromBody] IdModel model) { if (!ModelState.IsValid) diff --git a/ds-wms-service/DS.WMS.FeeApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.FeeApi/Logs/internal-nlog.txt index 07b4eb3e..b6211f74 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Logs/internal-nlog.txt +++ b/ds-wms-service/DS.WMS.FeeApi/Logs/internal-nlog.txt @@ -2497,3 +2497,94 @@ 2024-07-10 17:10:02.9237 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config 2024-07-10 17:10:02.9358 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile 2024-07-10 17:10:02.9358 Info Configuration initialized. +2024-07-10 17:32:36.3440 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-10 17:32:36.4802 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-10 17:32:36.4838 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-10 17:32:36.9533 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-10 17:32:36.9744 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-10 17:32:36.9744 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-10 17:32:36.9890 Info Configuration initialized. +2024-07-10 18:00:45.0387 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-10 18:00:45.1183 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-10 18:00:45.1183 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-10 18:00:45.1459 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-10 18:00:45.1573 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-10 18:00:45.1573 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-10 18:00:45.1678 Info Configuration initialized. +2024-07-11 08:53:21.5461 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 08:53:21.5790 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 08:53:21.5790 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 08:53:21.5960 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 08:53:21.5960 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 08:53:21.5960 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 08:53:21.6080 Info Configuration initialized. +2024-07-11 09:19:52.2051 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 09:19:52.2607 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 09:19:52.2707 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 09:19:52.2810 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 09:19:52.2810 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 09:19:52.2810 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 09:19:52.2810 Info Configuration initialized. +2024-07-11 09:58:47.5807 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 09:58:47.6117 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 09:58:47.6117 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 09:58:47.6280 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 09:58:47.6280 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 09:58:47.6280 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 09:58:47.6280 Info Configuration initialized. +2024-07-11 10:04:06.6413 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 10:04:06.7033 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 10:04:06.7033 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 10:04:06.7266 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 10:04:06.7341 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 10:04:06.7341 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 10:04:06.7341 Info Configuration initialized. +2024-07-11 10:22:21.5658 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 10:22:21.5980 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 10:22:21.5980 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 10:22:21.6188 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 10:22:21.6277 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 10:22:21.6277 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 10:22:21.6277 Info Configuration initialized. +2024-07-11 10:36:07.5331 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 10:36:07.5628 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 10:36:07.5628 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 10:36:07.5628 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 10:36:07.5628 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 10:36:07.5830 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 10:36:07.5830 Info Configuration initialized. +2024-07-11 10:36:46.9559 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 10:36:47.0250 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 10:36:47.0297 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 10:36:47.0482 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 10:36:47.0482 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 10:36:47.0654 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 10:36:47.0654 Info Configuration initialized. +2024-07-11 11:02:09.7503 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 11:02:09.8063 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 11:02:09.8063 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 11:02:09.8276 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 11:02:09.8333 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 11:02:09.8333 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 11:02:09.8485 Info Configuration initialized. +2024-07-11 11:08:09.2561 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 11:08:09.2883 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 11:08:09.2883 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 11:08:09.3020 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 11:08:09.3020 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 11:08:09.3109 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 11:08:09.3109 Info Configuration initialized. +2024-07-11 11:09:09.5009 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 11:09:09.5385 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 11:09:09.5385 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 11:09:09.5566 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 11:09:09.5566 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 11:09:09.5566 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 11:09:09.5723 Info Configuration initialized. +2024-07-11 11:11:00.1636 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-11 11:11:00.1957 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-11 11:11:00.1957 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-11 11:11:00.2128 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-11 11:11:00.2186 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config +2024-07-11 11:11:00.2186 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-11 11:11:00.2186 Info Configuration initialized.