Browse Source

司南接口更新

GOIAggregation
sanji 2 years ago
parent
commit
c053201b2d
  1. 22
      SiNan.Business/GOIBusiness.cs

22
SiNan.Business/GOIBusiness.cs

@ -95,7 +95,7 @@ namespace SiNan.Business
return list; return list;
} }
private GOIByShop StatisticsPopularizeLevelGOI(long shopId, DateTime? startDate, DateTime? endDate) private GOIByShop StatisticsProductLevelGOI(long shopId, DateTime? startDate, DateTime? endDate)
{ {
var cost = fsql.Select<JDPopularizeAdSku>() var cost = fsql.Select<JDPopularizeAdSku>()
.Where(jas => jas.ShopId == shopId) // &&jas.Date >= startDate && jas.Date <= endDate .Where(jas => jas.ShopId == shopId) // &&jas.Date >= startDate && jas.Date <= endDate
@ -103,14 +103,14 @@ namespace SiNan.Business
.WhereIf(endDate != null, jas => jas.Date <= endDate) .WhereIf(endDate != null, jas => jas.Date <= endDate)
.Sum(jas => jas.Cost); .Sum(jas => jas.Cost);
var profit = fsql.Select<JDOrderPopularizeRelation, OrderCostDetail, Order>() var profit = fsql.Select<OrderCostDetail, Order>()
.InnerJoin((jr, ocd, o) => jr.OrderId == ocd.OrderId) .InnerJoin((ocd, o) => ocd.OrderId == o.Id)
.InnerJoin((jr, ocd, o) => jr.OrderId == o.Id) .Where((ocd, o) => o.ShopId == shopId &&
.Where((jr, ocd, o) => jr.ShopId == shopId) ocd.IsEnabled &&
.WhereIf(startDate != null, (jr, ocd, o) => jr.CookieTime >= startDate) ocd.CreateTime >= startDate &&
.WhereIf(endDate != null, (jr, ocd, o) => jr.CookieTime <= endDate) ocd.CreateTime <= endDate &&
.Where((jr, ocd, o) => ocd.IsEnabled == true && o.OrderState != Enums.OrderState.) o.OrderState != Enums.OrderState.)
.Sum((jr, ocd, o) => ocd.SkuGrossProfit); .ToAggregate((ocd, o) => ocd.Sum(ocd.Key.SkuGrossProfit));
return new GOIByShop() return new GOIByShop()
{ {
@ -552,7 +552,7 @@ namespace SiNan.Business
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1); request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
var productSkuList = fsql.Select<ProductSku>().Where(ps => request.SpuIdList.Contains(ps.ProductId)).ToList(); var productSkuList = fsql.Select<ProductSku>().Where(ps => request.SpuIdList.Contains(ps.ProductId)).ToList();
var skuIdList = productSkuList.Select(ps => ps.ProductId).Distinct().ToList(); var skuIdList = productSkuList.Select(ps => ps.ProductId).Distinct().ToList();
var goiList = StatisticsPopularizeLevelGOI(skuIdList, request.StartTime, request.EndTime); var goiList = StatisticsProductLevelGOI(skuIdList, request.StartTime, request.EndTime);
foreach (var spu in request.SpuIdList) foreach (var spu in request.SpuIdList)
{ {
var currentSpuSkuIdList = productSkuList.Where(ps => ps.ProductId == spu).Select(ps => ps.Id).ToList(); var currentSpuSkuIdList = productSkuList.Where(ps => ps.ProductId == spu).Select(ps => ps.Id).ToList();
@ -574,7 +574,7 @@ namespace SiNan.Business
public GOIByShop QueryPopularizeLevelGOIByShopId(QueryPopularizeLevelGOIByShopIdRequest request) public GOIByShop QueryPopularizeLevelGOIByShopId(QueryPopularizeLevelGOIByShopIdRequest request)
{ {
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1); request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
return StatisticsPopularizeLevelGOI(request.ShopId, request.StartTime, request.EndTime); return StatisticsProductLevelGOI(request.ShopId, request.StartTime, request.EndTime);
} }
} }
} }

Loading…
Cancel
Save