diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index d69f0a91..ce436eae 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -10,6 +10,7 @@ using Microsoft.Web.WebView2.Core; using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -85,7 +86,7 @@ namespace BBWY.Client.ViewModels ChooseShopCommand = new RelayCommand((s) => ChooseShop(s)); this.GlobalContext = globalContext; ShopList = new ObservableCollection(); - MenuList = new List() + MenuList = new ObservableCollection() { new MenuModel() { @@ -147,6 +148,10 @@ namespace BBWY.Client.ViewModels throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}"); GlobalContext.User = mdsUserResponse.Data.Map(); +#if RELEASE + if (GlobalContext.User.TeamName != "财务部") + App.Current.Dispatcher.Invoke(() => MenuList.RemoveAt(MenuList.Count() - 1)); +#endif //请求用户信息接口 //GlobalContext.User = new User() @@ -272,6 +277,6 @@ namespace BBWY.Client.ViewModels { Wb2DownloadProgress = e.ProgressPercentage; } - #endregion +#endregion } } diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index 5b40ec27..6e3fb1f5 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -26,7 +26,7 @@ - + diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs index b5d2fe24..d3b4dbbc 100644 --- a/BBWY.Server.Business/Order/OrderBusiness.cs +++ b/BBWY.Server.Business/Order/OrderBusiness.cs @@ -887,7 +887,7 @@ namespace BBWY.Server.Business PageSize = 100, Platform = shop.Platform, JDColType = string.IsNullOrEmpty(shop.VenderType) ? "0" : shop.VenderType, - SaveResponseLog = true, + SaveResponseLog = false, OrderId = orderId }, null, HttpMethod.Post); if (orderListApiResult.StatusCode != System.Net.HttpStatusCode.OK) diff --git a/BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs b/BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs new file mode 100644 index 00000000..9d47c321 --- /dev/null +++ b/BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs @@ -0,0 +1,83 @@ +using BBWY.Common.Models; +using BBWY.Server.Model; +using BBWY.Server.Model.Dto; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BBWY.Server.Business +{ + public class LogisticsCompanyConverter : IDenpendency + { + private IDictionary> converterDictionary; + + public LogisticsCompanyConverter() + { + converterDictionary = new Dictionary>(); + converterDictionary.Add($"{Enums.Platform.阿里巴巴}_{Enums.Platform.京东}", new List() + { + new LogisticsCompanyRelationship(){SourceName="中通快递(ZTO)",TargetName="中通速递"}, + new LogisticsCompanyRelationship(){SourceName="圆通速递(YTO)",TargetName="圆通快递"}, + new LogisticsCompanyRelationship(){SourceName="邮政国内小包",TargetName="邮政快递包裹"}, + new LogisticsCompanyRelationship(){SourceName="韵达快递",TargetName="韵达快递"}, + new LogisticsCompanyRelationship(){SourceName="申通快递(STO)",TargetName="厂家自送"}, + new LogisticsCompanyRelationship(){SourceName="顺丰速运",TargetName="顺丰快递"}, + new LogisticsCompanyRelationship(){SourceName="百世快递",TargetName="厂家自送"}, + new LogisticsCompanyRelationship(){SourceName="其他",TargetName="厂家自送"}, + new LogisticsCompanyRelationship(){SourceName="德邦",TargetName="德邦物流"}, + new LogisticsCompanyRelationship(){SourceName="EMS",TargetName="邮政快递包裹"}, + new LogisticsCompanyRelationship(){SourceName="德邦快递",TargetName="德邦快运"}, + new LogisticsCompanyRelationship(){SourceName="其它",TargetName="厂家自送"}, + new LogisticsCompanyRelationship(){SourceName="极兔速递",TargetName="厂家自送"}, + new LogisticsCompanyRelationship(){SourceName="中通快运",TargetName="中通快运"}, + new LogisticsCompanyRelationship(){SourceName="龙邦速递",TargetName="龙邦快递"}, + new LogisticsCompanyRelationship(){SourceName="安能物流",TargetName="安能物流"}, + new LogisticsCompanyRelationship(){SourceName="德坤物流",TargetName="厂家自送"}, + new LogisticsCompanyRelationship(){SourceName="顺丰快运",TargetName="顺丰快递"}, + new LogisticsCompanyRelationship(){SourceName="壹米滴答",TargetName="壹米滴答"}, + new LogisticsCompanyRelationship(){SourceName="优速快递",TargetName="优速快递"}, + new LogisticsCompanyRelationship(){SourceName="京广速递",TargetName="厂家自送"}, + new LogisticsCompanyRelationship(){SourceName="丰网速运",TargetName="丰网速运"}, + new LogisticsCompanyRelationship(){SourceName="顺心捷达",TargetName="顺心捷达"}, + new LogisticsCompanyRelationship(){SourceName="快捷快递",TargetName="快捷速递"}, + new LogisticsCompanyRelationship(){SourceName="极兔快递(原百世快递)",TargetName="厂家自送"} + }); + } + + /// + /// 翻译各平台之间的物流公司 + /// + /// + /// + /// + /// 用户支持的目标平台物流公司 + /// 目标平台的物流公司Id + public string Converter(string sourceName, + Enums.Platform sourcePlatform, + Enums.Platform targetPlatform, + IList targetPlatformUserLogisticsCompanyList) + { + var key = $"{sourcePlatform}_{targetPlatform}"; + if (!converterDictionary.TryGetValue(key, out IList companyRelationShips)) + throw new BusinessException($"不支持{sourcePlatform}与{targetPlatform}的物流公司翻译"); + + var targetShip = companyRelationShips.FirstOrDefault(l => l.SourceName == sourceName); + if (targetShip == null) + throw new BusinessException($"sourcePlatform:{sourcePlatform},targetPlatform:{targetPlatform},未找到{sourcePlatform}的物流公司{sourceName}"); + + var logisiticsCompany = targetPlatformUserLogisticsCompanyList.FirstOrDefault(c => c.Name.Equals(targetShip.TargetName)); + if (logisiticsCompany == null) + throw new BusinessException($"sourcePlatform:{sourcePlatform},targetPlatform:{targetPlatform},targetShip:{targetShip.TargetName},在用户支持的物流公司中不存在"); + + return logisiticsCompany.Id; + } + } + + public class LogisticsCompanyRelationship + { + public string SourceName { get; set; } + + public string TargetName { get; set; } + } +} diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index a309612b..585e1e8b 100644 --- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs +++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs @@ -25,8 +25,8 @@ namespace BBWY.Server.Business private OrderBusiness orderBusiness; private MDSBusiness mdsBusiness; private VenderBusiness venderBusiness; - - private IDictionary deliverySelfDic; + private LogisticsCompanyConverter logisticsCompanyConverter; + //private IDictionary deliverySelfDic; public PurchaseOrderBusiness(IFreeSql fsql, NLog.ILogger logger, @@ -35,18 +35,19 @@ namespace BBWY.Server.Business TaskSchedulerManager taskSchedulerManager, OrderBusiness orderBusiness, MDSBusiness mdsBusiness, - VenderBusiness venderBusiness) : base(fsql, logger, idGenerator) + VenderBusiness venderBusiness, + LogisticsCompanyConverter logisticsCompanyConverter) : base(fsql, logger, idGenerator) { this.platformSDKBusinessList = platformSDKBusinessList; this.taskSchedulerManager = taskSchedulerManager; this.orderBusiness = orderBusiness; this.mdsBusiness = mdsBusiness; this.venderBusiness = venderBusiness; - - deliverySelfDic = new Dictionary() - { - {Enums.Platform.京东 , "1274"} //厂家自送 - }; + this.logisticsCompanyConverter = logisticsCompanyConverter; + //deliverySelfDic = new Dictionary() + //{ + // {Enums.Platform.京东 , "1274"} //厂家自送 + //}; } public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest) @@ -507,8 +508,9 @@ namespace BBWY.Server.Business #endregion #region 物流公司翻译 - currentProgress = "将采购单的物流公司翻译为店铺平台的物流公司"; - logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); + currentProgress = "物流公司翻译"; + //logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); + logisticsCompanyId = logisticsCompanyConverter.Converter(wayBillNoResponse.LogisticsCompanyName, callbackPlatform, shop.Platform, logisticsCompanyList); #endregion #region 店铺平台订单出库 @@ -533,25 +535,26 @@ namespace BBWY.Server.Business } } - /// - /// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司 - /// - /// - /// - /// - /// - private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList targetLogisticsList, Enums.Platform tagetLogisticsPlatform) - { - var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)"); - if (match.Success) - { - var sname = match.Groups[1].Value; - var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Name.Contains(sname)); - if (targetLogistics != null) - return targetLogistics.Id; - } - return deliverySelfDic[tagetLogisticsPlatform]; - } + ///// + ///// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司 + ///// + ///// + ///// + ///// + ///// + //private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList targetLogisticsList, Enums.Platform tagetLogisticsPlatform) + //{ + // var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)"); + // if (match.Success) + // { + // var sname = match.Groups[1].Value; + // var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Name.Contains(sname)); + // if (targetLogistics != null) + // return targetLogistics.Id; + // } + // return deliverySelfDic[tagetLogisticsPlatform]; + //} + /// /// 采购平台改价回调