|
@ -138,15 +138,16 @@ namespace BBWY.Server.Business |
|
|
return list; |
|
|
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); |
|
|
var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId); |
|
|
if (xxRespose == null) |
|
|
if (xxRespose == null) |
|
|
{ |
|
|
{ |
|
|
xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M }; |
|
|
xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M, ActualAmount = 0M }; |
|
|
detailList.Add(xxRespose); |
|
|
detailList.Add(xxRespose); |
|
|
} |
|
|
} |
|
|
xxRespose.Profit += profit; |
|
|
xxRespose.Profit += profit; |
|
|
|
|
|
xxRespose.ActualAmount += spuProductAmount; |
|
|
if (isSD) |
|
|
if (isSD) |
|
|
{ |
|
|
{ |
|
|
xxRespose.SDOrderCount++; |
|
|
xxRespose.SDOrderCount++; |
|
@ -182,6 +183,7 @@ namespace BBWY.Server.Business |
|
|
//DeliveryExpressFreight = oc.DeliveryExpressFreight,
|
|
|
//DeliveryExpressFreight = oc.DeliveryExpressFreight,
|
|
|
//PreferentialAmount = oc.PreferentialAmount,
|
|
|
//PreferentialAmount = oc.PreferentialAmount,
|
|
|
OrderSellerPrice = o.OrderSellerPrice, |
|
|
OrderSellerPrice = o.OrderSellerPrice, |
|
|
|
|
|
FreightPrice = o.FreightPrice, |
|
|
//SellerPreferentialAmount = o.SellerPreferentialAmount,
|
|
|
//SellerPreferentialAmount = o.SellerPreferentialAmount,
|
|
|
Profit = oc.Profit |
|
|
Profit = oc.Profit |
|
|
}); |
|
|
}); |
|
@ -202,7 +204,7 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
|
if (order.StorageType == Enums.StorageType.SD) |
|
|
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; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -223,49 +225,8 @@ namespace BBWY.Server.Business |
|
|
var spuProfitPercent = tempOrderProfit == 0M ? 0M : tempSpuProfit / tempOrderProfit; |
|
|
var spuProfitPercent = tempOrderProfit == 0M ? 0M : tempSpuProfit / tempOrderProfit; |
|
|
|
|
|
|
|
|
var realSpuProfit = (order.Profit ?? 0M) * spuProfitPercent; |
|
|
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); |
|
|
var sdOrderList = orderList.Where(o => o.StorageType == Enums.StorageType.SD); |
|
|