|
|
@ -827,13 +827,18 @@ namespace BBWYB.Server.Business |
|
|
|
throw new BusinessException("无效采购单号"); |
|
|
|
if (!dbOrderPurchaseInfo.IsEnabled) |
|
|
|
throw new BusinessException("采购单已失效"); |
|
|
|
if (dbOrderPurchaseInfo.IsSign == true) |
|
|
|
if (dbOrderPurchaseInfo.OrderState == Enums.PurchaseOrderState.已签收 || |
|
|
|
dbOrderPurchaseInfo.IsSign == true) |
|
|
|
throw new BusinessException("采购单已签收"); |
|
|
|
|
|
|
|
dbOrderPurchaseInfo.IsSign = true; |
|
|
|
dbOrderPurchaseInfo.OrderState = Enums.PurchaseOrderState.已签收; |
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
fsql.Update<OrderPurchaseInfo>(dbOrderPurchaseInfo.Id).Set(opi => opi.IsSign, true).ExecuteAffrows(); |
|
|
|
fsql.Update<OrderPurchaseInfo>().SetSource(dbOrderPurchaseInfo).ExecuteAffrows(); |
|
|
|
fsql.Update<Order>(dbOrder.Id).Set(o => o.IsWaitPack, true).ExecuteAffrows(); |
|
|
|
Enums.OrderState.待收货; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -899,19 +904,19 @@ namespace BBWYB.Server.Business |
|
|
|
{ |
|
|
|
#region 查询代发信息
|
|
|
|
currentProgress = "查询代发信息"; |
|
|
|
var orderPurchaseInfo = fsql.Select<OrderPurchaseInfo>().Where(o => o.PurchaseOrderId == purchaseOrderId).ToOne(); |
|
|
|
var orderPurchaseInfo = fsql.Select<OrderPurchaseInfo>().Where(o => o.PurchaseOrderId == purchaseOrderId && orderPurchaseInfo.IsEnabled == true).ToOne(); |
|
|
|
if (orderPurchaseInfo == null) |
|
|
|
throw new Exception("未查询到代发信息"); |
|
|
|
orderId = orderPurchaseInfo.OrderId; |
|
|
|
shopId = orderPurchaseInfo.ShopId; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 查询采购账号的归属店铺
|
|
|
|
currentProgress = "查询采购账号归属店铺"; |
|
|
|
var shop = venderBusiness.GetShopList(shopId: shopId)?.FirstOrDefault(); |
|
|
|
if (shop == null) |
|
|
|
throw new Exception("未查询到店铺信息"); |
|
|
|
#endregion
|
|
|
|
//#region 查询采购账号的归属店铺
|
|
|
|
//currentProgress = "查询采购账号归属店铺";
|
|
|
|
//var shop = venderBusiness.GetShopList(shopId: shopId)?.FirstOrDefault();
|
|
|
|
//if (shop == null)
|
|
|
|
// throw new Exception("未查询到店铺信息");
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
#region 查询采购账号
|
|
|
|
currentProgress = "查询采购账号"; |
|
|
@ -938,58 +943,80 @@ namespace BBWYB.Server.Business |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 获取目标平台的物流公司列表
|
|
|
|
currentProgress = "获取店铺平台物流公司列表"; |
|
|
|
var expressCompanyList = venderBusiness.GetExpressCompanyList(new PlatformRequest() |
|
|
|
//#region 获取目标平台的物流公司列表
|
|
|
|
//currentProgress = "获取店铺平台物流公司列表";
|
|
|
|
//var expressCompanyList = venderBusiness.GetExpressCompanyList(new PlatformRequest()
|
|
|
|
//{
|
|
|
|
// AppKey = shop.AppKey,
|
|
|
|
// AppSecret = shop.AppSecret,
|
|
|
|
// AppToken = shop.AppToken,
|
|
|
|
// Platform = shop.PlatformId
|
|
|
|
//});
|
|
|
|
//if (expressCompanyList != null)
|
|
|
|
// expressCompanyListInfo = JsonConvert.SerializeObject(expressCompanyList);
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#region 物流公司翻译
|
|
|
|
//currentProgress = "物流公司翻译";
|
|
|
|
|
|
|
|
//OP_QueryExpressCompanyResponse convertExpressCompany = null;
|
|
|
|
|
|
|
|
//try
|
|
|
|
//{
|
|
|
|
// convertExpressCompany = expressCompanyNameConverter.Converter(wayBillNoResponse.ExpressName,
|
|
|
|
// (AdapterEnums.PlatformType)callbackPlatform,
|
|
|
|
// (AdapterEnums.PlatformType)shop.PlatformId,
|
|
|
|
// expressCompanyList);
|
|
|
|
// if (convertExpressCompany != null)
|
|
|
|
// expressCompanyInfo = JsonConvert.SerializeObject(convertExpressCompany);
|
|
|
|
//}
|
|
|
|
//catch
|
|
|
|
//{
|
|
|
|
// throw;
|
|
|
|
//}
|
|
|
|
//finally
|
|
|
|
//{
|
|
|
|
// #region 店铺平台订单出库
|
|
|
|
// currentProgress = "店铺平台订单出库";
|
|
|
|
// orderBusiness.OutStock(new OutStockRequest()
|
|
|
|
// {
|
|
|
|
// AppKey = shop.AppKey,
|
|
|
|
// AppSecret = shop.AppSecret,
|
|
|
|
// AppToken = shop.AppToken,
|
|
|
|
// OrderId = orderId,
|
|
|
|
// TargetExpressId = convertExpressCompany?.ExpressId ?? string.Empty, //物流公司Id
|
|
|
|
// TargetExpressName = convertExpressCompany?.ExpressName ?? string.Empty, //物流公司名称
|
|
|
|
// SourceExpressId = wayBillNoResponse.ExpressId,
|
|
|
|
// SourceExpressName = wayBillNoResponse.ExpressName,
|
|
|
|
// PurchaseOrderId = purchaseOrderId,
|
|
|
|
// Platform = shop.PlatformId,
|
|
|
|
// WayBillNo = wayBillNoResponse.WayBillNo
|
|
|
|
// });
|
|
|
|
// #endregion
|
|
|
|
//}
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 店铺平台订单出库
|
|
|
|
currentProgress = "店铺平台订单出库"; |
|
|
|
orderBusiness.OutStock(new OutStockRequest() |
|
|
|
{ |
|
|
|
AppKey = shop.AppKey, |
|
|
|
AppSecret = shop.AppSecret, |
|
|
|
AppToken = shop.AppToken, |
|
|
|
Platform = shop.PlatformId |
|
|
|
//AppKey = shop.AppKey,
|
|
|
|
//AppSecret = shop.AppSecret,
|
|
|
|
//AppToken = shop.AppToken,
|
|
|
|
OrderId = orderId, |
|
|
|
//TargetExpressId = convertExpressCompany?.ExpressId ?? string.Empty, //物流公司Id
|
|
|
|
//TargetExpressName = convertExpressCompany?.ExpressName ?? string.Empty, //物流公司名称
|
|
|
|
SourceExpressId = wayBillNoResponse.ExpressId, |
|
|
|
SourceExpressName = wayBillNoResponse.ExpressName, |
|
|
|
PurchaseOrderId = purchaseOrderId, |
|
|
|
//Platform = shop.PlatformId,
|
|
|
|
WayBillNo = wayBillNoResponse.WayBillNo |
|
|
|
}); |
|
|
|
if (expressCompanyList != null) |
|
|
|
expressCompanyListInfo = JsonConvert.SerializeObject(expressCompanyList); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 物流公司翻译
|
|
|
|
currentProgress = "物流公司翻译"; |
|
|
|
|
|
|
|
OP_QueryExpressCompanyResponse convertExpressCompany = null; |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
convertExpressCompany = expressCompanyNameConverter.Converter(wayBillNoResponse.ExpressName, |
|
|
|
(AdapterEnums.PlatformType)callbackPlatform, |
|
|
|
(AdapterEnums.PlatformType)shop.PlatformId, |
|
|
|
expressCompanyList); |
|
|
|
if (convertExpressCompany != null) |
|
|
|
expressCompanyInfo = JsonConvert.SerializeObject(convertExpressCompany); |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
throw; |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
#region 店铺平台订单出库
|
|
|
|
currentProgress = "店铺平台订单出库"; |
|
|
|
orderBusiness.OutStock(new OutStockRequest() |
|
|
|
{ |
|
|
|
AppKey = shop.AppKey, |
|
|
|
AppSecret = shop.AppSecret, |
|
|
|
AppToken = shop.AppToken, |
|
|
|
OrderId = orderId, |
|
|
|
TargetExpressId = convertExpressCompany?.ExpressId ?? string.Empty, //物流公司Id
|
|
|
|
TargetExpressName = convertExpressCompany?.ExpressName ?? string.Empty, //物流公司名称
|
|
|
|
SourceExpressId = wayBillNoResponse.ExpressId, |
|
|
|
SourceExpressName = wayBillNoResponse.ExpressName, |
|
|
|
PurchaseOrderId = purchaseOrderId, |
|
|
|
Platform = shop.PlatformId, |
|
|
|
WayBillNo = wayBillNoResponse.WayBillNo |
|
|
|
}); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
nLogManager.Default().Info($"DeliveryCallback 回调平台{callbackPlatform},订单号{orderId},采购单号{purchaseOrderId},执行进度[{currentProgress}],采购单物流信息:{wayBillNoResponseInfo},店铺平台物流公司列表:{expressCompanyListInfo},翻译后的物流公司:{expressCompanyInfo}"); |
|
|
|
} |
|
|
@ -1008,6 +1035,7 @@ namespace BBWYB.Server.Business |
|
|
|
Task.Factory.StartNew(() => |
|
|
|
{ |
|
|
|
IList<IUpdate<OrderPurchaseSkuInfo>> updateOrderPurchaseSkuInfoList = new List<IUpdate<OrderPurchaseSkuInfo>>(); |
|
|
|
IList<IUpdate<OrderPurchaseInfo>> updateOrderPurchaseInfoList = new List<IUpdate<OrderPurchaseInfo>>(); |
|
|
|
|
|
|
|
var statusChanged = jObject["data"]["OrderLogisticsTracingModel"].Value<string>("statusChanged").ToUpper(); |
|
|
|
var orderLogsItems = jObject["data"]["OrderLogisticsTracingModel"]["orderLogsItems"].Children(); |
|
|
@ -1015,6 +1043,8 @@ namespace BBWYB.Server.Business |
|
|
|
var purchaseOrderIds = orderLogsItems.Select(x => x.Value<string>("orderId")).Distinct().ToList(); |
|
|
|
var orderEntryIds = orderLogsItems.Select(x => x.Value<string>("orderEntryId")).Distinct().ToList(); |
|
|
|
|
|
|
|
var dbOrderPurchaseInfoList = fsql.Select<OrderPurchaseInfo>().Where(opi => purchaseOrderIds.Contains(opi.PurchaseOrderId) && opi.IsEnabled == true).ToList(); |
|
|
|
|
|
|
|
var dbOrderPurchaseSkuInfoList = fsql.Select<OrderPurchaseSkuInfo>() |
|
|
|
.WhereIf(purchaseOrderIds.Count() > 1, ops => purchaseOrderIds.Contains(ops.PurchaseOrderId)) |
|
|
|
.WhereIf(purchaseOrderIds.Count() == 1, ops => ops.PurchaseOrderId == purchaseOrderIds[0]) |
|
|
@ -1043,12 +1073,20 @@ namespace BBWYB.Server.Business |
|
|
|
foreach (var group in groupsByPoIds) |
|
|
|
{ |
|
|
|
var isSignAll = group.Count() == group.Where(x => x.ExpressState == "SIGN").Count(); |
|
|
|
if (isSignAll) |
|
|
|
{ |
|
|
|
var dbOrderPurchaseInfo = dbOrderPurchaseInfoList.FirstOrDefault(x => x.PurchaseOrderId == group.Key && x.IsEnabled == true); |
|
|
|
if (dbOrderPurchaseInfo != null) |
|
|
|
{ |
|
|
|
dbOrderPurchaseInfo.OrderState = Enums.PurchaseOrderState.已签收; |
|
|
|
updateOrderPurchaseInfoList.Add(fsql.Update<OrderPurchaseInfo>().SetSource(dbOrderPurchaseInfo)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 通知齐库
|
|
|
|
var relationList = dbOrderPurchaseRelationInfoList.Where(x => x.PurchaseOrderId == group.Key).ToList(); |
|
|
|
foreach (var relation in relationList) |
|
|
|
{ |
|
|
|
//通知C端
|
|
|
|
try |
|
|
|
{ |
|
|
|
restApiService.SendRequest("http://qiku.qiyue666.com", |
|
|
@ -1069,37 +1107,16 @@ namespace BBWYB.Server.Business |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
var groupsByOrderIds = dbOrderPurchaseSkuInfoList.GroupBy(x => x.OrderId); |
|
|
|
foreach (var group in groupsByOrderIds) |
|
|
|
{ |
|
|
|
var isSignAll = group.Count() == group.Where(x => x.ExpressState == "SIGN").Count(); |
|
|
|
|
|
|
|
if (isSignAll) |
|
|
|
{ |
|
|
|
//通知C端
|
|
|
|
try |
|
|
|
{ |
|
|
|
restApiService.SendRequest("https://bbwy.qiyue666.com", |
|
|
|
"/Api/PurchaseOrder/SignPurchaseOrder", |
|
|
|
new { orderId = group.Key }, |
|
|
|
null, |
|
|
|
HttpMethod.Post); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (updateOrderPurchaseSkuInfoList.Count() > 0) |
|
|
|
if (updateOrderPurchaseSkuInfoList.Count() > 0 || updateOrderPurchaseInfoList.Count() > 0) |
|
|
|
{ |
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
foreach (var update in updateOrderPurchaseSkuInfoList) |
|
|
|
update.ExecuteAffrows(); |
|
|
|
foreach (var update in updateOrderPurchaseInfoList) |
|
|
|
update.ExecuteAffrows(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|