You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.5 KiB
66 lines
2.5 KiB
using BBWYB.Common.Http;
|
|
using BBWYB.Common.Models;
|
|
using BBWYB.Server.Model.Db;
|
|
|
|
namespace BBWYB.Server.Business
|
|
{
|
|
public class QiKuManager : IDenpendency
|
|
{
|
|
private RestApiService restApiService;
|
|
public QiKuManager(RestApiService restApiService)
|
|
{
|
|
this.restApiService = restApiService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通知齐库
|
|
/// </summary>
|
|
/// <param name="orderPurchaseRelationInfoList"></param>
|
|
/// <param name="orderPurchaseSkuInfoList"></param>
|
|
/// <param name="purchaseExpressOrderList"></param>
|
|
public void PublishQiKu(IList<OrderPurchaseRelationInfo> orderPurchaseRelationInfoList,
|
|
IList<OrderPurchaseSkuInfo> orderPurchaseSkuInfoList,
|
|
IList<PurchaseExpressOrder> purchaseExpressOrderList)
|
|
{
|
|
try
|
|
{
|
|
var relationGroups = orderPurchaseRelationInfoList.GroupBy(opri => opri.SourceSkuId);
|
|
foreach (var relationGroup in relationGroups)
|
|
{
|
|
bool isSignAll = true;
|
|
foreach (var relation in relationGroup)
|
|
{
|
|
var purchaseSku = orderPurchaseSkuInfoList.FirstOrDefault(x => x.PurchaseSkuId == relation.PurchaseSkuId);
|
|
if (purchaseSku == null || string.IsNullOrEmpty(purchaseSku.WaybillNo))
|
|
{
|
|
isSignAll = false;
|
|
continue;
|
|
}
|
|
var purchaseExpressOrder = purchaseExpressOrderList.FirstOrDefault(x => x.WaybillNo == purchaseSku.WaybillNo);
|
|
if (purchaseExpressOrder == null || purchaseExpressOrder.ExpressState != "QianShou")
|
|
{
|
|
isSignAll = false;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
restApiService.SendRequest("http://qiku.qiyue666.com",
|
|
"/Api/PackPurchaseTask/UpdateAvailabilityState",
|
|
new
|
|
{
|
|
availability = isSignAll ? 0 : 1,
|
|
orderId = relationGroup.FirstOrDefault().OrderId,
|
|
skuId = relationGroup.Key
|
|
},
|
|
null,
|
|
HttpMethod.Post);
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|