Browse Source

xx统计增加spu毛利率

AddValidOverTime
sanji 2 years ago
parent
commit
a7a9103bd6
  1. 51
      BBWY.Server.Business/Statistics/StatisticsBusiness.cs
  2. 19
      BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs

51
BBWY.Server.Business/Statistics/StatisticsBusiness.cs

@ -138,15 +138,16 @@ namespace BBWY.Server.Business
return list;
}
private void XingXiangCumulative(IList<XingXiangItemResponse> detailList, string spuId, bool isSD, decimal profit, decimal sdProductAmount, decimal sdCost)
private void XingXiangCumulative(IList<XingXiangItemResponse> detailList, string spuId, bool isSD, decimal profit, decimal spuProductAmount, decimal sdProductAmount, decimal sdCost)
{
var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId);
if (xxRespose == null)
{
xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M };
xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M, ActualAmount = 0M };
detailList.Add(xxRespose);
}
xxRespose.Profit += profit;
xxRespose.ActualAmount += spuProductAmount;
if (isSD)
{
xxRespose.SDOrderCount++;
@ -182,6 +183,7 @@ namespace BBWY.Server.Business
//DeliveryExpressFreight = oc.DeliveryExpressFreight,
//PreferentialAmount = oc.PreferentialAmount,
OrderSellerPrice = o.OrderSellerPrice,
FreightPrice = o.FreightPrice,
//SellerPreferentialAmount = o.SellerPreferentialAmount,
Profit = oc.Profit
});
@ -202,7 +204,7 @@ namespace BBWY.Server.Business
if (order.StorageType == Enums.StorageType.SD)
{
XingXiangCumulative(detailList, currentOrderSkuList[0].ProductId, true, order.Profit ?? 0M, order.OrderSellerPrice, Math.Abs(order.Profit ?? 0M));
XingXiangCumulative(detailList, currentOrderSkuList[0].ProductId, true, order.Profit ?? 0M, order.OrderSellerPrice, order.OrderSellerPrice + order.FreightPrice, Math.Abs(order.Profit ?? 0M));
continue;
}
@ -223,49 +225,8 @@ namespace BBWY.Server.Business
var spuProfitPercent = tempOrderProfit == 0M ? 0M : tempSpuProfit / tempOrderProfit;
var realSpuProfit = (order.Profit ?? 0M) * spuProfitPercent;
XingXiangCumulative(detailList, spuGroup.Key, false, realSpuProfit, 0, 0);
XingXiangCumulative(detailList, spuGroup.Key, false, realSpuProfit, tempSpuProductAmount, 0, 0);
}
//foreach (var group in spuGroups)
//{
// var spuId = group.Key;
// var profit = 0M;
// var sdCost = 0M;
// var prodcutAmount = group.Sum(osku => osku.Price * osku.ItemTotal) ?? 0; //货款
// var skuSellerPreferentialAmount = order.SellerPreferentialAmount / skuCount * group.Count(); //该SPU分摊的商家优惠金额
// prodcutAmount -= skuSellerPreferentialAmount;
// var commissionAmount = prodcutAmount * platformCommissionRatio; //该SPU的平台扣点金额
// var freightPriceByUser = order.FreightPrice == 0 ? 0 : order.FreightPrice / skuCount * group.Count(); //该SPU分摊的用户承担运费
// var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id && ocd.ProductId == spuId).ToList();
// var purchaseAmount = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.TotalCost) : 0;
// var deliveryFreight = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.DeliveryExpressFreight) : 0;
// if (order.StorageType != Enums.StorageType.SD)
// {
// profit = prodcutAmount + freightPriceByUser - purchaseAmount - deliveryFreight - commissionAmount;
// }
// else
// {
// var sdCommissionAmount = order.SDCommissionAmount.Value / skuCount * group.Count();
// profit = 0;
// sdCost = sdCommissionAmount + commissionAmount + order.DeliveryExpressFreight ?? 0M;
// totalSDOrderCost += sdCost;
// }
// var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId);
// if (xxRespose == null)
// {
// xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M };
// detailList.Add(xxRespose);
// }
// xxRespose.Profit += profit;
// if (order.StorageType == Enums.StorageType.SD)
// {
// xxRespose.SDOrderCount++;
// xxRespose.SDOrderAmount += prodcutAmount;
// xxRespose.SDOrderCost += sdCost;
// }
//}
}
var sdOrderList = orderList.Where(o => o.StorageType == Enums.StorageType.SD);

19
BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
@ -38,6 +39,22 @@ namespace BBWY.Server.Model.Dto
public decimal Profit { get; set; }
/// <summary>
/// 实收金额
/// </summary>
public decimal ActualAmount { get; set; }
/// <summary>
/// 毛利率
/// </summary>
public decimal ProfitRatio
{
get
{
return ActualAmount == 0 ? 0 : Math.Round(Profit / ActualAmount * 100, 2);
}
}
/// <summary>
/// 刷单单量
/// </summary>

Loading…
Cancel
Save