Browse Source

订单利润公式调整

AddValidOverTime
shanji 2 years ago
parent
commit
c85b3464f1
  1. 9
      BBWY.Server.Business/Extensions/OrderCostExtension.cs
  2. 33
      BBWY.Server.Business/Sync/OrderSyncBusiness.cs
  3. 4
      BBWY.Server.Business/TestBusiness.cs

9
BBWY.Server.Business/Extensions/OrderCostExtension.cs

@ -19,6 +19,7 @@ namespace BBWY.Server.Business.Extensions
orderCost.PlatformCommissionAmount = ((order.ActualProductAmount ?? 0M) - orderCost.RefundAmount) * orderCost.PlatformCommissionRatio;
var actualAmount = order.OrderSellerPrice + order.FreightPrice + (order.PingTaiChengDanYouHuiQuan ?? 0M);
//orderCost.Profit = order.OrderSellerPrice + order.FreightPrice - orderCost.RefundAmount -
// orderCost.PurchaseAmount -
@ -27,7 +28,7 @@ namespace BBWY.Server.Business.Extensions
// orderCost.AfterTotalCost +
// orderCost.RefundPurchaseAmount;
orderCost.Profit = (order.ActualProductAmount ?? 0M) -
orderCost.Profit = actualAmount -
orderCost.RefundAmount -
orderCost.PurchaseAmount -
orderCost.DeliveryExpressFreight -
@ -37,7 +38,7 @@ namespace BBWY.Server.Business.Extensions
}
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal actualAmountProduct, IList<AfterSaleOrder> afterSaleOrders)
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal actualAmount, IList<AfterSaleOrder> afterSaleOrders)
{
orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
@ -45,7 +46,7 @@ namespace BBWY.Server.Business.Extensions
//退款之后平台扣点
//orderCost.PlatformCommissionAmount = (orderPayment - freightPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
orderCost.PlatformCommissionAmount = (actualAmountProduct - orderCost.RefundAmount) * orderCost.PlatformCommissionRatio;
orderCost.PlatformCommissionAmount = (actualAmount - orderCost.RefundAmount) * orderCost.PlatformCommissionRatio;
//orderCost.Profit = orderSellerPrice + freightPrice - orderCost.RefundAmount -
// orderCost.PurchaseAmount -
@ -54,7 +55,7 @@ namespace BBWY.Server.Business.Extensions
// orderCost.AfterTotalCost +
// orderCost.RefundPurchaseAmount;
orderCost.Profit = actualAmountProduct -
orderCost.Profit = actualAmount -
orderCost.RefundAmount -
orderCost.PurchaseAmount -
orderCost.DeliveryExpressFreight -

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

@ -471,6 +471,7 @@ namespace BBWY.Server.Business
var storageType = ConvertStoreOrder(storeOrder);
decimal? actualProductAmount = 0M;
decimal actualAmount = 0M; //实收金额
decimal? preferentialAmount = 0M;
decimal? pingtaiChengDanYouHuiQuan = 0M;
@ -480,6 +481,7 @@ namespace BBWY.Server.Business
//actualProductAmount = orderPayment - freightPrice + pingtaibutie;
pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M);
actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan;
actualAmount = orderSellerPrice + freightPrice + (pingtaiChengDanYouHuiQuan ?? 0M);
//preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice;
preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M);
dbOrder = new Order()
@ -596,6 +598,7 @@ namespace BBWY.Server.Business
pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M);
actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan;
actualAmount = orderSellerPrice + freightPrice + (pingtaiChengDanYouHuiQuan ?? 0M);
//preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice;
preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M);
@ -675,34 +678,6 @@ namespace BBWY.Server.Business
}
#endregion
//#region 订单优惠
//var orderCouponJArray = (JArray)orderJToken["couponDetailList"];
//if (orderCouponJArray.HasValues)
//{
// foreach (var orderCouponJToken in orderCouponJArray)
// {
// var couponType = orderCouponJToken.Value<string>("couponType");
// if (string.IsNullOrEmpty(couponType))
// continue;
// //dbOrder.PreferentialAmount += orderCouponJToken.Value<decimal>("couponPrice");
// preferentialAmount += orderCouponJToken.Value<decimal>("couponPrice");
// if (!dbOrderCouponList.Any(oc => oc.OrderId == orderId))
// {
// insertOrderCouponList.Add(new OrderCoupon()
// {
// Id = idGenerator.NewLong(),
// SkuId = orderCouponJToken.Value<string>("skuId"),
// OrderId = orderId,
// CreateTime = DateTime.Now,
// CouponType = couponType,
// CouponPrice = orderCouponJToken.Value<decimal>("couponPrice")
// });
// }
// }
//}
//#endregion
#region 订单状态转换
var orderState = ConvertOrderState(orderJToken, dbOrder.StorageType);
#endregion
@ -923,7 +898,7 @@ namespace BBWY.Server.Business
if (dbOrder.OrderTotalPrice != 0)
orderCost.CalculationOrderProfitAndCost(dbOrder, null);
else
orderCost.CalculationOrderProfitAndCost(actualProductAmount ?? 0M, null);
orderCost.CalculationOrderProfitAndCost(actualAmount, null);
insertOrderCostList.Add(orderCost);
#endregion

4
BBWY.Server.Business/TestBusiness.cs

@ -252,8 +252,8 @@ namespace BBWY.Server.Business
var orderCost = orderCostList.FirstOrDefault(oc => oc.OrderId == order.Id);
if (orderCost != null && orderTotal != null)
{
orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M,
currentAfterOrderList);
var actualAmount = order.OrderSellerPrice + order.FreightPrice + (order.PingTaiChengDanYouHuiQuan ?? 0M);
orderCost.CalculationOrderProfitAndCost(actualAmount, currentAfterOrderList);
if (updateOrderCostDetailList.Count() > 0)
{
fsql.Transaction(() =>

Loading…
Cancel
Save