diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index d8532351..f893d0fc 100644 --- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs +++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs @@ -431,6 +431,7 @@ namespace BBWY.Server.Business string currentProgress = string.Empty; string wayBillNoResponseInfo = string.Empty; string logisticsCompanyListInfo = string.Empty; + string logisticsCompanyId = string.Empty; try { #region 查询代发信息 @@ -484,7 +485,7 @@ namespace BBWY.Server.Business #region 物流公司翻译 currentProgress = "将采购单的物流公司翻译为店铺平台的物流公司"; - var logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); + logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); #endregion #region 店铺平台订单出库 @@ -503,7 +504,7 @@ namespace BBWY.Server.Business } catch (Exception ex) { - logger.Error(ex, $"DeliveryCallback 回调平台{callbackPlatform},采购单号{purchaseOrderId},执行进度[{currentProgress}],采购单物流信息:{wayBillNoResponseInfo},店铺平台物流公司列表:{logisticsCompanyListInfo}"); + logger.Error(ex, $"DeliveryCallback 回调平台{callbackPlatform},采购单号{purchaseOrderId},执行进度[{currentProgress}],采购单物流信息:{wayBillNoResponseInfo},店铺平台物流公司列表:{logisticsCompanyListInfo},翻译后的物流公司Id:{logisticsCompanyId}"); } } diff --git a/BBWY.Test/BBWY.Test.csproj b/BBWY.Test/BBWY.Test.csproj new file mode 100644 index 00000000..58bb9eb0 --- /dev/null +++ b/BBWY.Test/BBWY.Test.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs new file mode 100644 index 00000000..8246a3d1 --- /dev/null +++ b/BBWY.Test/Program.cs @@ -0,0 +1,41 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; + +namespace BBWY.Test +{ + internal class Program + { + + + static void Main(string[] args) + { + IDictionary deliverySelfDic = new Dictionary() + { + {2 , "1274"} //厂家自送 + }; + var wayBillNoResponse = JObject.Parse("{\"LogisticsCompanyId\":\"100\",\"LogisticsCompanyName\":\"申通快递(STO)\",\"WayBillNo\":\"773159209682541\"}"); + var logisticsCompanyList = JArray.Parse("[{\"Id\":\"2087\",\"Name\":\"京东快递\"},{\"Id\":\"463\",\"Name\":\"圆通快递\"},{\"Id\":\"2170\",\"Name\":\"邮政快递包裹\"},{\"Id\":\"1327\",\"Name\":\"韵达快递\"},{\"Id\":\"680414\",\"Name\":\"中通快运\"},{\"Id\":\"467\",\"Name\":\"顺丰快递\"},{\"Id\":\"256122\",\"Name\":\"UPS\"},{\"Id\":\"1747\",\"Name\":\"优速快递\"},{\"Id\":\"3046\",\"Name\":\"德邦快递\"},{\"Id\":\"465\",\"Name\":\"邮政EMS\"},{\"Id\":\"1665004\",\"Name\":\"云仓速递\"},{\"Id\":\"4832\",\"Name\":\"安能物流\"},{\"Id\":\"1499\",\"Name\":\"中通速递\"}]"); + + var companyId = ConvertLogisticsCompanyId(wayBillNoResponse.Value("LogisticsCompanyName"), logisticsCompanyList, 2, deliverySelfDic); + Console.WriteLine(companyId); + Console.ReadKey(); + } + + + private static string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList targetLogisticsList, int tagetLogisticsPlatform, IDictionary deliverySelfDic) + { + var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)"); + if (match.Success) + { + var sname = match.Groups[1].Value; + var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Value("Name").Contains(sname)); + if (targetLogistics != null) + return targetLogistics.Value("Id"); + } + return deliverySelfDic[tagetLogisticsPlatform]; + } + } +} diff --git a/BBWY.sln b/BBWY.sln index d545c4d3..efd5d059 100644 --- a/BBWY.sln +++ b/BBWY.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30225.117 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBWY.Client", "BBWY.Client\BBWY.Client.csproj", "{04DAF636-2630-45BB-BEFA-264EC273E920}" EndProject @@ -30,7 +30,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BBWY.1688SDK", "BBWY.1688SDK\BBWY.1688SDK.csproj", "{1A7EB438-5DEF-4940-8CB2-C58141C75524}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBWY.1688SDK", "BBWY.1688SDK\BBWY.1688SDK.csproj", "{1A7EB438-5DEF-4940-8CB2-C58141C75524}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BBWY.Test", "BBWY.Test\BBWY.Test.csproj", "{FCD5E03E-DA48-406B-9AA8-F72F21F62BDB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -74,6 +76,10 @@ Global {1A7EB438-5DEF-4940-8CB2-C58141C75524}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A7EB438-5DEF-4940-8CB2-C58141C75524}.Release|Any CPU.ActiveCfg = Release|Any CPU {1A7EB438-5DEF-4940-8CB2-C58141C75524}.Release|Any CPU.Build.0 = Release|Any CPU + {FCD5E03E-DA48-406B-9AA8-F72F21F62BDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FCD5E03E-DA48-406B-9AA8-F72F21F62BDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FCD5E03E-DA48-406B-9AA8-F72F21F62BDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCD5E03E-DA48-406B-9AA8-F72F21F62BDB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -87,6 +93,7 @@ Global {E38A95F5-05E6-4856-811C-30D7A1B77C68} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5} {2DC24A1B-EFE0-4F9D-8A9A-A6B530696E17} = {B131026A-2025-4A74-ABF1-644059FADF78} {1A7EB438-5DEF-4940-8CB2-C58141C75524} = {B131026A-2025-4A74-ABF1-644059FADF78} + {FCD5E03E-DA48-406B-9AA8-F72F21F62BDB} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CC045257-4D86-45FD-A1F0-2715C024F1B5}