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(); + }); + } } + } } }