Browse Source

财务端条件验证

qianyi
shanji 3 years ago
parent
commit
096b195950
  1. 7
      BBWY.Client/ViewModels/MainViewModel.cs
  2. 2
      BBWY.Client/Views/MainWindow.xaml
  3. 2
      BBWY.Server.Business/Order/OrderBusiness.cs
  4. 83
      BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs
  5. 61
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

7
BBWY.Client/ViewModels/MainViewModel.cs

@ -10,6 +10,7 @@ using Microsoft.Web.WebView2.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -85,7 +86,7 @@ namespace BBWY.Client.ViewModels
ChooseShopCommand = new RelayCommand<Shop>((s) => ChooseShop(s)); ChooseShopCommand = new RelayCommand<Shop>((s) => ChooseShop(s));
this.GlobalContext = globalContext; this.GlobalContext = globalContext;
ShopList = new ObservableCollection<Shop>(); ShopList = new ObservableCollection<Shop>();
MenuList = new List<MenuModel>() MenuList = new ObservableCollection<MenuModel>()
{ {
new MenuModel() new MenuModel()
{ {
@ -147,6 +148,10 @@ namespace BBWY.Client.ViewModels
throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}"); throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}");
GlobalContext.User = mdsUserResponse.Data.Map<User>(); GlobalContext.User = mdsUserResponse.Data.Map<User>();
#if RELEASE
if (GlobalContext.User.TeamName != "财务部")
App.Current.Dispatcher.Invoke(() => MenuList.RemoveAt(MenuList.Count() - 1));
#endif
//请求用户信息接口 //请求用户信息接口
//GlobalContext.User = new User() //GlobalContext.User = new User()

2
BBWY.Client/Views/MainWindow.xaml

@ -26,7 +26,7 @@
<!--<TextBlock Text="{Binding GlobalContext.User.TeamName}" Margin="5,0,0,0"/> <!--<TextBlock Text="{Binding GlobalContext.User.TeamName}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" Margin="5,0,0,0"/>--> <TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" Margin="5,0,0,0"/>-->
<TextBlock Text="{Binding GlobalContext.User.Shop.Name}" Margin="5,0,0,0"/> <TextBlock Text="{Binding GlobalContext.User.Shop.Name}" Margin="5,0,0,0"/>
<TextBlock Text="v10013" Margin="5,0,0,0"/> <TextBlock Text="v10015" Margin="5,0,0,0"/>
</StackPanel> </StackPanel>
</Border> </Border>
<Grid Grid.Row="1"> <Grid Grid.Row="1">

2
BBWY.Server.Business/Order/OrderBusiness.cs

@ -887,7 +887,7 @@ namespace BBWY.Server.Business
PageSize = 100, PageSize = 100,
Platform = shop.Platform, Platform = shop.Platform,
JDColType = string.IsNullOrEmpty(shop.VenderType) ? "0" : shop.VenderType, JDColType = string.IsNullOrEmpty(shop.VenderType) ? "0" : shop.VenderType,
SaveResponseLog = true, SaveResponseLog = false,
OrderId = orderId OrderId = orderId
}, null, HttpMethod.Post); }, null, HttpMethod.Post);
if (orderListApiResult.StatusCode != System.Net.HttpStatusCode.OK) if (orderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)

83
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<string, IList<LogisticsCompanyRelationship>> converterDictionary;
public LogisticsCompanyConverter()
{
converterDictionary = new Dictionary<string, IList<LogisticsCompanyRelationship>>();
converterDictionary.Add($"{Enums.Platform.阿里巴巴}_{Enums.Platform.京东}", new List<LogisticsCompanyRelationship>()
{
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="厂家自送"}
});
}
/// <summary>
/// 翻译各平台之间的物流公司
/// </summary>
/// <param name="sourceName"></param>
/// <param name="sourcePlatform"></param>
/// <param name="targetPlatform"></param>
/// <param name="targetPlatformUserLogisticsCompanyList">用户支持的目标平台物流公司</param>
/// <returns>目标平台的物流公司Id</returns>
public string Converter(string sourceName,
Enums.Platform sourcePlatform,
Enums.Platform targetPlatform,
IList<LogisticsResponse> targetPlatformUserLogisticsCompanyList)
{
var key = $"{sourcePlatform}_{targetPlatform}";
if (!converterDictionary.TryGetValue(key, out IList<LogisticsCompanyRelationship> 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; }
}
}

