|
@ -10,6 +10,7 @@ using Newtonsoft.Json.Linq; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Text.RegularExpressions; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Yitter.IdGenerator; |
|
|
using Yitter.IdGenerator; |
|
@ -22,14 +23,29 @@ namespace BBWY.Server.Business |
|
|
private TaskSchedulerManager taskSchedulerManager; |
|
|
private TaskSchedulerManager taskSchedulerManager; |
|
|
private OrderBusiness orderBusiness; |
|
|
private OrderBusiness orderBusiness; |
|
|
private MDSBusiness mdsBusiness; |
|
|
private MDSBusiness mdsBusiness; |
|
|
|
|
|
private VenderBusiness venderBusiness; |
|
|
|
|
|
|
|
|
|
|
|
private IDictionary<Enums.Platform, string> deliverySelfDic; |
|
|
|
|
|
|
|
|
public PurchaseOrderBusiness(IFreeSql fsql, NLog.ILogger logger, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList, TaskSchedulerManager taskSchedulerManager, OrderBusiness orderBusiness, MDSBusiness mdsBusiness) : base(fsql, logger, idGenerator) |
|
|
public PurchaseOrderBusiness(IFreeSql fsql, |
|
|
|
|
|
NLog.ILogger logger, |
|
|
|
|
|
IIdGenerator idGenerator, |
|
|
|
|
|
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList, |
|
|
|
|
|
TaskSchedulerManager taskSchedulerManager, |
|
|
|
|
|
OrderBusiness orderBusiness, |
|
|
|
|
|
MDSBusiness mdsBusiness, |
|
|
|
|
|
VenderBusiness venderBusiness) : 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; |
|
|
|
|
|
|
|
|
|
|
|
deliverySelfDic = new Dictionary<Enums.Platform, string>() |
|
|
|
|
|
{ |
|
|
|
|
|
{Enums.Platform.京东 , "1274"} //厂家自送
|
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest) |
|
|
public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest) |
|
@ -243,7 +259,14 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
|
#region 获取采购单的物流信息
|
|
|
#region 获取采购单的物流信息
|
|
|
currentProgress = "获取采购单的物流信息"; |
|
|
currentProgress = "获取采购单的物流信息"; |
|
|
|
|
|
var wayBillNoResponse = platformSDKBusinessList.FirstOrDefault(p => p.Platform == callbackPlatform).GetWayBillNoByOrderId(new QueryOrderWayBillNoRequest() |
|
|
|
|
|
{ |
|
|
|
|
|
AppKey = purchaseAccount.AppKey, |
|
|
|
|
|
AppSecret = purchaseAccount.AppSecret, |
|
|
|
|
|
AppToken = purchaseAccount.AppToken, |
|
|
|
|
|
OrderId = purchaseOrderId, |
|
|
|
|
|
Platform = callbackPlatform |
|
|
|
|
|
}); |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 查询采购账号的归属店铺
|
|
|
#region 查询采购账号的归属店铺
|
|
@ -252,11 +275,19 @@ namespace BBWY.Server.Business |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 获取目标平台的物流公司列表
|
|
|
#region 获取目标平台的物流公司列表
|
|
|
currentProgress = "获取目标平台物流公司列表"; |
|
|
currentProgress = "获取店铺平台物流公司列表"; |
|
|
|
|
|
var logisticsCompanyList = venderBusiness.GetLogisticsList(new PlatformRequest() |
|
|
|
|
|
{ |
|
|
|
|
|
AppKey = shop.AppKey, |
|
|
|
|
|
AppSecret = shop.AppSecret, |
|
|
|
|
|
AppToken = shop.AppToken, |
|
|
|
|
|
Platform = shop.Platform |
|
|
|
|
|
}); |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 物流公司翻译
|
|
|
#region 物流公司翻译
|
|
|
currentProgress = "将采购单的物流公司翻译为店铺平台的物流公司"; |
|
|
currentProgress = "将采购单的物流公司翻译为店铺平台的物流公司"; |
|
|
|
|
|
var logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 店铺平台订单出库
|
|
|
#region 店铺平台订单出库
|
|
@ -268,8 +299,8 @@ namespace BBWY.Server.Business |
|
|
AppToken = shop.AppToken, |
|
|
AppToken = shop.AppToken, |
|
|
OrderId = orderDropshipping.OrderId, |
|
|
OrderId = orderDropshipping.OrderId, |
|
|
Platform = shop.Platform, |
|
|
Platform = shop.Platform, |
|
|
WayBillNo = "", |
|
|
WayBillNo = wayBillNoResponse.WayBillNo, |
|
|
LogisticsId = "" |
|
|
LogisticsId = logisticsCompanyId //物流公司Id
|
|
|
}); |
|
|
}); |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
@ -278,5 +309,19 @@ namespace BBWY.Server.Business |
|
|
logger.Error(ex, $"回调平台{callbackPlatform},采购单号{purchaseOrderId},执行进度[{currentProgress}]"); |
|
|
logger.Error(ex, $"回调平台{callbackPlatform},采购单号{purchaseOrderId},执行进度[{currentProgress}]"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList<LogisticsResponse> 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]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|