Browse Source

订单优惠公式调整

AddValidOverTime
shanji 2 years ago
parent
commit
cb8a95380d
  1. 8
      BBWY.Server.Business/Sync/OrderSyncBusiness.cs
  2. 56
      BBWY.Server.Business/TestBusiness.cs

8
BBWY.Server.Business/Sync/OrderSyncBusiness.cs

@ -479,8 +479,9 @@ namespace BBWY.Server.Business
var orderTotalInfo = insertOrderTotalInfoList.FirstOrDefault(x => x.Id == orderId); var orderTotalInfo = insertOrderTotalInfoList.FirstOrDefault(x => x.Id == orderId);
//actualProductAmount = orderPayment - freightPrice + pingtaibutie; //actualProductAmount = orderPayment - freightPrice + pingtaibutie;
pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M); pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M);
actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan; actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan;
preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; //preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice;
preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M);
dbOrder = new Order() dbOrder = new Order()
{ {
Id = orderId, Id = orderId,
@ -595,7 +596,8 @@ namespace BBWY.Server.Business
pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M); pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M);
actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan; actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan;
preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; //preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice;
preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M);
//preferentialAmount = dbOrder.PreferentialAmount; //preferentialAmount = dbOrder.PreferentialAmount;
if (storageType != null && dbOrder.StorageType != storageType) if (storageType != null && dbOrder.StorageType != storageType)

56
BBWY.Server.Business/TestBusiness.cs

@ -190,11 +190,17 @@ namespace BBWY.Server.Business
fsql.Update<OrderSku>().Set(osku => osku.ShouldPay, 0).Where(osku => orderIdList.Contains(osku.OrderId)).ExecuteAffrows(); fsql.Update<OrderSku>().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); 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<Order>(orderIdList).ToList(); var orderList = fsql.Select<Order>(orderIdList).ToList();
var orderSkuList = fsql.Select<OrderSku>().Where(osku => osku.Price > 0 && orderIdList.Contains(osku.OrderId)).ToList(); var orderSkuList = fsql.Select<OrderSku>().Where(osku => osku.Price > 0 && orderIdList.Contains(osku.OrderId)).ToList();
@ -217,33 +223,39 @@ namespace BBWY.Server.Business
foreach (var orderSku in currentOrderSkuList) foreach (var orderSku in currentOrderSkuList)
{ {
var ocd = currentOrderCostDetailList.FirstOrDefault(x => x.SkuId == orderSku.SkuId); var ocd = currentOrderCostDetailList.FirstOrDefault(x => x.SkuId == orderSku.SkuId);
if (ocd != null)
ocd.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M, {
orderSku.PingTaiChengDanYouHuiQuan ?? 0M, ocd.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M,
orderSku.SuperRedEnvelope ?? 0M, orderSku.PingTaiChengDanYouHuiQuan ?? 0M,
orderSku.XianPinLeiDongQuan ?? 0M, orderSku.SuperRedEnvelope ?? 0M,
orderSku.VenderFee ?? 0M, orderSku.XianPinLeiDongQuan ?? 0M,
shop.PlatformCommissionRatio ?? 0.05M); orderSku.VenderFee ?? 0M,
var update = fsql.Update<OrderCostDetail>(ocd.Id).Set(x => x.SkuGrossProfit, ocd.SkuGrossProfit); shop.PlatformCommissionRatio ?? 0.05M);
updateOrderCostDetailList.Add(update); var update = fsql.Update<OrderCostDetail>(ocd.Id).Set(x => x.SkuGrossProfit, ocd.SkuGrossProfit);
updateOrderCostDetailList.Add(update);
}
} }
var currentAfterOrderList = afterOrderList.Where(af => af.OrderId == order.Id).ToList(); var currentAfterOrderList = afterOrderList.Where(af => af.OrderId == order.Id).ToList();
var orderTotal = orderTotalList.FirstOrDefault(on => on.Id == order.Id); var orderTotal = orderTotalList.FirstOrDefault(on => on.Id == order.Id);
var orderCost = orderCostList.FirstOrDefault(oc => oc.OrderId == order.Id); var orderCost = orderCostList.FirstOrDefault(oc => oc.OrderId == order.Id);
orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M, if (orderCost != null && orderTotal != null)
orderTotal.TotalPingTaiChengDanYouHuiQuan ?? 0M,
orderTotal.TotalVenderFee ?? 0M,
currentAfterOrderList);
if (updateOrderCostDetailList.Count() > 0)
{ {
fsql.Transaction(() => orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M,
orderTotal.TotalPingTaiChengDanYouHuiQuan ?? 0M,
orderTotal.TotalVenderFee ?? 0M,
currentAfterOrderList);
if (updateOrderCostDetailList.Count() > 0)
{ {
foreach (var update in updateOrderCostDetailList) fsql.Transaction(() =>
update.ExecuteAffrows(); {
fsql.Update<OrderCost>(orderCost.OrderId).Set(oc => oc.Profit, orderCost.Profit) foreach (var update in updateOrderCostDetailList)
.Set(oc => oc.PlatformCommissionAmount, orderCost.PlatformCommissionAmount).ExecuteAffrows(); update.ExecuteAffrows();
}); fsql.Update<OrderCost>(orderCost.OrderId).Set(oc => oc.Profit, orderCost.Profit)
.Set(oc => oc.PlatformCommissionAmount, orderCost.PlatformCommissionAmount).ExecuteAffrows();
});
}
} }
} }
} }
} }

Loading…
Cancel
Save