You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
2.4 KiB
39 lines
2.4 KiB
using BBWY.Server.Model.Db;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace BBWY.Server.Business.Extensions
|
|
{
|
|
public static class OrderCostExtension
|
|
{
|
|
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, Order order, 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);
|
|
orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
|
|
|
|
//退款之后平台扣点
|
|
orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
|
|
|
|
orderCost.Profit = order.OrderSellerPrice + order.FreightPrice - orderCost.RefundAmount -
|
|
orderCost.PurchaseAmount -
|
|
orderCost.DeliveryExpressFreight -
|
|
orderCost.PlatformCommissionAmount -
|
|
orderCost.AfterTotalCost +
|
|
orderCost.RefundPurchaseAmount;
|
|
}
|
|
|
|
public static void CalculationSDOrderProfitAndCost(this OrderCost orderCost, Order order, 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);
|
|
orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
|
|
|
|
//退款之后平台扣点
|
|
orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
|
|
orderCost.Profit = (orderCost.SDCommissionAmount + orderCost.SDOrderAmount + orderCost.DeliveryExpressFreight + orderCost.PlatformCommissionAmount + orderCost.AfterTotalCost) * -1;
|
|
}
|
|
}
|
|
}
|
|
|