61
BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -25,8 +25,8 @@ namespace BBWY.Server.Business
private OrderBusiness orderBusiness; private OrderBusiness orderBusiness;
private MDSBusiness mdsBusiness; private MDSBusiness mdsBusiness;
private VenderBusiness venderBusiness; private VenderBusiness venderBusiness;
private LogisticsCompanyConverter logisticsCompanyConverter;
private IDictionary<Enums.Platform, string> deliverySelfDic; //private IDictionary<Enums.Platform, string> deliverySelfDic;
public PurchaseOrderBusiness(IFreeSql fsql, public PurchaseOrderBusiness(IFreeSql fsql,
NLog.ILogger logger, NLog.ILogger logger,
@ -35,18 +35,19 @@ namespace BBWY.Server.Business
TaskSchedulerManager taskSchedulerManager, TaskSchedulerManager taskSchedulerManager,
OrderBusiness orderBusiness, OrderBusiness orderBusiness,
MDSBusiness mdsBusiness, MDSBusiness mdsBusiness,
VenderBusiness venderBusiness) : base(fsql, logger, idGenerator) VenderBusiness venderBusiness,
LogisticsCompanyConverter logisticsCompanyConverter) : base(fsql, logger, idGenerator)
{ {
this.platformSDKBusinessList = platformSDKBusinessList; this.platformSDKBusinessList = platformSDKBusinessList;
this.taskSchedulerManager = taskSchedulerManager; this.taskSchedulerManager = taskSchedulerManager;
this.orderBusiness = orderBusiness; this.orderBusiness = orderBusiness;
this.mdsBusiness = mdsBusiness; this.mdsBusiness = mdsBusiness;
this.venderBusiness = venderBusiness; this.venderBusiness = venderBusiness;
this.logisticsCompanyConverter = logisticsCompanyConverter;
deliverySelfDic = new Dictionary<Enums.Platform, string>() //deliverySelfDic = new Dictionary<Enums.Platform, string>()
{ //{
{Enums.Platform. , "1274"} //厂家自送 // {Enums.Platform.京东 , "1274"} //厂家自送
}; //};
} }
public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest) public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest)
@ -507,8 +508,9 @@ namespace BBWY.Server.Business
#endregion #endregion
#region 物流公司翻译 #region 物流公司翻译
currentProgress = "将采购单的物流公司翻译为店铺平台的物流公司"; currentProgress = "物流公司翻译";
logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); //logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform);
logisticsCompanyId = logisticsCompanyConverter.Converter(wayBillNoResponse.LogisticsCompanyName, callbackPlatform, shop.Platform, logisticsCompanyList);
#endregion #endregion
#region 店铺平台订单出库 #region 店铺平台订单出库
@ -533,25 +535,26 @@ namespace BBWY.Server.Business
} }
} }
/// <summary> ///// <summary>
/// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司 ///// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司
/// </summary> ///// </summary>
/// <param name="sourceLogisticsCompanyName"></param> ///// <param name="sourceLogisticsCompanyName"></param>
/// <param name="targetLogisticsList"></param> ///// <param name="targetLogisticsList"></param>
/// <param name="tagetLogisticsPlatform"></param> ///// <param name="tagetLogisticsPlatform"></param>
/// <returns></returns> ///// <returns></returns>
private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList<LogisticsResponse> targetLogisticsList, Enums.Platform tagetLogisticsPlatform) //private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList<LogisticsResponse> targetLogisticsList, Enums.Platform tagetLogisticsPlatform)
{ //{
var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)"); // var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)");
if (match.Success) // if (match.Success)
{ // {
var sname = match.Groups[1].Value; // var sname = match.Groups[1].Value;
var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Name.Contains(sname)); // var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Name.Contains(sname));
if (targetLogistics != null) // if (targetLogistics != null)
return targetLogistics.Id; // return targetLogistics.Id;
} // }
return deliverySelfDic[tagetLogisticsPlatform]; // return deliverySelfDic[tagetLogisticsPlatform];
} //}
/// <summary> /// <summary>
/// 采购平台改价回调 /// 采购平台改价回调

Loading…
Cancel
Save