|
@ -220,6 +220,32 @@ namespace BBWY.Server.Business |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region CallBack
|
|
|
|
|
|
|
|
|
|
|
|
#region 1688CallBack
|
|
|
|
|
|
public void CallbackFrom1688(string jsonStr) |
|
|
|
|
|
{ |
|
|
|
|
|
logger.Info(jsonStr); |
|
|
|
|
|
var jObject = JObject.Parse(jsonStr); |
|
|
|
|
|
var type = jObject.Value<string>("type").ToUpper(); |
|
|
|
|
|
switch (type) |
|
|
|
|
|
{ |
|
|
|
|
|
case "ORDER_BUYER_VIEW_PART_PART_SENDGOODS": //部分发货
|
|
|
|
|
|
case "ORDER_BUYER_VIEW_ANNOUNCE_SENDGOODS": //发货
|
|
|
|
|
|
DeliveryCallbackFrom1688(jObject); |
|
|
|
|
|
break; |
|
|
|
|
|
case "ORDER_BUYER_VIEW_ORDER_PRICE_MODIFY": |
|
|
|
|
|
OrderPriceModificationCallbackFrom1688(jObject); //订单改价
|
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 1688发货回调(即将废弃)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="jsonStr"></param>
|
|
|
public void DeliveryCallbackFrom1688(string jsonStr) |
|
|
public void DeliveryCallbackFrom1688(string jsonStr) |
|
|
{ |
|
|
{ |
|
|
logger.Info(jsonStr); |
|
|
logger.Info(jsonStr); |
|
@ -228,15 +254,29 @@ namespace BBWY.Server.Business |
|
|
Task.Factory.StartNew(() => DeliveryCallback(purchaseOrderId, Enums.Platform.阿里巴巴), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler); |
|
|
Task.Factory.StartNew(() => DeliveryCallback(purchaseOrderId, Enums.Platform.阿里巴巴), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void DeliveryCallbackFromPDD(object param) |
|
|
/// <summary>
|
|
|
|
|
|
/// 1688发货回调
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="jObject"></param>
|
|
|
|
|
|
private void DeliveryCallbackFrom1688(JObject jObject) |
|
|
|
|
|
{ |
|
|
|
|
|
var purchaseOrderId = jObject["data"].Value<string>("orderId"); |
|
|
|
|
|
Task.Factory.StartNew(() => DeliveryCallback(purchaseOrderId, Enums.Platform.阿里巴巴), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 1688订单改价回调
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="jObject"></param>
|
|
|
|
|
|
private void OrderPriceModificationCallbackFrom1688(JObject jObject) |
|
|
{ |
|
|
{ |
|
|
var orderJObject = JObject.Parse(param.ToString()); |
|
|
var purchaseOrderId = jObject["data"].Value<string>("orderId"); |
|
|
var purchaseOrderId = orderJObject.Value<string>("orderId"); |
|
|
Task.Factory.StartNew(() => OrderPriceModificationCallback(purchaseOrderId, Enums.Platform.阿里巴巴), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler); |
|
|
Task.Factory.StartNew(() => DeliveryCallback(purchaseOrderId, Enums.Platform.拼多多), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 采购平台回调核心流程
|
|
|
/// 采购平台发货回调
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="purchaseOrderId"></param>
|
|
|
/// <param name="purchaseOrderId"></param>
|
|
|
/// <param name="callbackPlatform"></param>
|
|
|
/// <param name="callbackPlatform"></param>
|
|
@ -245,11 +285,11 @@ namespace BBWY.Server.Business |
|
|
string currentProgress = string.Empty; |
|
|
string currentProgress = string.Empty; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
#region 查询采购单
|
|
|
#region 查询代发信息
|
|
|
currentProgress = "查询采购单"; |
|
|
currentProgress = "查询代发信息"; |
|
|
var orderDropshipping = fsql.Select<OrderDropShipping>().Where(o => o.PurchaseOrderId == purchaseOrderId).ToOne(); |
|
|
var orderDropshipping = fsql.Select<OrderDropShipping>().Where(o => o.PurchaseOrderId == purchaseOrderId).ToOne(); |
|
|
if (orderDropshipping == null) |
|
|
if (orderDropshipping == null) |
|
|
throw new Exception("未查询到采购单号"); |
|
|
throw new Exception("未查询到代发信息"); |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 查询采购账号
|
|
|
#region 查询采购账号
|
|
@ -310,10 +350,17 @@ namespace BBWY.Server.Business |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
|
logger.Error(ex, $"回调平台{callbackPlatform},采购单号{purchaseOrderId},执行进度[{currentProgress}]"); |
|
|
logger.Error(ex, $"DeliveryCallback 回调平台{callbackPlatform},采购单号{purchaseOrderId},执行进度[{currentProgress}]"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sourceLogisticsCompanyName"></param>
|
|
|
|
|
|
/// <param name="targetLogisticsList"></param>
|
|
|
|
|
|
/// <param name="tagetLogisticsPlatform"></param>
|
|
|
|
|
|
/// <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|德邦|百世|天天|优速)"); |
|
@ -327,5 +374,65 @@ namespace BBWY.Server.Business |
|
|
return deliverySelfDic[tagetLogisticsPlatform]; |
|
|
return deliverySelfDic[tagetLogisticsPlatform]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 采购平台改价回调
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="purchaseOrderId"></param>
|
|
|
|
|
|
/// <param name="callbackPlatform"></param>
|
|
|
|
|
|
private void OrderPriceModificationCallback(string purchaseOrderId, Enums.Platform callbackPlatform) |
|
|
|
|
|
{ |
|
|
|
|
|
string currentProgress = string.Empty; |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
#region 查询代发信息
|
|
|
|
|
|
currentProgress = "查询代发信息"; |
|
|
|
|
|
var orderDropshipping = fsql.Select<OrderDropShipping>().Where(o => o.PurchaseOrderId == purchaseOrderId).ToOne(); |
|
|
|
|
|
if (orderDropshipping == null) |
|
|
|
|
|
throw new Exception("未查询到代发信息"); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 查询采购账号
|
|
|
|
|
|
currentProgress = "查询采购账号"; |
|
|
|
|
|
var purchaseAccount = fsql.Select<PurchaseAccount>().WhereIf(orderDropshipping.PurchaseAccountId != 0, pa => pa.Id == orderDropshipping.PurchaseAccountId) |
|
|
|
|
|
.WhereIf(orderDropshipping.PurchaseAccountId == 0, pa => pa.AccountName == orderDropshipping.BuyerAccount) |
|
|
|
|
|
.Where(pa => pa.PurchasePlatformId == callbackPlatform).ToOne(); |
|
|
|
|
|
if (purchaseAccount == null) |
|
|
|
|
|
throw new Exception($"未查询到采购账号{orderDropshipping.BuyerAccount}"); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 查询订单Sku
|
|
|
|
|
|
currentProgress = "查询订单Sku"; |
|
|
|
|
|
var orderSku = fsql.Select<OrderSku>().Where(osku => osku.OrderId == orderDropshipping.OrderId).ToOne(); |
|
|
|
|
|
if (orderSku == null) |
|
|
|
|
|
throw new BusinessException("订单Sku不存在"); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 查询改价后的订单金额
|
|
|
|
|
|
var orderAmountResponse = platformSDKBusinessList.FirstOrDefault(p => p.Platform == callbackPlatform).GetOrderAmountInfo(new GetOrderInfoRequest() |
|
|
|
|
|
{ |
|
|
|
|
|
AppKey = purchaseAccount.AppKey, |
|
|
|
|
|
AppSecret = purchaseAccount.AppSecret, |
|
|
|
|
|
AppToken = purchaseAccount.AppToken, |
|
|
|
|
|
OrderId = purchaseOrderId, |
|
|
|
|
|
Platform = callbackPlatform |
|
|
|
|
|
}); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
|
|
|
{ |
|
|
|
|
|
fsql.Update<PurchaseOrder>(purchaseOrderId).Set(po => po.SingleSkuAmount, orderAmountResponse.ProductAmount / orderSku.ItemTotal.Value) |
|
|
|
|
|
.Set(po => po.SingleFreight, orderAmountResponse.FreightAmount / orderSku.ItemTotal.Value) |
|
|
|
|
|
.ExecuteAffrows(); |
|
|
|
|
|
//fsql.Update<OrderCostDetail>().Where(ocd=>)
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
logger.Error(ex, $"OrderPriceModificationCallback 回调平台{callbackPlatform},采购单号{purchaseOrderId},执行进度[{currentProgress}]"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|