|
|
@ -77,7 +77,7 @@ namespace SiNan.Business |
|
|
|
.WhereIf(!string.IsNullOrEmpty(querySpu), p => p.Id == querySpu) |
|
|
|
.OrderBy(p => p.CreateTime) |
|
|
|
.ToList(p => p.Id); |
|
|
|
var skuList = fsql.Select<ProductSku>().Where(ps => ps.ShopId == shopId && ps.State == 1) |
|
|
|
var skuList = fsql.Select<ProductSku>().Where(ps => ps.ShopId == shopId && ps.State == 1 && ps.Price > 0) |
|
|
|
.WhereIf(!string.IsNullOrEmpty(querySpu), ps => ps.ProductId == querySpu) |
|
|
|
.OrderBy(ps => ps.CreateTime) |
|
|
|
.ToList(ps => new |
|
|
@ -111,7 +111,7 @@ namespace SiNan.Business |
|
|
|
spuGroupIndex++; |
|
|
|
Console.WriteLine($"{DateTime.Now} {shopName} SPU聚合 {spuGroupIndex}/{spuGroupCount}"); |
|
|
|
var currentGroupSkuList = skuList.Where(s => spuGroup.Contains(s.ProductId)).ToList(); |
|
|
|
var currentGroupSkuIdList = currentGroupSkuList.Select(ps => ps.Id).ToList(); |
|
|
|
var currentGroupSkuIdList = currentGroupSkuList.Select(ps => ps.Id).Distinct().ToList(); |
|
|
|
|
|
|
|
List<AggregationJDPopularizeSpuDaily> insertAggregationSpuDailyList = new List<AggregationJDPopularizeSpuDaily>(); |
|
|
|
List<AggregationJDPopularizeSkuDaily> insertAggregationSkuDailyList = new List<AggregationJDPopularizeSkuDaily>(); |
|
|
@ -122,7 +122,7 @@ namespace SiNan.Business |
|
|
|
|
|
|
|
var aggregationDate_ProductLevelList = goiBusiness.StatisticsProductLevelGOI(currentGroupSkuIdList, startDate_aggregationDate, endDate_aggregationDate); |
|
|
|
var aggregationDate_PopularizeLevelList = goiBusiness.StatisticsPopularizeLevelGOI(currentGroupSkuIdList, startDate_aggregationDate, endDate_aggregationDate); |
|
|
|
var aggregationDate_SpuActualAmountList = StatisticsActualAmountBySpu(spuGroup, startDate_aggregationDate, endDate_aggregationDate); |
|
|
|
var aggregationDate_SkuActualAmountList = StatisticsActualAmountBySku(currentGroupSkuIdList, startDate_aggregationDate, endDate_aggregationDate); |
|
|
|
IList<GOIBySku> recent7d_ProductLevelList = null; |
|
|
|
IList<GOIBySku> recent7d_PopularizeLevelList = null; |
|
|
|
IList<GOIBySku> recent30d_ProductLevelList = null; |
|
|
@ -180,7 +180,7 @@ namespace SiNan.Business |
|
|
|
ProductLevelGOI = spugoi_AggregationDate_ProductLevel?.GOI ?? 0M, |
|
|
|
PopularizeLevelProfit = spugoi_AggregationDate_PopularizeLevel?.Profit ?? 0M, |
|
|
|
PopularizeLevelGOI = spugoi_AggregationDate_PopularizeLevel?.GOI ?? 0M, |
|
|
|
ActualAmount = aggregationDate_SpuActualAmountList.FirstOrDefault(x => x.Spu == spuId)?.ActualAmount ?? 0M |
|
|
|
ActualAmount = aggregationDate_SkuActualAmountList.Where(x => x.Spu == spuId).Sum(x => x.ActualAmount) |
|
|
|
}; |
|
|
|
insertAggregationSpuDailyList.Add(spuDailyAggregation); |
|
|
|
#endregion
|
|
|
@ -287,7 +287,8 @@ namespace SiNan.Business |
|
|
|
ProductLevelProfit = skugoi_AggregationDate_ProductLevel?.Profit ?? 0M, |
|
|
|
ProductLevelGOI = skugoi_AggregationDate_ProductLevel?.GOI ?? 0M, |
|
|
|
PopularizeLevelProfit = skugoi_AggregationDate_PopularizeLevel?.Profit ?? 0M, |
|
|
|
PopularizeLevelGOI = skugoi_AggregationDate_PopularizeLevel?.GOI ?? 0M |
|
|
|
PopularizeLevelGOI = skugoi_AggregationDate_PopularizeLevel?.GOI ?? 0M, |
|
|
|
ActualAmount = aggregationDate_SkuActualAmountList.FirstOrDefault(x => x.Sku == skuId)?.ActualAmount ?? 0M |
|
|
|
}; |
|
|
|
insertAggregationSkuDailyList.Add(skuDailyAggregation); |
|
|
|
#endregion
|
|
|
@ -390,6 +391,25 @@ namespace SiNan.Business |
|
|
|
}); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
private IList<ActualAmountBySku> StatisticsActualAmountBySku(IList<string> skuList, DateTime startDate, DateTime endDate) |
|
|
|
{ |
|
|
|
var list = fsql.Select<OrderSku, Order>().InnerJoin((osku, o) => osku.OrderId == o.Id) |
|
|
|
.Where((osku, o) => o.OrderState != Enums.OrderState.已取消 && |
|
|
|
o.IsGift == false && |
|
|
|
o.StartTime >= startDate && |
|
|
|
o.EndTime <= endDate && |
|
|
|
osku.Price > 0 && |
|
|
|
skuList.Contains(osku.SkuId)) |
|
|
|
.GroupBy((osku, o) => new { osku.SkuId, osku.ProductId }) |
|
|
|
.ToList(g => new ActualAmountBySku |
|
|
|
{ |
|
|
|
ActualAmount = g.Sum(g.Value.Item1.ActualAmount), |
|
|
|
Sku = g.Key.SkuId, |
|
|
|
Spu = g.Key.ProductId |
|
|
|
}); |
|
|
|
return list; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 计划聚合任务
|
|
|
|