|
|
@ -69,13 +69,14 @@ namespace SiNan.Business |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
private IList<GOIBySku> StatisticsPopularizeLevelGOI(IList<string> skuIdList, DateTime startDate, DateTime endDate) |
|
|
|
private IList<GOIBySku> StatisticsPopularizeLevelGOI(IList<string> skuIdList, DateTime? startDate, DateTime? endDate) |
|
|
|
{ |
|
|
|
IList<GOIBySku> list = new List<GOIBySku>(); |
|
|
|
|
|
|
|
var costs = fsql.Select<JDPopularizeAdSku>() |
|
|
|
.Where(jas => skuIdList.Contains(jas.Sku) && |
|
|
|
jas.Date >= startDate && jas.Date <= endDate) |
|
|
|
.Where(jas => skuIdList.Contains(jas.Sku)) // &&jas.Date >= startDate && jas.Date <= endDate
|
|
|
|
.WhereIf(startDate != null, jas => jas.Date >= startDate) |
|
|
|
.WhereIf(endDate != null, jas => jas.Date <= endDate) |
|
|
|
.GroupBy(jas => jas.Sku) |
|
|
|
.ToList(g => new |
|
|
|
{ |
|
|
@ -85,11 +86,11 @@ namespace SiNan.Business |
|
|
|
|
|
|
|
var profits = fsql.Select<JDOrderPopularizeRelation, OrderCostDetail, Order>() |
|
|
|
.InnerJoin((jr, ocd, o) => jr.OrderId == ocd.OrderId) |
|
|
|
.InnerJoin((jr, ocd, o) => jr.OrderId == o.Id) |
|
|
|
.Where((jr, ocd, o) => skuIdList.Contains(jr.PopularizeSku) && |
|
|
|
jr.CookieTime >= startDate && jr.CookieTime <= endDate && |
|
|
|
ocd.IsEnabled == true && |
|
|
|
o.OrderState != Enums.OrderState.已取消) |
|
|
|
.InnerJoin((jr, ocd, o) => jr.OrderId == o.Id) |
|
|
|
.Where((jr, ocd, o) => skuIdList.Contains(jr.PopularizeSku)) |
|
|
|
.WhereIf(startDate != null, (jr, ocd, o) => jr.CookieTime >= startDate) |
|
|
|
.WhereIf(endDate != null, (jr, ocd, o) => jr.CookieTime <= endDate) |
|
|
|
.Where((jr, ocd, o) => ocd.IsEnabled == true && o.OrderState != Enums.OrderState.已取消) |
|
|
|
.GroupBy((jr, ocd, o) => jr.PopularizeSku) |
|
|
|
.ToList(g => new |
|
|
|
{ |
|
|
@ -176,18 +177,8 @@ namespace SiNan.Business |
|
|
|
var recent30dayPopularizeLevelGOIList = StatisticsPopularizeLevelGOI(skuIdList, startDate_Recent30day, endDate_Recent30day); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 累计花费
|
|
|
|
var accumulatCosts = fsql.Select<JDPopularizeAdSku>() |
|
|
|
.Where(x => x.ShopId == request.ShopId && |
|
|
|
skuIdList.Contains(x.Sku) && |
|
|
|
x.Date >= request.StartDate && |
|
|
|
x.Date <= request.EndDate) |
|
|
|
.GroupBy(x => x.Sku) |
|
|
|
.ToList(g => new |
|
|
|
{ |
|
|
|
Cost = g.Sum(g.Value.Cost), |
|
|
|
Sku = g.Key |
|
|
|
}); |
|
|
|
#region 累计花费/累计亏损
|
|
|
|
var historyPopularizeLevelGOIList = StatisticsPopularizeLevelGOI(skuIdList, null, null); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
List<ProductGOIResponse> productGOIList = new List<ProductGOIResponse>(); |
|
|
@ -205,7 +196,10 @@ namespace SiNan.Business |
|
|
|
productSku.PromotionGOI_Yestoday = yestodayPopularizeLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); |
|
|
|
productSku.PromotionGOI_Recent7Day = recent7dayPopularizeLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); |
|
|
|
productSku.PromotionGOI_Recent30Day = recent30dayPopularizeLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); |
|
|
|
productSku.TotalCost = accumulatCosts.FirstOrDefault(x => x.Sku == productSku.Id)?.Cost ?? 0M; |
|
|
|
|
|
|
|
var historyPopularizeLevelGOI = historyPopularizeLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); |
|
|
|
productSku.TotalCost = historyPopularizeLevelGOI?.Cost ?? 0M; |
|
|
|
productSku.TotalDeficit = (historyPopularizeLevelGOI?.Profit ?? 0M) - (historyPopularizeLevelGOI?.Cost ?? 0M); |
|
|
|
} |
|
|
|
|
|
|
|
productGoi.ProductGOI_Yestoday = new GOIResponse() |
|
|
@ -240,6 +234,7 @@ namespace SiNan.Business |
|
|
|
Profit = productGoi.ProductSkuGOIList.Sum(x => x.PromotionGOI_Recent30Day?.Profit ?? 0M) |
|
|
|
}; |
|
|
|
productGoi.TotalCost = productGoi.ProductSkuGOIList.Sum(x => x.TotalCost); |
|
|
|
productGoi.TotalDeficit = productGoi.ProductSkuGOIList.Sum(x => x.TotalDeficit); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|