From cb8a95380d62bdbb30703010b72163775961f71d Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Tue, 14 Nov 2023 11:05:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BC=98=E6=83=A0=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sync/OrderSyncBusiness.cs | 8 ++- BBWY.Server.Business/TestBusiness.cs | 56 +++++++++++-------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs index bb5a54ee..e60ea19b 100644 --- a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs +++ b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs @@ -479,8 +479,9 @@ namespace BBWY.Server.Business var orderTotalInfo = insertOrderTotalInfoList.FirstOrDefault(x => x.Id == orderId); //actualProductAmount = orderPayment - freightPrice + pingtaibutie; pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M); - actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan; - preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; + actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan; + //preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; + preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M); dbOrder = new Order() { Id = orderId, @@ -595,7 +596,8 @@ namespace BBWY.Server.Business pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M); actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan; - preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; + //preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; + preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M); //preferentialAmount = dbOrder.PreferentialAmount; if (storageType != null && dbOrder.StorageType != storageType) diff --git a/BBWY.Server.Business/TestBusiness.cs b/BBWY.Server.Business/TestBusiness.cs index 3069f8bd..1850e817 100644 --- a/BBWY.Server.Business/TestBusiness.cs +++ b/BBWY.Server.Business/TestBusiness.cs @@ -190,11 +190,17 @@ namespace BBWY.Server.Business fsql.Update().Set(osku => osku.ShouldPay, 0).Where(osku => orderIdList.Contains(osku.OrderId)).ExecuteAffrows(); }); - foreach (var orderId in orderIdList) + for (var i = 0; i < orderIdList.Count(); i++) { + var orderId = orderIdList[i]; orderSyncBusiness.SyncOrder(shop, orderId); - Thread.Sleep(1000); + Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()} {shop.ShopName},orderProgress {i + 1}/{orderIdList.Count()}"); } + // foreach (var orderId in orderIdList) + // { + // orderSyncBusiness.SyncOrder(shop, orderId); + // Thread.Sleep(1000); + // } var orderList = fsql.Select(orderIdList).ToList(); var orderSkuList = fsql.Select().Where(osku => osku.Price > 0 && orderIdList.Contains(osku.OrderId)).ToList(); @@ -217,33 +223,39 @@ namespace BBWY.Server.Business foreach (var orderSku in currentOrderSkuList) { var ocd = currentOrderCostDetailList.FirstOrDefault(x => x.SkuId == orderSku.SkuId); - - ocd.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M, - orderSku.PingTaiChengDanYouHuiQuan ?? 0M, - orderSku.SuperRedEnvelope ?? 0M, - orderSku.XianPinLeiDongQuan ?? 0M, - orderSku.VenderFee ?? 0M, - shop.PlatformCommissionRatio ?? 0.05M); - var update = fsql.Update(ocd.Id).Set(x => x.SkuGrossProfit, ocd.SkuGrossProfit); - updateOrderCostDetailList.Add(update); + if (ocd != null) + { + ocd.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M, + orderSku.PingTaiChengDanYouHuiQuan ?? 0M, + orderSku.SuperRedEnvelope ?? 0M, + orderSku.XianPinLeiDongQuan ?? 0M, + orderSku.VenderFee ?? 0M, + shop.PlatformCommissionRatio ?? 0.05M); + var update = fsql.Update(ocd.Id).Set(x => x.SkuGrossProfit, ocd.SkuGrossProfit); + updateOrderCostDetailList.Add(update); + } } var currentAfterOrderList = afterOrderList.Where(af => af.OrderId == order.Id).ToList(); var orderTotal = orderTotalList.FirstOrDefault(on => on.Id == order.Id); var orderCost = orderCostList.FirstOrDefault(oc => oc.OrderId == order.Id); - orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M, - orderTotal.TotalPingTaiChengDanYouHuiQuan ?? 0M, - orderTotal.TotalVenderFee ?? 0M, - currentAfterOrderList); - if (updateOrderCostDetailList.Count() > 0) + if (orderCost != null && orderTotal != null) { - fsql.Transaction(() => + orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M, + orderTotal.TotalPingTaiChengDanYouHuiQuan ?? 0M, + orderTotal.TotalVenderFee ?? 0M, + currentAfterOrderList); + if (updateOrderCostDetailList.Count() > 0) { - foreach (var update in updateOrderCostDetailList) - update.ExecuteAffrows(); - fsql.Update(orderCost.OrderId).Set(oc => oc.Profit, orderCost.Profit) - .Set(oc => oc.PlatformCommissionAmount, orderCost.PlatformCommissionAmount).ExecuteAffrows(); - }); + fsql.Transaction(() => + { + foreach (var update in updateOrderCostDetailList) + update.ExecuteAffrows(); + fsql.Update(orderCost.OrderId).Set(oc => oc.Profit, orderCost.Profit) + .Set(oc => oc.PlatformCommissionAmount, orderCost.PlatformCommissionAmount).ExecuteAffrows(); + }); + } } + } } }