diff --git a/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index b5b644d..5a01ee9 100644 --- a/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs +++ b/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs @@ -2864,6 +2864,8 @@ namespace BBWYB.Server.Business IUpdate updatePurchaseOrder = null; + IDictionary oskuPriceEditParamDictionary = new Dictionary(); + var ppclient = ppPlatformClientFactory.GetClient(AdapterEnums.PlatformType.阿里巴巴); var totalPurchaseProductAmount = 0M; @@ -2911,21 +2913,34 @@ namespace BBWYB.Server.Business var orderSku = dbOrderSkus.FirstOrDefault(osku => osku.SkuId == belongSkuId); if (isEditOrderPrice) { - orderSku.Price = currentOrderSkuProductAmount / orderSku.ItemTotal; - orderSku.BuyerPayFreight = currentPurchaseFreight; - if (!op_EditPriceSkuRequests.Any(x => x.SkuId == orderSku.SkuId)) + if (!oskuPriceEditParamDictionary.TryGetValue(orderSku.SkuId, out OP_EditPriceSkuRequest editSkuPrice)) { - op_EditPriceSkuRequests.Add(new OP_EditPriceSkuRequest() + editSkuPrice = new OP_EditPriceSkuRequest() { - Freight = currentPurchaseFreight ?? 0M, - InPackAmountPrice = orderSku.InPackAmount ?? 0M, + SkuId = orderSku.SkuId, OrderSkuId = orderSku.Id.ToString(), - Price = orderSku.Price ?? 0M, - SkuId = orderSku.SkuId - }); - updateOrderSkuList.Add(fsql.Update(orderSku.Id).Set(osku => osku.Price, orderSku.Price) - .Set(osku => osku.BuyerPayFreight, orderSku.BuyerPayFreight)); + 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.Id).Set(osku => osku.Price, orderSku.Price) + // .Set(osku => osku.BuyerPayFreight, orderSku.BuyerPayFreight)); + //} } #endregion @@ -2938,8 +2953,24 @@ namespace BBWYB.Server.Business updateOrderCostDetailList.Add(fsql.Update().SetSource(dbOrderSkuDetail)); } } + if (isEditOrderPrice) { + #region 更新订单sku金额 + foreach (var editSkuPriceKey in oskuPriceEditParamDictionary.Keys) + { + oskuPriceEditParamDictionary.TryGetValue(editSkuPriceKey, out var editSkuPrice); + var orderSku = dbOrderSkus.FirstOrDefault(osku => osku.SkuId == editSkuPrice.SkuId); + orderSku.Price = editSkuPrice.Price; + orderSku.BuyerPayFreight = editSkuPrice.Freight; + + op_EditPriceSkuRequests.Add(editSkuPrice); + updateOrderSkuList.Add(fsql.Update(orderSku.Id).Set(osku => osku.Price, orderSku.Price) + .Set(osku => osku.BuyerPayFreight, orderSku.BuyerPayFreight)); + } + #endregion + + #region 更新订单金额 dbOrder.OrderTotalPrice = totalPurchaseProductAmount + totalPurchaseFreight; dbOrder.OrderSellerPrice = totalPurchaseProductAmount; dbOrder.FreightPrice = totalPurchaseFreight; @@ -2948,6 +2979,7 @@ namespace BBWYB.Server.Business .Set(o => o.FreightPrice, dbOrder.FreightPrice); updatePurchaseOrder = fsql.Update(orderPurchaseInfo.Id).Set(opi => opi.IsAutoEditOrderPrice, Enums.AutoEditOrderPriceType.已平价); + #region } #region 订单Sku成本