From 5c5df7837881f644ad575b07213e3f37d45dc546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Thu, 17 Oct 2024 10:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=9B=B8=E5=85=B3=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Info/Method/ClientBankService.cs | 65 ++++++++++--------- .../Info/Method/ClientContactService.cs | 49 +++++++------- .../Info/Method/ClientInfoService.cs | 8 +-- .../Controllers/ClientInfoController.cs | 4 +- 4 files changed, 68 insertions(+), 58 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs index eab7dbaa..d9136fdb 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs @@ -123,13 +123,15 @@ public class ClientBankService : ServiceBase, IClientBankService { long userId = long.Parse(User.UserId); DateTime dtNow = DateTime.Now; - + TenantDb.QueryFilter.Clear(); + TenantDb.QueryFilter.Clear(); var clientNames = list.Select(x => x.CompanyName).Distinct(); - var clients = await TenantDb.Queryable().Where(x => clientNames.Contains(x.ShortName)) + var clients = await TenantDb.Queryable().Where(x => clientNames.Contains(x.ShortName) || clientNames.Contains(x.Description)) .Select(x => new { x.Id, x.ShortName, + x.Description, x.OrgId }).ToListAsync(); @@ -137,40 +139,43 @@ public class ClientBankService : ServiceBase, IClientBankService List banks = new List(list.Count); foreach (var model in list) { - var client = clients.Find(x => x.ShortName == model.CompanyName); - if (client == null) + var clientList = clients.FindAll(x => x.ShortName == model.CompanyName || x.Description == model.CompanyName); + if (clientList.Count == 0) { sb.Append("," + model.CompanyName); continue; } - InfoClientBank bank = new() - { - ClientId = client.Id, - OrgId = client.OrgId, - BankName = model.BankName, - Account = model.BankAccount, - BankAddress = model.BankAddress, - BankAccountNo = model.BankAccount, - IsInvoiceDefault = model.IsDefault, - CreateBy = userId, - CreateUserName = User.UserName, - CreateTime = dtNow, - InvoiceHeaders = [] - }; - - if (model.Currency == "人民币") - bank.Currency = FeeCurrency.RMB_CODE; - else if (model.Currency == "美元") - bank.Currency = FeeCurrency.USD_CODE; - - bank.InvoiceHeaders.Add(new InvoiceHeader + foreach (var item in clientList) { - Header = model.InvoiceHeader, - AddressTel = model.InvoiceAddress + " " + model.InvoiceTel - }); - - banks.Add(bank); + InfoClientBank bank = new() + { + ClientId = item.Id, + OrgId = item.OrgId, + BankName = model.BankName, + Account = model.BankAccount, + BankAddress = model.BankAddress, + BankAccountNo = model.BankAccount, + IsInvoiceDefault = model.IsDefault, + CreateBy = userId, + CreateUserName = User.UserName, + CreateTime = dtNow, + InvoiceHeaders = [] + }; + + if (model.Currency == "人民币") + bank.Currency = FeeCurrency.RMB_CODE; + else if (model.Currency == "美元") + bank.Currency = FeeCurrency.USD_CODE; + + bank.InvoiceHeaders.Add(new InvoiceHeader + { + Header = model.InvoiceHeader, + AddressTel = model.InvoiceAddress + " " + model.InvoiceTel + }); + + banks.Add(bank); + } } if (sb.Length > 0) diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientContactService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientContactService.cs index a17d776a..407fd1d7 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientContactService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientContactService.cs @@ -100,45 +100,50 @@ public class ClientContactService : ServiceBase, IClientContactService { long userId = long.Parse(User.UserId); DateTime dtNow = DateTime.Now; - + TenantDb.QueryFilter.Clear(); + TenantDb.QueryFilter.Clear(); var clientNames = list.Select(x => x.CompanyName).Distinct(); - var clients = await TenantDb.Queryable().Where(x => clientNames.Contains(x.ShortName)) + var clients = await TenantDb.Queryable().Where(x => clientNames.Contains(x.ShortName) || clientNames.Contains(x.Description)) .Select(x => new { x.Id, x.ShortName, + x.Description, x.OrgId }).ToListAsync(); StringBuilder sb = new(); - List contacts = new List(list.Count); + List contacts = new(list.Count * 2); foreach (var model in list) { - var client = clients.Find(x => x.ShortName == model.CompanyName); - if (client == null) + var clientList = clients.FindAll(x => x.ShortName == model.CompanyName || x.Description == model.CompanyName); + if (clientList.Count == 0) { sb.Append("," + model.CompanyName); continue; } - InfoClientContact contact = new() + foreach (var item in clientList) { - ClientId = client.Id, - OrgId = client.OrgId, - CreateBy = userId, - CreateUserName = User.UserName, - CreateTime = dtNow, - Name = model.ContactName, - EnName = model.ContactEnName, - Job = model.Job, - Email = model.Email, - Mobile = model.Mobile, - Tel = model.Tel, - QQ = model.QQ, - IsDefault = model.IsDefault - }; - - contacts.Add(contact); + InfoClientContact contact = new() + { + ClientId = item.Id, + OrgId = item.OrgId, + CreateBy = userId, + CreateUserName = User.UserName, + CreateTime = dtNow, + Name = model.ContactName, + EnName = model.ContactEnName, + Job = model.Job, + Email = model.Email, + Mobile = model.Mobile, + Tel = model.Tel, + QQ = model.QQ, + IsDefault = model.IsDefault + }; + + contacts.Add(contact); + } } if (sb.Length > 0) diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs index 064a9988..dcdc7646 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs @@ -318,13 +318,13 @@ public class ClientInfoService : ServiceBase, IClientInfoService AccountDates = [] }; - var dicValue = dicList.Find(x => x.Name == model.Attribute)?.Value; - if (!string.IsNullOrEmpty(dicValue)) + var dicValues = dicList.FindAll(x => model.AttributeNames.Contains(x.Name)); + foreach (var item in dicValues) { - dicValue = dicValue.ToUpperCamelCase(); + var dicValue = item.Value.ToUpperCamelCase(); PropertyExtensions.SetPropertyValue(client.ClientTag, dicValue, true); } - + client.AccountDates.Add(new InfoClientAccountDate { AccountType = model.StlType, diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs index 2d908ad9..2ce271aa 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs @@ -357,7 +357,7 @@ public class ClientInfoController : ApiController { var model = new InfoClientBankModel { - CompanyName = item["A"]?.ToString(), + CompanyName = item["A"]?.ToString()?.Trim(), Currency = item["B"]?.ToString(), BankName = item["C"]?.ToString(), BankAccount = item["E"]?.ToString(), @@ -415,7 +415,7 @@ public class ClientInfoController : ApiController { var model = new InfoClientContactModel { - CompanyName = item["A"]?.ToString(), + CompanyName = item["A"]?.ToString()?.Trim(), ContactName = item["B"]?.ToString(), ContactEnName = item["C"]?.ToString(), Tel = item["D"]?.ToString(),