|
@ -457,7 +457,8 @@ namespace BBWYB.Server.Business |
|
|
ShopId = request.ShopId, |
|
|
ShopId = request.ShopId, |
|
|
BelongSkuIds = string.Join(",", belongSkuIdList), |
|
|
BelongSkuIds = string.Join(",", belongSkuIdList), |
|
|
IsEnabled = true, |
|
|
IsEnabled = true, |
|
|
Remark = !string.IsNullOrEmpty(cargoParamGroup.Remark) ? cargoParamGroup.Remark : request.Remark |
|
|
Remark = !string.IsNullOrEmpty(cargoParamGroup.Remark) ? cargoParamGroup.Remark : request.Remark, |
|
|
|
|
|
UpadteTime = DateTime.Now |
|
|
}; |
|
|
}; |
|
|
insertOrderPurchaseInfos.Add(orderPurchaserInfo); |
|
|
insertOrderPurchaseInfos.Add(orderPurchaserInfo); |
|
|
#endregion
|
|
|
#endregion
|
|
@ -473,7 +474,10 @@ namespace BBWYB.Server.Business |
|
|
PurchaseOrderId = purchaseOrderSimpleInfo.OrderId, |
|
|
PurchaseOrderId = purchaseOrderSimpleInfo.OrderId, |
|
|
PurchaseProductId = purchaseOrderSku.ProductId, |
|
|
PurchaseProductId = purchaseOrderSku.ProductId, |
|
|
PurchaseSkuId = purchaseOrderSku.SkuId, |
|
|
PurchaseSkuId = purchaseOrderSku.SkuId, |
|
|
ShopId = request.ShopId |
|
|
ShopId = request.ShopId, |
|
|
|
|
|
PurchasedPrice = purchaseOrderSku.Price, |
|
|
|
|
|
PurchasedAmount = purchaseOrderSku.ProductAmount, |
|
|
|
|
|
PurchasedItemCount = purchaseOrderSku.Quantity |
|
|
}; |
|
|
}; |
|
|
insertOrderPurchaseSkuInfos.Add(orderPurchaseSkuInfo); |
|
|
insertOrderPurchaseSkuInfos.Add(orderPurchaseSkuInfo); |
|
|
} |
|
|
} |
|
@ -1112,7 +1116,8 @@ namespace BBWYB.Server.Business |
|
|
PurchasePlatform = purchaseOrder.PurchasePlatform, |
|
|
PurchasePlatform = purchaseOrder.PurchasePlatform, |
|
|
PurchaserId = purchaseOrder.PurchaserId, |
|
|
PurchaserId = purchaseOrder.PurchaserId, |
|
|
PurchaserName = purchaseOrder.PurchaserName, |
|
|
PurchaserName = purchaseOrder.PurchaserName, |
|
|
ShopId = request.ShopId |
|
|
ShopId = request.ShopId, |
|
|
|
|
|
UpadteTime = DateTime.Now |
|
|
}; |
|
|
}; |
|
|
insertOrderPurchaseInfoList.Add(dbPurchaserOrder); |
|
|
insertOrderPurchaseInfoList.Add(dbPurchaserOrder); |
|
|
#endregion
|
|
|
#endregion
|
|
@ -2995,7 +3000,8 @@ namespace BBWYB.Server.Business |
|
|
|
|
|
|
|
|
IList<OP_EditPriceSkuRequest> op_EditPriceSkuRequests = new List<OP_EditPriceSkuRequest>(); |
|
|
IList<OP_EditPriceSkuRequest> op_EditPriceSkuRequests = new List<OP_EditPriceSkuRequest>(); |
|
|
|
|
|
|
|
|
IUpdate<OrderPurchaseInfo> updatePurchaseOrder = null; |
|
|
IUpdate<OrderPurchaseInfo> updatePurchaseOrder = fsql.Update<OrderPurchaseInfo>(orderPurchaseInfo.Id).Set(opi => opi.UpdateTime, DateTime.Now); |
|
|
|
|
|
List<IUpdate<OrderPurchaseSkuInfo>> updatePurchaserOrderSkuList = new List<IUpdate<OrderPurchaseSkuInfo>>(); |
|
|
|
|
|
|
|
|
IDictionary<string, OP_EditPriceSkuRequest> oskuPriceEditParamDictionary = new Dictionary<string, OP_EditPriceSkuRequest>(); |
|
|
IDictionary<string, OP_EditPriceSkuRequest> oskuPriceEditParamDictionary = new Dictionary<string, OP_EditPriceSkuRequest>(); |
|
|
|
|
|
|
|
@ -3007,7 +3013,6 @@ namespace BBWYB.Server.Business |
|
|
{ |
|
|
{ |
|
|
if (opi.PurchasePlatform != Enums.Platform.阿里巴巴) |
|
|
if (opi.PurchasePlatform != Enums.Platform.阿里巴巴) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
var purchaseOrderSimpleInfo = ppclient.QueryOrderDetail(new PP_QueryOrderDetailRequest() |
|
|
var purchaseOrderSimpleInfo = ppclient.QueryOrderDetail(new PP_QueryOrderDetailRequest() |
|
|
{ |
|
|
{ |
|
|
AppKey = purchaseAccount.AppKey, |
|
|
AppKey = purchaseAccount.AppKey, |
|
@ -3016,6 +3021,21 @@ namespace BBWYB.Server.Business |
|
|
OrderId = opi.PurchaseOrderId |
|
|
OrderId = opi.PurchaseOrderId |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
#region 更新配件下单信息
|
|
|
|
|
|
if (opi.PurchaseOrderId == purchaseOrderId) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in purchaseOrderSimpleInfo.ItemList) |
|
|
|
|
|
{ |
|
|
|
|
|
var update = fsql.Update<OrderPurchaseSkuInfo>().Set(opsi => opsi.PurchasedPrice, item.Price) |
|
|
|
|
|
.Set(opsi => opsi.PurchasedAmount, item.ProductAmount) |
|
|
|
|
|
.Set(opsi => opsi.PurchasedItemCount, item.Quantity) |
|
|
|
|
|
.Where(opsi => opsi.PurchaseOrderId == purchaseOrderId && |
|
|
|
|
|
opsi.PurchaseSkuId == item.SkuId); |
|
|
|
|
|
updatePurchaserOrderSkuList.Add(update); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
totalPurchaseProductAmount += purchaseOrderSimpleInfo.ProductAmount; |
|
|
totalPurchaseProductAmount += purchaseOrderSimpleInfo.ProductAmount; |
|
|
totalPurchaseFreight += purchaseOrderSimpleInfo.FreightAmount; |
|
|
totalPurchaseFreight += purchaseOrderSimpleInfo.FreightAmount; |
|
|
var currentPurchaseOrderRelationInfos = dbOrderPurchaseRelationInfos.Where(x => x.PurchaseOrderId == opi.PurchaseOrderId).ToList(); |
|
|
var currentPurchaseOrderRelationInfos = dbOrderPurchaseRelationInfos.Where(x => x.PurchaseOrderId == opi.PurchaseOrderId).ToList(); |
|
@ -3065,71 +3085,6 @@ namespace BBWYB.Server.Business |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
//var purchaseSkuTotalQuantity = purchaseOrderSimpleInfo.ItemList.Sum(x => x.Quantity);
|
|
|
|
|
|
//var belongSkuGroups = currentPurchaseOrderRelationInfos.GroupBy(p => p.BelongSkuId);
|
|
|
|
|
|
//foreach (var belongSkuGroup in belongSkuGroups)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var belongSkuId = belongSkuGroup.Key;
|
|
|
|
|
|
|
|
|
|
|
|
// var currentOrderSkuCargoParamList = belongSkuGroup.ToList(); //找当前skuId的采购skuId
|
|
|
|
|
|
// var currentOrderSkuProductAmount = 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.PurchaseSkuId)
|
|
|
|
|
|
// .Sum(p => p.ProductAmount);
|
|
|
|
|
|
// var currentPurchaseSkuTotalQuantity = purchaseOrderSimpleInfo.ItemList.Where(p => p.SkuId == currentOrderSkuCargo.PurchaseSkuId)
|
|
|
|
|
|
// .Sum(p => p.Quantity);
|
|
|
|
|
|
// currentOrderSkuProductAmount += currentPurchaseSkuProductAmount * (1.0M * currentOrderSkuCargo.Quantity.Value / currentPurchaseSkuTotalQuantity);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// #region 订单sku平价
|
|
|
|
|
|
// var orderSku = dbOrderSkus.FirstOrDefault(osku => osku.SkuId == belongSkuId);
|
|
|
|
|
|
// if (isEditOrderPrice)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (!oskuPriceEditParamDictionary.TryGetValue(orderSku.SkuId, out OP_EditPriceSkuRequest editSkuPrice))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// editSkuPrice = new OP_EditPriceSkuRequest()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// SkuId = orderSku.SkuId,
|
|
|
|
|
|
// OrderSkuId = orderSku.Id.ToString(),
|
|
|
|
|
|
// InPackAmountPrice = orderSku.InPackAmount ?? 0M
|
|
|
|
|
|
// };
|
|
|
|
|
|
// oskuPriceEditParamDictionary.Add(orderSku.SkuId, editSkuPrice);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// editSkuPrice.Price += currentOrderSkuProductAmount / (orderSku.ItemTotal ?? 1M);
|
|
|
|
|
|
// editSkuPrice.Freight += currentPurchaseFreight ?? 0M;
|
|
|
|
|
|
|
|
|
|
|
|
// //orderSku.Price =
|
|
|
|
|
|
// //orderSku.BuyerPayFreight = currentPurchaseFreight;
|
|
|
|
|
|
// //if (!op_EditPriceSkuRequests.Any(x => x.SkuId == orderSku.SkuId))
|
|
|
|
|
|
// //{
|
|
|
|
|
|
// // op_EditPriceSkuRequests.Add(new OP_EditPriceSkuRequest()
|
|
|
|
|
|
// // {
|
|
|
|
|
|
// // Freight = currentPurchaseFreight ?? 0M,
|
|
|
|
|
|
// // InPackAmountPrice = orderSku.InPackAmount ?? 0M,
|
|
|
|
|
|
// // OrderSkuId = orderSku.Id.ToString(),
|
|
|
|
|
|
// // Price = orderSku.Price ?? 0M,
|
|
|
|
|
|
// // SkuId = orderSku.SkuId
|
|
|
|
|
|
// // });
|
|
|
|
|
|
// // updateOrderSkuList.Add(fsql.Update<OrderSku>(orderSku.Id).Set(osku => osku.Price, orderSku.Price)
|
|
|
|
|
|
// // .Set(osku => osku.BuyerPayFreight, orderSku.BuyerPayFreight));
|
|
|
|
|
|
// //}
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
|
|
|
|
// var dbOrderSkuDetail = dbOrderCostDetails.FirstOrDefault(ocd => ocd.SkuId == belongSkuId && ocd.PurchaseOrderId == opi.PurchaseOrderId);
|
|
|
|
|
|
// dbOrderSkuDetail.CalculationOrderCostDetailCostAndProfit(currentOrderSkuProductAmount,
|
|
|
|
|
|
// currentPurchaseFreight ?? 0M,
|
|
|
|
|
|
// dbOrderSkuDetail.OutPackAmount ?? 0M,
|
|
|
|
|
|
// dbOrderSkuDetail.DeliveryExpressFreight ?? 0M);
|
|
|
|
|
|
// updateOrderCostDetailList.Add(fsql.Update<OrderCostDetail>().SetSource(dbOrderSkuDetail));
|
|
|
|
|
|
//}
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isEditOrderPrice) |
|
|
if (isEditOrderPrice) |
|
@ -3156,7 +3111,7 @@ namespace BBWYB.Server.Business |
|
|
.Set(o => o.OrderSellerPrice, dbOrder.OrderSellerPrice) |
|
|
.Set(o => o.OrderSellerPrice, dbOrder.OrderSellerPrice) |
|
|
.Set(o => o.FreightPrice, dbOrder.FreightPrice); |
|
|
.Set(o => o.FreightPrice, dbOrder.FreightPrice); |
|
|
|
|
|
|
|
|
updatePurchaseOrder = fsql.Update<OrderPurchaseInfo>(orderPurchaseInfo.Id).Set(opi => opi.IsAutoEditOrderPrice, Enums.AutoEditOrderPriceType.已平价); |
|
|
updatePurchaseOrder = updatePurchaseOrder.Set(opi => opi.IsAutoEditOrderPrice, Enums.AutoEditOrderPriceType.已平价); |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -3187,17 +3142,17 @@ namespace BBWYB.Server.Business |
|
|
|
|
|
|
|
|
#region 订单成本
|
|
|
#region 订单成本
|
|
|
dbOrderCost.CalculationOrderCostAndProfit(dbOrder.OrderTotalPrice.Value, dbOrderSkuCostList.Union(insertOrderSkuCostList).ToList()); |
|
|
dbOrderCost.CalculationOrderCostAndProfit(dbOrder.OrderTotalPrice.Value, dbOrderSkuCostList.Union(insertOrderSkuCostList).ToList()); |
|
|
//dbOrderCost.CalculationOrderCostAndProfit(dbOrder.OrderTotalPrice ?? 0M,
|
|
|
|
|
|
// totalPurchaseProductAmount,
|
|
|
|
|
|
// totalPurchaseFreight,
|
|
|
|
|
|
// dbOrderCostDetails.Sum(ocd => ocd.OutPackAmount ?? 0M),
|
|
|
|
|
|
// dbOrderCostDetails.Sum(ocd => ocd.DeliveryExpressFreight ?? 0M));
|
|
|
|
|
|
updateOrderCost = fsql.Update<OrderCost>().SetSource(dbOrderCost); |
|
|
updateOrderCost = fsql.Update<OrderCost>().SetSource(dbOrderCost); |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
fsql.Transaction(() => |
|
|
{ |
|
|
{ |
|
|
updatePurchaseOrder?.ExecuteAffrows(); |
|
|
updatePurchaseOrder?.ExecuteAffrows(); |
|
|
|
|
|
if (updatePurchaserOrderSkuList.Count() > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var update in updatePurchaserOrderSkuList) |
|
|
|
|
|
update.ExecuteAffrows(); |
|
|
|
|
|
} |
|
|
foreach (var update in updateOrderCostDetailList) |
|
|
foreach (var update in updateOrderCostDetailList) |
|
|
update.ExecuteAffrows(); |
|
|
update.ExecuteAffrows(); |
|
|
updateOrderCost?.ExecuteAffrows(); |
|
|
updateOrderCost?.ExecuteAffrows(); |
|
|