|
|
@ -36,6 +36,7 @@ namespace BBWYB.Server.Business |
|
|
|
private Lazy<JDBusiness> jdBusinessLazy; |
|
|
|
private Lazy<OP_PlatformClientFactory> opPlatformClientFactoryLazy; |
|
|
|
private Lazy<VenderBusiness> venderBusinessLazy; |
|
|
|
private Lazy<PurchaseSchemeBusiness> purchaseSchemeBusinessLazy; |
|
|
|
|
|
|
|
private PP_PlatformClientFactory ppPlatformClientFactory => pplatformClientFactoryLazy.Value; |
|
|
|
private TaskSchedulerManager taskSchedulerManager => taskSchedulerManagerLazy.Value; |
|
|
@ -50,6 +51,8 @@ namespace BBWYB.Server.Business |
|
|
|
|
|
|
|
private JDBusiness jdBusiness => jdBusinessLazy.Value; |
|
|
|
|
|
|
|
private PurchaseSchemeBusiness purchaseSchemeBusiness => purchaseSchemeBusinessLazy.Value; |
|
|
|
|
|
|
|
private IList<Enums.OrderState> cantPurchaseOrderStateList; |
|
|
|
|
|
|
|
public PurchaseOrderBusiness(IFreeSql fsql, |
|
|
@ -68,6 +71,7 @@ namespace BBWYB.Server.Business |
|
|
|
jdBusinessLazy = new Lazy<JDBusiness>(() => serviceProvider.GetService<JDBusiness>()); |
|
|
|
opPlatformClientFactoryLazy = new Lazy<OP_PlatformClientFactory>(() => serviceProvider.GetService<OP_PlatformClientFactory>()); |
|
|
|
venderBusinessLazy = new Lazy<VenderBusiness>(() => serviceProvider.GetService<VenderBusiness>()); |
|
|
|
purchaseSchemeBusinessLazy = new Lazy<PurchaseSchemeBusiness>(() => serviceProvider.GetService<PurchaseSchemeBusiness>()); |
|
|
|
cantPurchaseOrderStateList = new List<Enums.OrderState>() |
|
|
|
{ |
|
|
|
Enums.OrderState.已取消, |
|
|
@ -1113,6 +1117,10 @@ namespace BBWYB.Server.Business |
|
|
|
if (request.PurchasePlatform != Enums.Platform.阿里巴巴) |
|
|
|
return null; |
|
|
|
|
|
|
|
var order = fsql.Select<Order>(request.OrderId).ToOne(); |
|
|
|
if (order == null) |
|
|
|
throw new BusinessException("订单不存在"); |
|
|
|
|
|
|
|
var client = ppPlatformClientFactory.GetClient((AdapterEnums.PlatformType)request.PurchasePlatform); |
|
|
|
var purchaseOrderSimpleInfo = client.QueryOrderDetail(new PP_QueryOrderDetailRequest() |
|
|
|
{ |
|
|
@ -1143,24 +1151,34 @@ namespace BBWYB.Server.Business |
|
|
|
|
|
|
|
#region 查询订单sku所有采购方案
|
|
|
|
var skuIds = dbOrderSkuList.Select(osku => osku.SkuId).ToList(); |
|
|
|
var purchaseSchemeSkuList = fsql.Select<Purchaser, PurchaseScheme, PurchaseSchemeProductSku>() |
|
|
|
.InnerJoin((p, ps, pss) => p.Id == ps.PurchaserId) |
|
|
|
.InnerJoin((p, ps, pss) => ps.Id == pss.SkuPurchaseSchemeId) |
|
|
|
.Where((p, ps, pss) => p.Id == purchaserId) |
|
|
|
.Where((p, ps, pss) => ps.PurchasePlatform == Enums.Platform.阿里巴巴) |
|
|
|
.Where((p, ps, pss) => skuIds.Contains(pss.SkuId)) |
|
|
|
.ToList((p, ps, pss) => new |
|
|
|
{ |
|
|
|
pss.Id, |
|
|
|
pss.SkuId, |
|
|
|
pss.ProductId, |
|
|
|
pss.PurchaseProductId, |
|
|
|
pss.PurchaseSkuId, |
|
|
|
pss.PurchaseSkuSpecId, |
|
|
|
pss.SkuPurchaseSchemeId |
|
|
|
}); |
|
|
|
if (purchaseSchemeSkuList.Count() == 0) |
|
|
|
throw new BusinessException($"采购单{request.PurchaseOrderId} 采购商Id{purchaserId} 未匹配到采购方案"); |
|
|
|
|
|
|
|
|
|
|
|
//var purchaseSchemeSkuList = fsql.Select<Purchaser, PurchaseScheme, PurchaseSchemeProductSku>()
|
|
|
|
// .InnerJoin((p, ps, pss) => p.Id == ps.PurchaserId)
|
|
|
|
// .InnerJoin((p, ps, pss) => ps.Id == pss.SkuPurchaseSchemeId)
|
|
|
|
// .Where((p, ps, pss) => p.Id == purchaserId)
|
|
|
|
// .Where((p, ps, pss) => ps.PurchasePlatform == Enums.Platform.阿里巴巴)
|
|
|
|
// .Where((p, ps, pss) => skuIds.Contains(pss.SkuId))
|
|
|
|
// .ToList((p, ps, pss) => new
|
|
|
|
// {
|
|
|
|
// pss.Id,
|
|
|
|
// pss.SkuId,
|
|
|
|
// pss.ProductId,
|
|
|
|
// pss.PurchaseProductId,
|
|
|
|
// pss.PurchaseSkuId,
|
|
|
|
// pss.PurchaseSkuSpecId,
|
|
|
|
// pss.SkuPurchaseSchemeId
|
|
|
|
// });
|
|
|
|
//if (purchaseSchemeSkuList.Count() == 0)
|
|
|
|
// throw new BusinessException($"采购单{request.PurchaseOrderId} 采购商Id{purchaserId} 未匹配到采购方案");
|
|
|
|
|
|
|
|
var purchaseSchemeList = purchaseSchemeBusiness.GetPurchaseSchemeList(new QuerySchemeRequest() |
|
|
|
{ |
|
|
|
ShopId = order.ShopId, |
|
|
|
SkuIdList = skuIds |
|
|
|
}); |
|
|
|
if (purchaseSchemeList.Count() == 0) |
|
|
|
throw new BusinessException("未匹配到采购方案"); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 匹配采购单所使用到的采购方案
|
|
|
@ -1199,8 +1217,6 @@ namespace BBWYB.Server.Business |
|
|
|
{ |
|
|
|
var currentPurchaseSkuProductAmount = purchaseOrderSimpleInfo.ItemList.Where(p => p.SkuId == currentOrderSkuCargo.SkuId) |
|
|
|
.Sum(p => p.ProductAmount); |
|
|
|
//var currentPurchaseSkuTotalQuantity = purchaseOrderSimpleInfo.ItemList.Where(p => p.SkuId == currentOrderSkuCargo.SkuId)
|
|
|
|
// .Sum(p => p.Quantity);
|
|
|
|
|
|
|
|
var currentPurchaseSkuTotalQuantity = cargoParamList.Where(p => p.SkuId == currentOrderSkuCargo.SkuId) |
|
|
|
.Sum(p => p.Quantity); |
|
|
@ -2611,7 +2627,7 @@ namespace BBWYB.Server.Business |
|
|
|
if (order.IntoStoreType == Enums.IntoStoreType.厂商代发入仓 && |
|
|
|
state == "QianShou" && |
|
|
|
order.OrderState == Enums.OrderState.待验收 && |
|
|
|
inStoreOrderCheckTaskList != null && |
|
|
|
inStoreOrderCheckTaskList != null && |
|
|
|
!inStoreOrderCheckTaskList.Any(x => x.OrderId == order.Id)) |
|
|
|
{ |
|
|
|
insertInStoreOrderCheckTaskList.Add(new InStoreOrderCheckTask() |
|
|
|