diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs b/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs index 214ee78d..82193b42 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs @@ -24,7 +24,7 @@ namespace DS.WMS.Core.Application.Method public abstract TaskBaseTypeEnum AuditType { get; } readonly IClientFlowInstanceService flowService; - readonly IAuditTaskService taskService; + readonly IApplicationTaskService taskService; /// /// 初始化 @@ -33,7 +33,7 @@ namespace DS.WMS.Core.Application.Method public ApplicationAuditService(IServiceProvider serviceProvider) : base(serviceProvider) { flowService = serviceProvider.GetRequiredService(); - taskService = serviceProvider.GetRequiredService(); + taskService = serviceProvider.GetRequiredService(); } /// diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs index 090333bc..b2edcf38 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs @@ -97,7 +97,7 @@ namespace DS.WMS.Core.Application.Method protected override DataResult PreAudit(List applications) { - if (applications.Exists(x => x.Status != InvoiceApplicationStatus.AuditSubmittd)) + if (applications.Exists(x => x.Status != InvoiceApplicationStatus.AuditSubmittd && x.Status != InvoiceApplicationStatus.AuditPassed)) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.ApplicationIsNotAuditing)); return DataResult.Success; diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs index fb7f454a..2a88eb82 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs @@ -289,7 +289,7 @@ namespace DS.WMS.Core.Application.Method protected override DataResult PreAudit(List applications) { - if (applications.Exists(x => x.Status != PaymentApplicationStatus.AuditSubmittd)) + if (applications.Exists(x => x.Status != PaymentApplicationStatus.AuditSubmittd && x.Status != PaymentApplicationStatus.AuditPassed)) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.ApplicationIsNotAuditing)); return DataResult.Success; diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs index f980b03b..1084542f 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs @@ -908,13 +908,15 @@ namespace DS.WMS.Core.Fee.Method if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT) { - if (entity.BillAuditStatus != BillAuditStatus.Pending && entity.BillAuditStatus != BillAuditStatus.RecvRejected) + if (entity.BillAuditStatus == BillAuditStatus.PaySubmitted || entity.BillAuditStatus == BillAuditStatus.PayRejected) + taskType = TaskBaseTypeEnum.BILL_PAY_AUDIT; + else if (entity.BillAuditStatus != BillAuditStatus.Pending && entity.BillAuditStatus != BillAuditStatus.RecvRejected) return DataResult.Failed(string.Format( MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription())); } else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT) { - if (entity.BillAuditStatus != BillAuditStatus.PaySubmitted || entity.BillAuditStatus != BillAuditStatus.PayRejected) + if (entity.BillAuditStatus != BillAuditStatus.PaySubmitted && entity.BillAuditStatus != BillAuditStatus.PayRejected) return DataResult.Failed(string.Format( MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription())); } @@ -985,11 +987,6 @@ namespace DS.WMS.Core.Fee.Method x.ARFeeStatus, x.APFeeStatus }).ExecuteCommandAsync(); - - //修改关联费用状态为提交审核 - await TenantDb.Updateable().Where(x => x.BusinessId == bid && x.BusinessType == type && - (x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.Withdraw || x.FeeStatus == FeeStatus.RejectSubmission)) - .SetColumns(x => x.FeeStatus == FeeStatus.AuditSubmitted).ExecuteCommandAsync(); } else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT) { @@ -1000,6 +997,11 @@ namespace DS.WMS.Core.Fee.Method }).ExecuteCommandAsync(); } + //修改关联费用状态为提交审核 + await TenantDb.Updateable().Where(x => x.BusinessId == bid && x.BusinessType == type && + (x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.Withdraw || x.FeeStatus == FeeStatus.RejectSubmission)) + .SetColumns(x => x.FeeStatus == FeeStatus.AuditSubmitted).ExecuteCommandAsync(); + if (useTransaction) await TenantDb.Ado.CommitTranAsync(); return DataResult.Success; @@ -1039,7 +1041,9 @@ namespace DS.WMS.Core.Fee.Method if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT) { - if (entity.BillAuditStatus != BillAuditStatus.RecvSubmitted) + if (entity.BillAuditStatus == BillAuditStatus.PaySubmitted) + taskType = TaskBaseTypeEnum.BILL_PAY_AUDIT; + else if (entity.BillAuditStatus != BillAuditStatus.RecvSubmitted) return DataResult.Failed(string.Format( MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BusinessStatusError)), entity.BillAuditStatus.GetDescription())); } diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/DebitNoteReport.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/DebitNoteReport.cs index 72694e76..93e53e1d 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/DebitNoteReport.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/DebitNoteReport.cs @@ -11,15 +11,23 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders /// /// 费用确认单 /// - public class DebitNoteReport : IReportProvider + public class DebitNoteReport : ServiceBase, IReportProvider { + /// + /// 初始化 + /// + /// + public DebitNoteReport(IServiceProvider provider) : base(provider) + { + } + public async Task GetDataAsync(ReportContext context) { DebitNote? form = null; switch (context.BusinessType) { case BusinessType.OceanShippingExport: - form = await context.TenantDb.Queryable().Where(s => s.Id == context.BusinessId).Select().FirstAsync(); + form = await AsQueryable().Where(s => s.Id == context.BusinessId).Select().FirstAsync(); break; case BusinessType.OceanShippingImport: @@ -32,7 +40,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders if (form != null) { - form.Items = await context.TenantDb.Queryable().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType) + form.Items = await AsQueryable().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType) .WhereIF(context.Ids != null && context.Ids.Length > 0, x => context.Ids.Contains(x.Id)) .Select(x => new DebitNoteItem { diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/ProfitAccountingReport.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/ProfitAccountingReport.cs index 05fcedd2..1d903760 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/ProfitAccountingReport.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/ProfitAccountingReport.cs @@ -12,17 +12,25 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders /// /// 利润核算单 /// - public class ProfitAccountingReport : IReportProvider + public class ProfitAccountingReport : ServiceBase, IReportProvider { internal static readonly string[] CustomerTypes = ["booking", "controller", "shippercn", "yard", "truck", "custom"]; + /// + /// 初始化 + /// + /// + public ProfitAccountingReport(IServiceProvider provider) : base(provider) + { + } + public async Task GetDataAsync(ReportContext context) { ProfitAccounting? form = null; switch (context.BusinessType) { case BusinessType.OceanShippingExport: - form = await context.TenantDb.Queryable().Where(s => s.Id == context.BusinessId) + form = await AsQueryable().Where(s => s.Id == context.BusinessId) .Select(s => new ProfitAccounting { ETDValue = s.ETD, @@ -71,7 +79,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders form.CabinRemark = string.Join(delimiter, remarks.Where(x => x.RemarkType == "2").Select(x => x.Remark)); form.BookingRemark = string.Join(delimiter, remarks.Where(x => x.RemarkType == "3").Select(x => x.Remark)); - var list = await context.TenantDb.Queryable().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType) + var list = await AsQueryable().Where(x => x.BusinessId == context.BusinessId && x.BusinessType == context.BusinessType) .WhereIF(context.Ids != null && context.Ids.Length > 0, x => context.Ids.Contains(x.Id)) .OrderByDescending(x => x.Currency).Select().ToListAsync(); if (list.Count > 0) diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs index a66626d9..9c310ecb 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs @@ -7,6 +7,8 @@ using DS.WMS.Core.Flow.Interface; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Sys.Entity; using Mapster; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using SqlSugar; @@ -24,12 +26,14 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService api = new ApiFox(); } + ILogger logger; /// /// 初始化 /// /// public FlowInstanceService(IServiceProvider serviceProvider) : base(serviceProvider) { + logger = serviceProvider.GetRequiredService>(); } /// @@ -615,7 +619,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService } else { - await new ApplicationException($"访问回调URL:{instance.CallbackURL} 时返回了错误:" + result.Message).LogAsync(Db); + logger.LogError($"访问回调URL:{instance?.CallbackURL} 时返回了错误:" + result?.Message); } } catch (Exception ex) diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs index 6e03092f..b9f58d73 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs @@ -66,7 +66,7 @@ namespace DS.WMS.Core.Op.Entity /// Desc:是否费用锁定 /// [SugarColumn(ColumnDescription = "是否费用锁定", DefaultValue = "0")] - public bool? IsFeeLocking { get; set; } = false; + public bool? IsFeeLocking { get; set; } = false; /// /// 整单费用审核状态 diff --git a/ds-wms-service/DS.WMS.Core/TaskInteraction/Interface/IApplicationTaskService.cs b/ds-wms-service/DS.WMS.Core/TaskInteraction/Interface/IApplicationTaskService.cs new file mode 100644 index 00000000..143f2d4c --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/TaskInteraction/Interface/IApplicationTaskService.cs @@ -0,0 +1,10 @@ +namespace DS.WMS.Core.TaskInteraction.Interface +{ + /// + /// 申请类审核任务 + /// + public interface IApplicationTaskService : IAuditTaskService + { + + } +} diff --git a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/ApplicationTaskService.cs b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/ApplicationTaskService.cs new file mode 100644 index 00000000..5ddac3ee --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/ApplicationTaskService.cs @@ -0,0 +1,102 @@ +using DS.Module.Core; +using DS.WMS.Core.Flow.Dtos; +using DS.WMS.Core.Flow.Entity; +using DS.WMS.Core.TaskInteraction.Dtos; +using DS.WMS.Core.TaskInteraction.Entity; +using DS.WMS.Core.TaskInteraction.Interface; + +namespace DS.WMS.Core.TaskInteraction.Method +{ + /// + /// 申请类审核任务 + /// + public class ApplicationTaskService : TaskService, IApplicationTaskService + { + /// + /// 初始化 + /// + /// + public ApplicationTaskService(IServiceProvider provider) : base(provider) + { + } + + public async override Task AuditAsync(TaskAuditRequest request) + { + var tasksList = await TenantDb.Queryable().Where(x => x.TaskType == request.TaskType && request.Ids.Contains(x.BusinessId)) + .WhereIF(request.BusinessType.HasValue, x => x.BusinessType == request.BusinessType.Value).ToListAsync(); + if (tasksList.Count == 0) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists)); + if (tasksList.Count != request.Ids.Length) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCountNotMatch)); + + if (tasksList.Exists(x => x.TaskStatus != TaskStatusEnum.Create && x.TaskStatus != TaskStatusEnum.Pending && x.TaskStatus != TaskStatusEnum.Complete)) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskAuditStatusError)); + + DataResult result = DataResult.Success; + var tasks = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Create); + var task2 = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Complete); + await TenantDb.Ado.BeginTranAsync(); + try + { + //状态待审核的任务 + if (tasks.Count > 0) + { + var flowIds = tasks.Select(x => x.FlowId.Value); + var flowInstances = await Db.Queryable().Where(x => flowIds.Contains(x.Id)).ToListAsync(); + foreach (var instance in flowInstances) + { + result = await FlowService.Value.AuditAsync(new FlowAuditInfo + { + AuditNote = request.Remark, + Status = request.Result, + Instance = instance + }); + + if (!result.Succeeded) + return result; + + var req = new TaskUpdateRequest + { + BusinessId = instance.BusinessId, + BusinessType = instance.BusinessType, + RejectReason = request.Remark, + TaskTypeName = request.TaskType.ToString(), + TaskStatus = request.Result == 1 ? TaskStatusEnum.Complete : TaskStatusEnum.Pending, + AutoCreateNext = true + }; + //根据审批结果更新任务状态 + await SetTaskStatusAsync(req, false); + + if (instance.FlowStatus == FlowStatusEnum.Reject) + result.Message = request.Remark!; + } + } + + //已完成审核的任务 + if (task2.Count > 0) + { + switch (request.TaskType) + { + case TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT: + break; + + case TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT: + break; + + default: + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + } + + await TenantDb.Ado.CommitTranAsync(); + return result; + } + catch (Exception ex) + { + await TenantDb.Ado.RollbackTranAsync(); + await ex.LogAsync(Db); + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + } + } +} diff --git a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeBillTaskService.cs b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeBillTaskService.cs index df586315..2ba80827 100644 --- a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeBillTaskService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeBillTaskService.cs @@ -66,8 +66,8 @@ namespace DS.WMS.Core.TaskInteraction.Method BusinessType = x.BusinessType, BillAuditStatus = x.BillAuditStatus, BillFeeStatusTime = x.BillFeeStatusTime, - ProfitMargin = SqlFunc.Subqueryable().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Receivable).Sum(f => f.Amount) - - SqlFunc.Subqueryable().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Payable).Sum(f => f.Amount) + ProfitMargin = SqlFunc.Subqueryable().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Receivable).Sum(f => f.Amount * SqlFunc.IsNull(f.ExchangeRate.Value, 1)) + - SqlFunc.Subqueryable().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Payable).Sum(f => f.Amount * SqlFunc.IsNull(f.ExchangeRate.Value, 1)) }).FirstAsync(); if (biz == null) return; @@ -173,7 +173,7 @@ namespace DS.WMS.Core.TaskInteraction.Method { if (biz.ProfitMargin > 0) { - biz.IsBusinessLocking = true; + biz.IsFeeLocking = true; await SetLockAsync(biz); } else //如果为非正利润则生成锁单任务 @@ -345,6 +345,7 @@ namespace DS.WMS.Core.TaskInteraction.Method BusinessType = callback.BusinessType, TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString()!, TaskTitle = $"【{callback.AuditType.GetDescription()}】【{callback.BusinessType.GetDescription()}】{business.CustomerNo}", + TaskDescription = "审核备注:" + callback.RejectReason, RecvUserIdList = [task.CreateBy] //通知任务发起人 }; //创建驳回任务以进行通知