From c5f5366b3895535030490c93aad60398d41d5de5 Mon Sep 17 00:00:00 2001 From: cjy Date: Fri, 13 Sep 2024 09:24:37 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.Module.AutofacModule/AutofacModuleRegister.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ds-wms-service/DS.Module.AutofacModule/AutofacModuleRegister.cs b/ds-wms-service/DS.Module.AutofacModule/AutofacModuleRegister.cs index 356beaa4..29e75e7d 100644 --- a/ds-wms-service/DS.Module.AutofacModule/AutofacModuleRegister.cs +++ b/ds-wms-service/DS.Module.AutofacModule/AutofacModuleRegister.cs @@ -34,7 +34,9 @@ public class AutofacModuleRegister : Autofac.Module .AsImplementedInterfaces() .InstancePerDependency() .PropertiesAutowired() - .EnableInterfaceInterceptors(); //引用Autofac.Extras.DynamicProxy + .EnableInterfaceInterceptors() + //.InstancePerLifetimeScope() + ; //引用Autofac.Extras.DynamicProxy //.InterceptedBy(cacheType.ToArray());//允许将拦截器服务的列表分配给注册。 #endregion 带有接口层的服务注入 From 496d8cf27e4371d015129062f1b8c02e5e5a3faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Fri, 13 Sep 2024 10:35:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8D=95=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=B4=B9=E7=94=A8=E6=98=8E=E7=BB=86=E6=97=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=B4=B9=E7=94=A8=E5=AF=B9=E8=B1=A1=E7=BB=B4=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/Dtos/ApplicationRequest.cs | 2 +- .../Application/Dtos/BizOperation.cs | 94 +++++++++++++++++++ .../Interface/IInvoiceApplicationService.cs | 2 +- .../Interface/IPaymentApplicationService.cs | 3 +- .../Method/InvoiceApplicationService.cs | 18 ++-- .../Method/PaymentApplicationService.cs | 44 ++++----- .../DS.WMS.Core/Fee/Dtos/AuditRequest.cs | 47 +--------- .../DS.WMS.Core/Fee/Method/FeeAuditService.cs | 4 +- .../Invoice/Interface/IFreeInvoiceService.cs | 3 +- .../Invoice/Method/FreeInvoiceService.cs | 12 ++- .../Invoice/Method/GeneralInvoiceService.cs | 2 - .../Controllers/FreeInvoiceController.cs | 2 +- .../InvoiceApplicationController.cs | 2 +- .../PaymentApplicationController.cs | 4 +- 14 files changed, 144 insertions(+), 95 deletions(-) create mode 100644 ds-wms-service/DS.WMS.Core/Application/Dtos/BizOperation.cs diff --git a/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationRequest.cs b/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationRequest.cs index 3a440832..b80edb55 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationRequest.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationRequest.cs @@ -17,7 +17,7 @@ namespace DS.WMS.Core.Application.Dtos /// /// 业务信息 /// - public List Items { get; set; } = []; + public List Items { get; set; } = []; /// /// 汇率转换信息 diff --git a/ds-wms-service/DS.WMS.Core/Application/Dtos/BizOperation.cs b/ds-wms-service/DS.WMS.Core/Application/Dtos/BizOperation.cs new file mode 100644 index 00000000..905c4fb4 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Application/Dtos/BizOperation.cs @@ -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 +{ + /// + /// 业务ID与类型 + /// + public class BizItem + { + public static readonly BizItemComparer DefaultComparer = new(); + + /// + /// 业务ID + /// + public long Id { get; set; } + + /// + /// 业务类型 + /// + public BusinessType BusinessType { get; set; } + + + public class BizItemComparer : IEqualityComparer + { + 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 FeeClient : BizItem + { + /// + /// 费用对象ID + /// + public long CustomerId { get; set; } + } + + public class BizOperation : IValidatableObject + { + /// + /// 请求值(object类型,根据业务按需传值) + /// + public object Value { get; set; } + + /// + /// 业务ID与类型 + /// + public List? Items { get; set; } + + /// + /// 业务ID + /// + [IgnoreDataMember] + public IEnumerable? Ids => Items?.Select(x => x.Id).Distinct(); + + /// + /// 业务类型 + /// + [IgnoreDataMember] + public IEnumerable? Types => Items?.Select(x => x.BusinessType).Distinct(); + + public IEnumerable Validate(ValidationContext validationContext) + { + if (Items == null || Items.Count == 0) + { + yield return new ValidationResult($"缺少请求参数:{nameof(Items)}"); + } + } + } + + public class BizOperation : BizOperation + { + /// + /// 请求值(根据业务按需传值) + /// + public new T Value { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Application/Interface/IInvoiceApplicationService.cs b/ds-wms-service/DS.WMS.Core/Application/Interface/IInvoiceApplicationService.cs index 3930c048..d0547a30 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Interface/IInvoiceApplicationService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Interface/IInvoiceApplicationService.cs @@ -36,7 +36,7 @@ namespace DS.WMS.Core.Application.Interface /// /// 业务ID与业务类型 /// - Task> GetFeesAsync(params BizItem[] items); + Task> GetFeesAsync(params FeeClient[] items); /// /// 删除发票明细 diff --git a/ds-wms-service/DS.WMS.Core/Application/Interface/IPaymentApplicationService.cs b/ds-wms-service/DS.WMS.Core/Application/Interface/IPaymentApplicationService.cs index 2b02652c..0803ef9c 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Interface/IPaymentApplicationService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Interface/IPaymentApplicationService.cs @@ -36,7 +36,7 @@ namespace DS.WMS.Core.Application.Interface /// /// 业务ID与业务类型 /// - Task> GetFeesAsync(params BizItem[] items); + Task> GetFeesAsync(IEnumerable items); /// /// 设置是否收到发票 @@ -46,6 +46,5 @@ namespace DS.WMS.Core.Application.Interface /// Task SetInvoiceReceivedAsync(bool isInvoiceReceived, params long[] ids); - } } diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs index 4ed6ca8d..ed1e260c 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs @@ -176,7 +176,7 @@ namespace DS.WMS.Core.Application.Method var query1 = TenantDb.Queryable() .InnerJoin((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 /// /// 业务ID与业务类型 /// - public async Task> GetFeesAsync(params BizItem[] items) + public async Task> 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() .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> GetDetailsAsync(ApplicationRequest 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().Where(x => - ids1.Contains(x.BusinessId) && ids2.Contains(x.BusinessType) && x.FeeStatus == FeeStatus.AuditPassed) + var list = await TenantDb.Queryable().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 { diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationService.cs index 9b83205c..6c687ea9 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationService.cs @@ -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 /// public async Task>> 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() .InnerJoin((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().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().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().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().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().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().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed && @@ -219,13 +216,15 @@ namespace DS.WMS.Core.Application.Method /// /// 业务ID与业务类型 /// - public async Task> GetFeesAsync(params BizItem[] items) + public async Task> GetFeesAsync(IEnumerable 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() - .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> GetDetailsAsync(ApplicationRequest 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().Where(x => - ids1.Contains(x.BusinessId) && ids2.Contains(x.BusinessType) && x.FeeStatus == FeeStatus.AuditPassed) + var list = await TenantDb.Queryable().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 applications) diff --git a/ds-wms-service/DS.WMS.Core/Fee/Dtos/AuditRequest.cs b/ds-wms-service/DS.WMS.Core/Fee/Dtos/AuditRequest.cs index 13077106..33dabffb 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Dtos/AuditRequest.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Dtos/AuditRequest.cs @@ -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 Items { get; set; } } - public class BizItem - { - public static readonly BizItemComparer DefaultComparer = new BizItemComparer(); - - /// - /// 业务ID - /// - public long Id { get; set; } - - /// - /// 业务类型 - /// - public BusinessType BusinessType { get; set; } - - - public class BizItemComparer : IEqualityComparer - { - 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 - { - /// - /// 请求值(object类型,根据业务按需传值) - /// - public object Value { get; set; } - - /// - /// 业务ID与类型 - /// - public List Items { get; set; } - } - public class AuditDetailRequest : BizItem { public string? QueryCondition { get; set; } diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs index 311ab6b3..abf94668 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs @@ -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; } diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Interface/IFreeInvoiceService.cs b/ds-wms-service/DS.WMS.Core/Invoice/Interface/IFreeInvoiceService.cs index 8453dbff..8977f171 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Interface/IFreeInvoiceService.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Interface/IFreeInvoiceService.cs @@ -21,8 +21,7 @@ namespace DS.WMS.Core.Invoice.Interface /// /// 业务ID与业务类型 /// - Task> GetFeesAsync(params BizItem[] items); - + Task> GetFeesAsync(params FeeClient[] items); } } diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Method/FreeInvoiceService.cs b/ds-wms-service/DS.WMS.Core/Invoice/Method/FreeInvoiceService.cs index 8e86e0c2..d5888255 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/FreeInvoiceService.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/FreeInvoiceService.cs @@ -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 /// /// 业务ID与业务类型 /// - public async Task> GetFeesAsync(params BizItem[] items) + public async Task> 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() - .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, diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs b/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs index a1ea3b81..bbbe6a44 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs @@ -149,8 +149,6 @@ namespace DS.WMS.Core.Invoice.Method return Task.Factory.StartNew(UpdateInvoiceApplications, new List { invoice }); } - - protected override async Task OnDeleteDetailAsync(List invoices, DeleteOption deleteOption) { var list = invoices.SelectMany(x => x.Details).Where(x => x.DetailId.HasValue).Select(x => new ApplicationDetail diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FreeInvoiceController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FreeInvoiceController.cs index 2dbca283..4c581fde 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FreeInvoiceController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FreeInvoiceController.cs @@ -53,7 +53,7 @@ namespace DS.WMS.FeeApi.Controllers /// 业务ID与业务类型 /// [HttpPost, Route("GetFees")] - public async Task> GetFeesAsync([FromBody] BizItem[] items) + public async Task> GetFeesAsync([FromBody] FeeClient[] items) { return await _service.GetFeesAsync(items); } diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/InvoiceApplicationController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/InvoiceApplicationController.cs index e1b35463..6f5673b7 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/InvoiceApplicationController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/InvoiceApplicationController.cs @@ -66,7 +66,7 @@ namespace DS.WMS.FeeApi.Controllers /// 业务ID和类型 /// [HttpPost, Route("GetFees")] - public async Task> GetFeesAsync([FromBody] params BizItem[] items) + public async Task> GetFeesAsync([FromBody] params FeeClient[] items) { if (items == null || items.Length == 0) return DataResult.Failed("缺少请求参数"); diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentApplicationController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentApplicationController.cs index e102f523..4b0d2492 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentApplicationController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentApplicationController.cs @@ -60,10 +60,10 @@ namespace DS.WMS.FeeApi.Controllers /// /// 根据业务编号及类型获取关联费用记录 /// - /// 业务ID和类型 + /// /// [HttpPost, Route("GetFees")] - public async Task> GetFeesAsync([FromBody] params BizItem[] items) + public async Task> GetFeesAsync([FromBody] params FeeClient[] items) { if (items == null || items.Length == 0) return DataResult.Failed("缺少请求参数"); From a96d8022ace390e49a494b932c6fb36398fd7368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Fri, 13 Sep 2024 10:45:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.WMS.Core/Fee/Method/FeeAuditService.cs | 1 + .../Op/Method/TaskInteraction/TaskService.cs | 2 +- .../Interface/IPaymentFreeSettlementService.cs | 4 ++-- .../Method/PaymentFreeSettlementService.cs | 13 ++++++------- .../DS.WMS.FeeApi/Controllers/FeeAuditController.cs | 1 + .../Controllers/FeeCustTemplateController.cs | 2 +- .../Controllers/PaymentFreeSettlementController.cs | 3 ++- .../PublishProfiles/FolderProfile1.pubxml.user | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs index abf94668..2a4c5f82 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs @@ -1,5 +1,6 @@ using DS.Module.Core; using DS.Module.Core.Extensions; +using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Entity; diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs index 8e14e453..a50c4daa 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs @@ -3,7 +3,7 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Helpers; using DS.Module.DjyRulesEngine; -using DS.WMS.Core.Fee.Dtos; +using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Entity; using DS.WMS.Core.Flow.Interface; 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 8e587f81..e72e1695 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,5 @@ using DS.Module.Core; -using DS.WMS.Core.Fee.Dtos; +using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Settlement.Dtos; using DS.WMS.Core.Settlement.Entity; @@ -23,7 +23,7 @@ namespace DS.WMS.Core.Settlement.Interface /// /// 业务ID与业务类型 /// - Task> GetFeesAsync(params BizItem[] items); + Task> GetFeesAsync(params FeeClient[] items); /// /// 获取付费自由结算单 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 69c1cc2b..243ddcf2 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentFreeSettlementService.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Method/PaymentFreeSettlementService.cs @@ -5,7 +5,6 @@ using DS.Module.Core.Extensions; using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Application.Entity; using DS.WMS.Core.Code.Entity; -using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Settlement.Dtos; @@ -143,14 +142,15 @@ namespace DS.WMS.Core.Settlement.Method /// /// 业务ID与业务类型 /// - public async Task> GetFeesAsync(params BizItem[] items) + public async Task> 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() - .Where(f => bizIds.Contains(f.BusinessId) && types.Contains(f.BusinessType) && f.FeeStatus == FeeStatus.AuditPassed && - (f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount) != 0) + .Where(f => bizIds.Contains(f.BusinessId) && types.Contains(f.BusinessType) && cIds.Contains(f.CustomerId) && + f.FeeStatus == FeeStatus.AuditPassed && (f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount) != 0) .Select(f => new FeeItem { RecordId = f.Id, @@ -375,6 +375,5 @@ namespace DS.WMS.Core.Settlement.Method return DataResult.Success; } - } } diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeAuditController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeAuditController.cs index b8e02ad5..0e729eb7 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeAuditController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeAuditController.cs @@ -1,4 +1,5 @@ using DS.Module.Core; +using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Flow.Dtos; diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs index d4ea4ef7..941195a3 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs @@ -1,7 +1,7 @@ using System.Net; using DS.Module.Core; using DS.Module.Core.Data; -using DS.WMS.Core.Fee.Dtos; +using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Interface; using Microsoft.AspNetCore.Mvc; diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentFreeSettlementController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/PaymentFreeSettlementController.cs index 4d2157a6..4b520604 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.Application.Dtos; using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Settlement.Dtos; using DS.WMS.Core.Settlement.Entity; @@ -41,7 +42,7 @@ namespace DS.WMS.FeeApi.Controllers /// 业务ID与业务类型 /// [HttpPost, Route("GetFees")] - public async Task> GetFeesAsync([FromBody] BizItem[] items) + public async Task> GetFeesAsync([FromBody] FeeClient[] items) { return await _service.GetFeesAsync(items); } diff --git a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user index 8705ae82..cc12734c 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user +++ b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>D:\Publish\DS8\FeeApi - True|2024-09-06T10:49:17.9435308Z||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||; + True|2024-09-13T02:44:56.1241214Z||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||; \ No newline at end of file From bc90f4d1bceec2efc60b07157b72757cdb01a78d Mon Sep 17 00:00:00 2001 From: cjy Date: Fri, 13 Sep 2024 13:36:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=AF=E8=A7=86?= =?UTF-8?q?=E3=80=81=E6=93=8D=E4=BD=9C=E6=9D=83=E9=99=90=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=85=A8=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Code/Dtos/UserDataRuleScopeApplyReq.cs | 25 +++ .../Code/Interface/ICodeDataRuleService.cs | 13 ++ .../Interface/IDataRuleTemplateService.cs | 3 +- .../Code/Method/CodeDataRuleService.cs | 212 ++++++++++++++++++ .../Code/Method/DataRuleTemplateService.cs | 5 +- .../Controllers/CodeDataRuleController.cs | 25 +++ .../CodeDataRuleTemplateController.cs | 5 +- 7 files changed, 283 insertions(+), 5 deletions(-) create mode 100644 ds-wms-service/DS.WMS.Core/Code/Dtos/UserDataRuleScopeApplyReq.cs diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/UserDataRuleScopeApplyReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/UserDataRuleScopeApplyReq.cs new file mode 100644 index 00000000..705fe721 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/UserDataRuleScopeApplyReq.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.WMS.Core.Code.Dtos +{ + /// + /// 用户数据权限应用请求 + /// + public class UserDataRuleScopeApplyReq + { + /// + /// 数据权限Id + /// + public long RuleId { get; set; } + + /// + /// 用户Id + /// + public long UserId { get; set; } + + } +} diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeDataRuleService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeDataRuleService.cs index 687a2bd2..5968d667 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeDataRuleService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeDataRuleService.cs @@ -27,6 +27,19 @@ public interface ICodeDataRuleService /// /// public Task CopyDataRuleScope(CopyDataRuleScopeReq req); + + /// + /// 用户可视权限应用全部 + /// + /// + /// + public Task UserVisibleDataRuleScopeApply(UserDataRuleScopeApplyReq req); + /// + /// 用户操作权限应用全部 + /// + /// + /// + public Task UserOperateDataRuleScopeApply(UserDataRuleScopeApplyReq req); ///// ///// 编辑 ///// diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs index 73e15eba..ebb70279 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs @@ -40,7 +40,8 @@ public interface IDataRuleTemplateService /// 根据权限id获取数据权限模板 /// /// + /// /// - Task>> GetDataRuleTemplateSelectList(string id); + Task>> GetDataRuleTemplateSelectList(string id, string ruleType); } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs index 90adb033..e3aac2c2 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs @@ -9,6 +9,7 @@ using DS.WMS.Core.Code.Interface; using DS.WMS.Core.Invoice.Dtos; using DS.WMS.Core.Sys.Dtos; using DS.WMS.Core.Sys.Entity; +using LanguageExt; using Mapster; using Microsoft.AspNet.SignalR.Hubs; using Microsoft.Extensions.DependencyInjection; @@ -190,6 +191,217 @@ namespace DS.WMS.Core.Code.Method + return await Task.FromResult(DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess)); + } + public async Task UserVisibleDataRuleScopeApply(UserDataRuleScopeApplyReq req) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + var rule = await tenantDb.Queryable().Where(x=>x.Id == req.RuleId).FirstAsync(); + + if (rule.IsNull()) { + return await Task.FromResult(DataResult.Failed("数据权限信息不存在!")); + } + if (string.IsNullOrEmpty(rule.VisibleRuleScope)) + { + return await Task.FromResult(DataResult.Failed("请维护该数据权限信息的可视范围!")); + } + var userId = req.UserId; + + var userInfo = await db.Queryable().Where(x => x.Id == userId).FirstAsync(); + var roleIds = await db.Queryable().Where(x => x.UserId == userId).Select(x => x.RoleId).ToListAsync(); + if (roleIds.Count == 0) + { + return await Task.FromResult(DataResult.Failed("该用户未绑定角色!")); + } + + var permissions = await db.Queryable().Where(x => roleIds.Contains(x.RoleId)) + .Select(x => x.PermissionId).Distinct().ToListAsync(); + + var perlist = await db.Queryable() + .Where(x => x.MenuType == 2 && x.IsHidden == false && permissions.Contains(x.PermissionId) && x.PermissionId!= rule.PermissionId && + (x.PermissionType == 1 || x.PermissionType == 0)) + .OrderBy(x => x.SortCode) + .Select(a => new RouteItem + { + Id = a.Id, + ParentId = a.PermissionId, + Path = a.Url, + Name = a.PermissionName, + EnName = a.PermissionEnName, + Component = a.Component, + Redirect = a.Redirect, + SortCode = a.SortCode, + Meta = new RouteMeta() + { + Title = a.Title, + Icon = a.Icon, + } + }) + .ToListAsync(); + + try + { + await tenantDb.Ado.BeginTranAsync(); + var newRules = new List(); + var updateRules = new List(); + foreach (var item in perlist) + { + var currentTemplate = await tenantDb.Queryable().Where(x => x.PermissionId == item.ParentId && x.RuleScope == rule.VisibleRuleScope).FirstAsync(); + var currentRule = await tenantDb.Queryable().Where(x => x.PermissionId == item.ParentId && x.UserId == req.UserId).FirstAsync(); + if (currentRule.IsNull()) + { + if (currentTemplate.IsNotNull()) + { + newRules.Add(new CodeDataRule() + { + UserId = userInfo.Id, + UserName = userInfo.UserName, + VisibleTemplateId = currentTemplate.Id, + VisibleRuleScope = currentTemplate.RuleScope, + VisibleRuleScopeName = currentTemplate.RuleScopeName, + PermissionEntity = currentTemplate.PermissionEntity, + PermissionId = currentTemplate.PermissionId, + Description = currentTemplate.Description, + Status = currentTemplate.Status, + Note = currentTemplate.Note, + }); + } + } + else { + currentRule.VisibleTemplateId = currentTemplate.Id; + currentRule.VisibleRuleScope = currentTemplate.RuleScope; + currentRule.VisibleRuleScopeName = currentTemplate.RuleScopeName; + + updateRules.Add(currentRule); + } + + } + if (newRules.Count>0) + { + await tenantDb.Insertable(newRules).ExecuteCommandAsync(); + } + if (updateRules.Count > 0) + { + await tenantDb.Updateable(updateRules).ExecuteCommandAsync(); + } + await tenantDb.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + await tenantDb.Ado.RollbackTranAsync(); + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + + + + return await Task.FromResult(DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess)); + } + + public async Task UserOperateDataRuleScopeApply(UserDataRuleScopeApplyReq req) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + var rule = await tenantDb.Queryable().Where(x => x.Id == req.RuleId).FirstAsync(); + + if (rule.IsNull()) + { + return await Task.FromResult(DataResult.Failed("数据权限信息不存在!")); + } + if (string.IsNullOrEmpty(rule.OperateRuleScope)) + { + return await Task.FromResult(DataResult.Failed("请维护该数据权限信息的操作范围!")); + } + var userId = req.UserId; + + var userInfo = await db.Queryable().Where(x => x.Id == userId).FirstAsync(); + var roleIds = await db.Queryable().Where(x => x.UserId == userId).Select(x => x.RoleId).ToListAsync(); + if (roleIds.Count == 0) + { + return await Task.FromResult(DataResult.Failed("该用户未绑定角色!")); + } + + var permissions = await db.Queryable().Where(x => roleIds.Contains(x.RoleId)) + .Select(x => x.PermissionId).Distinct().ToListAsync(); + + var perlist = await db.Queryable() + .Where(x => x.MenuType == 2 && x.IsHidden == false && permissions.Contains(x.PermissionId) && x.PermissionId != rule.PermissionId && + (x.PermissionType == 1 || x.PermissionType == 0)) + .OrderBy(x => x.SortCode) + .Select(a => new RouteItem + { + Id = a.Id, + ParentId = a.PermissionId, + Path = a.Url, + Name = a.PermissionName, + EnName = a.PermissionEnName, + Component = a.Component, + Redirect = a.Redirect, + SortCode = a.SortCode, + Meta = new RouteMeta() + { + Title = a.Title, + Icon = a.Icon, + } + }) + .ToListAsync(); + + try + { + await tenantDb.Ado.BeginTranAsync(); + var newRules = new List(); + var updateRules = new List(); + foreach (var item in perlist) + { + var currentTemplate = await tenantDb.Queryable().Where(x => x.PermissionId == item.ParentId && x.RuleScope == rule.OperateRuleScope).FirstAsync(); + var currentRule = await tenantDb.Queryable().Where(x => x.PermissionId == item.ParentId && x.UserId == req.UserId).FirstAsync(); + if (currentRule.IsNull()) + { + if (currentTemplate.IsNotNull()) + { + newRules.Add(new CodeDataRule() + { + UserId = userInfo.Id, + UserName = userInfo.UserName, + OperateTemplateId = currentTemplate.Id, + OperateRuleScope = currentTemplate.RuleScope, + OperateRuleScopeName = currentTemplate.RuleScopeName, + PermissionEntity = currentTemplate.PermissionEntity, + PermissionId = currentTemplate.PermissionId, + Description = currentTemplate.Description, + Status = currentTemplate.Status, + Note = currentTemplate.Note, + }); + } + } + else + { + currentRule.OperateTemplateId = currentTemplate.Id; + currentRule.OperateRuleScope = currentTemplate.RuleScope; + currentRule.OperateRuleScopeName = currentTemplate.RuleScopeName; + + updateRules.Add(currentRule); + } + + } + if (newRules.Count > 0) + { + await tenantDb.Insertable(newRules).ExecuteCommandAsync(); + } + if (updateRules.Count > 0) + { + await tenantDb.Updateable(updateRules).ExecuteCommandAsync(); + } + await tenantDb.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + await tenantDb.Ado.RollbackTranAsync(); + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + + + return await Task.FromResult(DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess)); } /// diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs index ba806553..c3469b9e 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs @@ -104,13 +104,14 @@ namespace DS.WMS.Core.Code.Method /// 根据权限id获取数据权限模板 /// /// + /// /// - public async Task>> GetDataRuleTemplateSelectList(string id) + public async Task>> GetDataRuleTemplateSelectList(string id,string ruleType) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var data = await tenantDb.Queryable() - .Where(x => x.PermissionId == long.Parse(id) && x.Status == StatusEnum.Enable) + .Where(x => x.PermissionId == long.Parse(id) && x.Status == StatusEnum.Enable && x.RuleType == ruleType) .Select() .ToListAsync(); return await Task.FromResult(DataResult>.Success(data, MultiLanguageConst.DataQuerySuccess)); diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleController.cs index b3683468..51fc31c3 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleController.cs @@ -61,6 +61,31 @@ public class CodeDataRuleController : ApiController var res = await _invokeService.CopyDataRuleScope(req); return res; } + /// + /// 用户可视权限应用全部 + /// + /// + /// + [HttpPost] + [Route("UserVisibleDataRuleScopeApply")] + public async Task UserVisibleDataRuleScopeApply([FromBody] UserDataRuleScopeApplyReq req) + { + var res = await _invokeService.UserVisibleDataRuleScopeApply(req); + return res; + } + + /// + /// 用户操作权限应用全部 + /// + /// + /// + [HttpPost] + [Route("UserOperateDataRuleScopeApply")] + public async Task UserOperateDataRuleScopeApply([FromBody] UserDataRuleScopeApplyReq req) + { + var res = await _invokeService.UserOperateDataRuleScopeApply(req); + return res; + } ///// ///// 编辑 ///// diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs index ab1f8676..3f2d3304 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs @@ -40,12 +40,13 @@ public class CodeDataRuleTemplateController : ApiController /// 根据权限id获取数据权限模板 /// /// + /// /// [HttpPost] [Route("GetDataRuleTemplateSelectList")] - public async Task>> GetDataRuleTemplateSelectList([FromQuery] string id) + public async Task>> GetDataRuleTemplateSelectList([FromQuery] string id, string ruleType) { - var res = await _invokeService.GetDataRuleTemplateSelectList(id); + var res = await _invokeService.GetDataRuleTemplateSelectList(id,ruleType); return res; } ///