From bfa65847e3ca320fd874939d21f19e57355eb306 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 5 Aug 2023 11:56:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=20=E5=BD=93=E4=B8=80?= =?UTF-8?q?=E7=AC=94=E8=AE=A2=E5=8D=95sku=E4=BD=BF=E7=94=A8=E5=A4=9A?= =?UTF-8?q?=E7=AC=94=E9=87=87=E8=B4=AD=E5=8D=95=E6=97=B6=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=B9=B3=E4=BB=B7=E7=9A=84=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseOrder/PurchaseOrderBusiness.cs | 54 +++++++++++++++---- 1 file changed, 43 insertions(+), 11 deletions(-) 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成本