From e6fa12ede7ef62024466a06959f674e2b55a0e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Wed, 30 Oct 2024 10:48:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=89=B9=E9=87=8F=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs | 12 +++ .../Fee/Interface/IFeeCustTemplateService.cs | 14 +++ .../Fee/Method/FeeCustTemplateService.cs | 95 +++++++++++++++++++ .../Controllers/FeeCustTemplateController.cs | 30 +++++- 4 files changed, 150 insertions(+), 1 deletion(-) diff --git a/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs index bd7bcdb1..25e5d7a5 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs @@ -138,12 +138,24 @@ namespace DS.WMS.Core.Fee.Entity [SugarColumn(ColumnDescription = "业务来源ID", IsNullable = true)] public long? SourceId { get; set; } + /// + /// 业务来源明细ID + /// + [SugarColumn(ColumnDescription = "业务来源明细ID", IsNullable = true)] + public long? SourceDetailId { get; set; } + /// /// 订舱口ID /// [SugarColumn(ColumnDescription = "订舱口ID", IsNullable = true)] public long? ForwarderId { get; set; } + /// + /// 分公司ID + /// + [SugarColumn(ColumnDescription = "分公司ID", IsNullable = true)] + public long? DeptOrgId { get; set; } + /// /// 模板明细 /// diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs index bc1763c3..8a0929a8 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs @@ -45,6 +45,20 @@ namespace DS.WMS.Core.Fee.Interface /// Task EditAsync(FeeCustTemplate model); + /// + /// 批量编辑模板 + /// + /// + /// + Task BulkEditAsync(List list); + + /// + /// 批量编辑模板明细 + /// + /// + /// + Task BulkEditDetailsAsync(List details); + /// /// 根据ID批量删除 /// diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs index e54feceb..410b217a 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs @@ -61,8 +61,10 @@ namespace DS.WMS.Core.Fee.Method PODCode = x.PODCode, LaneId = x.LaneId, SourceId = x.SourceId, + SourceDetailId = x.SourceDetailId, CarrierId = x.CarrierId, ForwarderId = x.ForwarderId, + DeptOrgId = x.DeptOrgId, MBLFrtCode = x.MBLFrtCode, Condition = x.Condition }).ToListAsync(); @@ -186,9 +188,15 @@ namespace DS.WMS.Core.Fee.Method if (template.SourceId.HasValue && template.SourceId != order.SourceId) return null; + if (template.SourceDetailId.HasValue && template.SourceDetailId != order.SourceDetailId) + return null; + if (template.ForwarderId.HasValue && template.ForwarderId != order.ForwarderId) return null; + //if (template.DeptOrgId.HasValue && template.DeptOrgId != order.DeptOrgId) + // return null; + if (!string.IsNullOrEmpty(template.Condition)) //设置了自定义匹配条件 { var conditionModel = JsonConvert.DeserializeObject(template.Condition); @@ -558,6 +566,7 @@ namespace DS.WMS.Core.Fee.Method { if (model.Id == 0) { + model.DeptOrgId ??= User.OrgId; await TenantDb.InsertNav(model).Include(x => x.Details).ExecuteCommandAsync(); } else @@ -579,6 +588,92 @@ namespace DS.WMS.Core.Fee.Method } } + /// + /// 批量编辑模板 + /// + /// + /// + public async Task BulkEditAsync(List list) + { + int rows = await TenantDb.Updateable(list).UpdateColumns(x => new + { + x.StartTime, + x.EndTime, + x.IsDisabled, + x.FeeCategoryId, + x.FeeCategoryName, + x.Priority, + x.PODCode, + x.POLCode, + x.LaneId, + x.CarrierId, + x.MBLFrtCode, + x.SourceId, + x.SourceDetailId, + x.ForwarderId, + x.DeptOrgId + }).ExecuteCommandAsync(); + return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + + /// + /// 批量编辑模板明细 + /// + /// + /// + public async Task BulkEditDetailsAsync(List details) + { + var model = await TenantDb.Queryable() + .Where(x => x.Id == details[0].TemplateId).Select(x => new + { + x.CustomerId, + x.CustomerName, + x.FeeType + }).FirstAsync(); + if (model == null) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData)); + + foreach (var item in details) + { + item.TaxRate ??= 0; + item.AccTaxRate ??= 0; + item.Tax = Math.Round(item.TaxUnitPrice.GetValueOrDefault() - item.TaxRate.GetValueOrDefault() / 100 * item.TaxUnitPrice.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero); + item.UnitPrice = item.TaxUnitPrice - item.Tax.GetValueOrDefault(); + + if (item.ExchangeRate == null) + { + if (item.Currency == FeeCurrency.RMB_CODE) + { + item.ExchangeRate = 1m; + } + else + { + var er = await exchangeService.Value.GetExchangeRateAsync(new ExchangeRate + { + CurrencyFrom = item.Currency, + CurrencyTo = FeeCurrency.RMB_CODE, + FeeType = model.FeeType + }); + item.ExchangeRate = er.Data?.Rate; + } + } + + if (item.CustomerId == 0 && model.CustomerId.HasValue) + item.CustomerId = model.CustomerId.Value; + + if (string.IsNullOrEmpty(item.CustomerName)) + item.CustomerName = model.CustomerName; + } + + int rows = await TenantDb.Updateable(details).IgnoreColumns(x => new + { + x.TemplateId, + x.CreateTime, + x.CreateBy + }).ExecuteCommandAsync(); + return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + /// /// 根据ID批量删除 /// diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs index 6fbcfc91..fd07742f 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs @@ -139,6 +139,33 @@ namespace DS.WMS.FeeApi.Controllers return await _invokeService.EditAsync(model); } + /// + /// 批量编辑模板 + /// + /// + /// + [HttpPost, Route("BulkEdit")] + public async Task BulkEditAsync([FromBody] List list) + { + if (list == null || list.Count == 0) + return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest); + + return await _invokeService.BulkEditAsync(list); + } + + /// + /// 批量编辑模板明细 + /// + /// + /// + public async Task BulkEditDetailsAsync([FromBody] List details) + { + if (details == null || details.Count == 0) + return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest); + + return await _invokeService.BulkEditDetailsAsync(details); + } + /// /// 详情 /// @@ -167,10 +194,11 @@ namespace DS.WMS.FeeApi.Controllers /// /// 根据ID删除明细 /// + /// /// /// [HttpPost, Route("DeleteDetails")] - public async Task DeleteAsync([FromServices] IFeeCustTemplateDetailService detailService, [FromBody] IdModel model) + public async Task DeleteDetailsAsync([FromServices] IFeeCustTemplateDetailService detailService, [FromBody] IdModel model) { if (!ModelState.IsValid) return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);