diff --git a/BBWY.Server.Business/Extensions/OrderCostExtension.cs b/BBWY.Server.Business/Extensions/OrderCostExtension.cs index a3886f56..96ce4353 100644 --- a/BBWY.Server.Business/Extensions/OrderCostExtension.cs +++ b/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 afterSaleOrders) + public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal actualAmount, IList 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 - diff --git a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs index c4efd2c7..27837954 100644 --- a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs +++ b/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("couponType"); - // if (string.IsNullOrEmpty(couponType)) - // continue; - // //dbOrder.PreferentialAmount += orderCouponJToken.Value("couponPrice"); - // preferentialAmount += orderCouponJToken.Value("couponPrice"); - // if (!dbOrderCouponList.Any(oc => oc.OrderId == orderId)) - // { - // insertOrderCouponList.Add(new OrderCoupon() - // { - // Id = idGenerator.NewLong(), - // SkuId = orderCouponJToken.Value("skuId"), - // OrderId = orderId, - // CreateTime = DateTime.Now, - // CouponType = couponType, - // CouponPrice = orderCouponJToken.Value("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 diff --git a/BBWY.Server.Business/TestBusiness.cs b/BBWY.Server.Business/TestBusiness.cs index 8aefb3d2..a21a887a 100644 --- a/BBWY.Server.Business/TestBusiness.cs +++ b/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(() =>