|
|
@ -398,51 +398,6 @@ namespace BBWYB.Server.Business |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
////采购单总件数,由于1688运费只存在订单层,sku层没有运费,所以需要以订单总件数为基础等比计算采购运费
|
|
|
|
//var purchaseSkuTotalQuantity = purchaseOrderSimpleInfo.ItemList.Sum(x => x.Quantity);
|
|
|
|
//var belongSkuGroups = cargoParamGroup.CargoParamList.GroupBy(p => p.BelongSkuId);
|
|
|
|
//var belongSkuIdList = belongSkuGroups.Select(bsg => bsg.Key).ToList();
|
|
|
|
//foreach (var belongSkuGroup in belongSkuGroups)
|
|
|
|
//{
|
|
|
|
// var belongSkuId = belongSkuGroup.Key;
|
|
|
|
// //var currentOrderSkuCargoParamList = cargoParamGroup.CargoParamList.Where(p => p.BelongSkuId == belongSkuId); //找当前skuId的采购skuId
|
|
|
|
// var currentOrderSkuCargoParamList = belongSkuGroup.ToList();
|
|
|
|
// var currentSkuAmount = 0M; //采购成本
|
|
|
|
// var currentSkuTotalPurchaseQuantity = currentOrderSkuCargoParamList.Sum(x => x.Quantity); //当前skuId的采购数量总和
|
|
|
|
// var currentPurchaseFreight = purchaseOrderSimpleInfo.FreightAmount *
|
|
|
|
// (1.0M * currentSkuTotalPurchaseQuantity / purchaseSkuTotalQuantity); //采购运费
|
|
|
|
|
|
|
|
// foreach (var currentOrderSkuCargo in currentOrderSkuCargoParamList)
|
|
|
|
// {
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
// currentSkuAmount += currentPurchaseSkuProductAmount * (1.0M * currentOrderSkuCargo.Quantity / currentPurchaseSkuTotalQuantity);
|
|
|
|
// //currentPurchaseFreight += purchaseOrderSimpleInfo.FreightAmount * (1.0M * currentOrderSkuCargo.Quantity / purchaseSkuTotalQuantity);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// #region 成本明细
|
|
|
|
// var orderSku = orderSkus.FirstOrDefault(osku => osku.SkuId == belongSkuId);
|
|
|
|
// var orderCostDetail = new OrderCostDetail()
|
|
|
|
// {
|
|
|
|
// Id = idGenerator.NewLong(),
|
|
|
|
// CreateTime = DateTime.Now,
|
|
|
|
// DeductionQuantity = orderSku.ItemTotal.Value,
|
|
|
|
// OrderId = request.OrderId,
|
|
|
|
// ProductId = orderSku.ProductId,
|
|
|
|
// PurchaseOrderId = purchaseOrderSimpleInfo.OrderId,
|
|
|
|
// SkuId = belongSkuId,
|
|
|
|
// IsEnabled = true
|
|
|
|
// };
|
|
|
|
// orderCostDetail.CalculationOrderCostDetailCostAndProfit(currentSkuAmount,
|
|
|
|
// currentPurchaseFreight,
|
|
|
|
// 0M,
|
|
|
|
// 0M);
|
|
|
|
// insertOrderCostDetails.Add(orderCostDetail);
|
|
|
|
// #endregion
|
|
|
|
//}
|
|
|
|
#region 等比计算采购成本
|
|
|
|
var proportionalCalculationResultList = ProportionalCalculationCost(cargoParamGroup.CargoParamList, purchaseOrderSimpleInfo); |
|
|
|
foreach (var proportionalCalculationResult in proportionalCalculationResultList) |
|
|
@ -2646,56 +2601,43 @@ namespace BBWYB.Server.Business |
|
|
|
{ |
|
|
|
var currentOrderSkuList = orderSkuList.Where(osku => osku.OrderId == order.Id).ToList(); |
|
|
|
var currentPurchaseOrderList = purchaseOrderList.Where(po => po.OrderId == order.Id).ToList(); |
|
|
|
foreach (var purchaseOrder in currentPurchaseOrderList) |
|
|
|
|
|
|
|
#region 计算采购单状态
|
|
|
|
foreach (var po in currentPurchaseOrderList) |
|
|
|
{ |
|
|
|
var currentPurchaseOrderSkuList = orderPurchaseSkuList.Where(posku => posku.PurchaseOrderId == purchaseOrder.PurchaseOrderId).ToList(); |
|
|
|
var currentPoSkuList = orderPurchaseSkuList.Where(posku => posku.PurchaseOrderId == po.PurchaseOrderId).ToList(); |
|
|
|
|
|
|
|
var currentPurchaseExpressOrderList = purchaseExpressOrderList.Where(peo => peo.PurchaseOrderId == purchaseOrder.PurchaseOrderId).ToList(); |
|
|
|
var temp = currentPurchaseExpressOrderList.FirstOrDefault(p => p.WaybillNo == wayBillNo); |
|
|
|
if (temp != null) |
|
|
|
temp.ExpressState = state; |
|
|
|
var currentPeoList = purchaseExpressOrderList.Where(peo => peo.PurchaseOrderId == po.PurchaseOrderId).ToList(); |
|
|
|
var peo = currentPeoList.FirstOrDefault(p => p.WaybillNo == wayBillNo); |
|
|
|
if (peo != null) |
|
|
|
peo.ExpressState = state; |
|
|
|
|
|
|
|
var oldPurchaseOrderState = purchaseOrder.OrderState; |
|
|
|
purchaseOrder.CalculationOrderState(order.IntoStoreType.Value, fsql, currentPurchaseOrderSkuList, currentPurchaseExpressOrderList); |
|
|
|
if (purchaseOrder.OrderState != oldPurchaseOrderState) |
|
|
|
var oldPurchaseOrderState = po.OrderState; |
|
|
|
po.CalculationOrderState(order.IntoStoreType.Value, fsql, currentPoSkuList, currentPeoList); |
|
|
|
if (po.OrderState != oldPurchaseOrderState) |
|
|
|
{ |
|
|
|
var update = fsql.Update<OrderPurchaseInfo>(purchaseOrder.Id).Set(po => po.OrderState, purchaseOrder.OrderState); |
|
|
|
var update = fsql.Update<OrderPurchaseInfo>(po.Id).Set(po => po.OrderState, po.OrderState); |
|
|
|
updateOrderPurchaseList.Add(update); |
|
|
|
|
|
|
|
#region 通知齐库打包落仓情况
|
|
|
|
if (order.IntoStoreType == Enums.IntoStoreType.发回齐越 && state == "QianShou") |
|
|
|
{ |
|
|
|
var currentOrderPurchaseRelationList = orderPurchaseRelationList.Where(opri => opri.PurchaseOrderId == purchaseOrder.PurchaseOrderId).ToList(); |
|
|
|
|
|
|
|
Task.Factory.StartNew(() => qiKuManager.PublishQiKuReceiveInfo(purchaseOrder, currentOrderPurchaseRelationList, currentPurchaseOrderSkuList, purchaseExpressOrderList), |
|
|
|
CancellationToken.None, |
|
|
|
TaskCreationOptions.LongRunning, |
|
|
|
taskSchedulerManager.PurchaseOrderCallbackTaskScheduler); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
var oldOrderState = order.OrderState; |
|
|
|
order.CalculationOrderState(fsql, currentOrderSkuList, currentPurchaseOrderList); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (order.IntoStoreType == Enums.IntoStoreType.厂商代发入仓 && |
|
|
|
state == "QianShou" && |
|
|
|
order.OrderState == Enums.OrderState.待验收 && |
|
|
|
inStoreOrderCheckTaskList != null && |
|
|
|
!inStoreOrderCheckTaskList.Any(x => x.OrderId == order.Id)) |
|
|
|
#region 推送齐库到货情况
|
|
|
|
if (order.IntoStoreType == Enums.IntoStoreType.发回齐越 && state == "QianShou") |
|
|
|
{ |
|
|
|
insertInStoreOrderCheckTaskList.Add(new InStoreOrderCheckTask() |
|
|
|
{ |
|
|
|
Id = idGenerator.NewLong(), |
|
|
|
CreateTime = DateTime.Now, |
|
|
|
IsChecked = false, |
|
|
|
OrderId = order.Id, |
|
|
|
ShopId = order.ShopId, |
|
|
|
OrderSn = order.OrderSn |
|
|
|
}); |
|
|
|
Task.Factory.StartNew(() => qiKuManager.PublishQikuReceiveInfo(order.Id, |
|
|
|
wayBillNo, |
|
|
|
currentPurchaseOrderList, |
|
|
|
currentOrderSkuList, |
|
|
|
purchaseExpressOrderList, |
|
|
|
orderPurchaseRelationList, |
|
|
|
orderPurchaseSkuList), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 计算订单状态
|
|
|
|
var oldOrderState = order.OrderState; |
|
|
|
order.CalculationOrderState(fsql, currentOrderSkuList, currentPurchaseOrderList); |
|
|
|
if (order.OrderState != oldOrderState) |
|
|
|
{ |
|
|
|
var update = fsql.Update<Order>(order.Id).Set(o => o.OrderState, order.OrderState); |
|
|
@ -2728,6 +2670,26 @@ namespace BBWYB.Server.Business |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 创建入仓单检查任务
|
|
|
|
if (order.IntoStoreType == Enums.IntoStoreType.厂商代发入仓 && |
|
|
|
state == "QianShou" && |
|
|
|
order.OrderState == Enums.OrderState.待验收 && |
|
|
|
inStoreOrderCheckTaskList != null && |
|
|
|
!inStoreOrderCheckTaskList.Any(x => x.OrderId == order.Id)) |
|
|
|
{ |
|
|
|
insertInStoreOrderCheckTaskList.Add(new InStoreOrderCheckTask() |
|
|
|
{ |
|
|
|
Id = idGenerator.NewLong(), |
|
|
|
CreateTime = DateTime.Now, |
|
|
|
IsChecked = false, |
|
|
|
OrderId = order.Id, |
|
|
|
ShopId = order.ShopId, |
|
|
|
OrderSn = order.OrderSn |
|
|
|
}); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|