|
@ -773,27 +773,6 @@ namespace BBWYB.Server.Business |
|
|
var skuIdList = purchaseSchemeList.Select(ps => ps.SkuId).Distinct().ToList(); |
|
|
var skuIdList = purchaseSchemeList.Select(ps => ps.SkuId).Distinct().ToList(); |
|
|
var recentDate = DateTime.Now.Date.AddDays(-30); |
|
|
var recentDate = DateTime.Now.Date.AddDays(-30); |
|
|
|
|
|
|
|
|
//var purchaseSchemeProductList = fsql.Select<PurchaseSchemeProduct, Purchaser>()
|
|
|
|
|
|
// .InnerJoin((psp, p) => psp.PurchaserId == p.Id)
|
|
|
|
|
|
// .Where((psp, p) => purchaseSchemeIdList.Contains(psp.SkuPurchaseSchemeId))
|
|
|
|
|
|
// .ToList((psp, p) => new PurchaseSchemeProductResponse
|
|
|
|
|
|
// {
|
|
|
|
|
|
// CreateTime = psp.CreateTime,
|
|
|
|
|
|
// Id = psp.Id,
|
|
|
|
|
|
// ProductId = psp.ProductId,
|
|
|
|
|
|
// PurchaseProductId = psp.PurchaseProductId,
|
|
|
|
|
|
// PurchaseUrl = psp.PurchaseUrl,
|
|
|
|
|
|
// SkuId = psp.SkuId,
|
|
|
|
|
|
// SkuPurchaseSchemeId = psp.SkuPurchaseSchemeId,
|
|
|
|
|
|
// PurchaserId = p.Id,
|
|
|
|
|
|
// PurchaserId2 = p.Id2,
|
|
|
|
|
|
// PurchaserLocation = p.Location,
|
|
|
|
|
|
// PurchaserName = p.Name,
|
|
|
|
|
|
// PurchasePlatform = p.Platform,
|
|
|
|
|
|
// PurchaserMemberId = p.MemberId
|
|
|
|
|
|
// //PurchaserPurchasedCount = p.PurchasedCount,
|
|
|
|
|
|
// //PurchaserPurchasedSkuCount = p.PurchasedSkuCount,
|
|
|
|
|
|
// });
|
|
|
|
|
|
var purchaseSchemeProductList = fsql.Select<PurchaseSchemeProduct>() |
|
|
var purchaseSchemeProductList = fsql.Select<PurchaseSchemeProduct>() |
|
|
.Where(psp => purchaseSchemeIdList.Contains(psp.SkuPurchaseSchemeId)) |
|
|
.Where(psp => purchaseSchemeIdList.Contains(psp.SkuPurchaseSchemeId)) |
|
|
.ToList<PurchaseSchemeProductResponse>(); |
|
|
.ToList<PurchaseSchemeProductResponse>(); |
|
@ -856,48 +835,20 @@ namespace BBWYB.Server.Business |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<string> purchaserIdList = purchaseSchemeProductList.Select(x => x.PurchaserId).Distinct().ToList(); |
|
|
List<PurchaseSchemeProductSkuStatistic> purchaseSkuStatisticList = null; |
|
|
var dbPurchaserList = fsql.Select<Purchaser>(purchaserIdList).ToList<PurchaserResponse>(); |
|
|
if (request.IncludePurchaseSkuStatisticsInfo == 1) |
|
|
//if (request.IncludePurchaserStatisticsInfo == 1)
|
|
|
{ |
|
|
//{
|
|
|
var purchaseSkuIdList = purchaseSchemeList.SelectMany(ps => ps.PurchaseSchemeProductList.SelectMany(psp => psp.PurchaseSchemeProductSkuList)) |
|
|
// #region 查询SKU采购数
|
|
|
.Select(pss => pss.PurchaseSkuId) |
|
|
// var purchasedSkuList = fsql.Select<SkuHistoryPurchaserRelation, ProductSku>()
|
|
|
.Distinct() |
|
|
// .InnerJoin((spr, ps) => spr.SkuId == ps.Id)
|
|
|
.ToList(); |
|
|
// .Where((spr, ps) => ps.ShopId == request.ShopId && purchaserIdList.Contains(spr.PurchaserId))
|
|
|
purchaseSkuStatisticList = fsql.Select<PurchaseSchemeProductSkuStatistic>(purchaseSkuIdList) |
|
|
// .GroupBy((spr, ps) => new { spr.PurchaserId, spr.SkuId })
|
|
|
.ToList(); |
|
|
// .ToList(g => new
|
|
|
|
|
|
// {
|
|
|
|
|
|
// g.Key.PurchaserId,
|
|
|
|
|
|
// g.Key.SkuId
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
|
|
|
|
// #region 查询订单数
|
|
|
|
|
|
// var poList = fsql.Select<OrderPurchaseInfo, Order>()
|
|
|
|
|
|
// .InnerJoin((opi, o) => opi.OrderId == o.Id)
|
|
|
|
|
|
// .Where((opi, o) => opi.ShopId == request.ShopId &&
|
|
|
|
|
|
// opi.IsEnabled == true &&
|
|
|
|
|
|
// o.OrderState != Enums.OrderState.已取消 &&
|
|
|
|
|
|
// purchaserIdList.Contains(opi.PurchaserId))
|
|
|
|
|
|
// .GroupBy((opi, o) => opi.PurchaserId)
|
|
|
|
|
|
// .ToList(g => new
|
|
|
|
|
|
// {
|
|
|
|
|
|
// PurchaserId = g.Key,
|
|
|
|
|
|
// Count = g.Count()
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// #endregion
|
|
|
} |
|
|
|
|
|
|
|
|
// foreach (var purchaser in dbPurchaserList)
|
|
|
List<string> purchaserIdList = purchaseSchemeProductList.Select(x => x.PurchaserId).Distinct().ToList(); |
|
|
// {
|
|
|
var dbPurchaserList = fsql.Select<Purchaser>(purchaserIdList).ToList<PurchaserResponse>(); |
|
|
// purchaser.PurchasedSkuCount = purchasedSkuList.Where(x => x.PurchaserId == purchaser.Id)
|
|
|
|
|
|
// .Select(x => x.SkuId)
|
|
|
|
|
|
// .Distinct()
|
|
|
|
|
|
// .Count();
|
|
|
|
|
|
// purchaser.PurchasedCount = poList.FirstOrDefault(x => x.PurchaserId == purchaser.Id)?.Count ?? 0;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var scheme in purchaseSchemeList) |
|
|
foreach (var scheme in purchaseSchemeList) |
|
|
{ |
|
|
{ |
|
@ -925,6 +876,18 @@ namespace BBWYB.Server.Business |
|
|
schemeProduct.PurchasePlatform = purchaser.Platform; |
|
|
schemeProduct.PurchasePlatform = purchaser.Platform; |
|
|
schemeProduct.PurchaserTag = purchaser.Tag; |
|
|
schemeProduct.PurchaserTag = purchaser.Tag; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (request.IncludePurchaseSkuStatisticsInfo == 1) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var schemeProductSku in schemeProduct.PurchaseSchemeProductSkuList) |
|
|
|
|
|
{ |
|
|
|
|
|
var pssStatistic = purchaseSkuStatisticList.FirstOrDefault(x => x.PurchaseSkuId == schemeProductSku.PurchaseSkuId); |
|
|
|
|
|
schemeProductSku.PurchasedAmount = pssStatistic?.PurchasedAmount ?? 0M; |
|
|
|
|
|
schemeProductSku.PurchasedItemCount = pssStatistic?.PurchasedItemCount ?? 0; |
|
|
|
|
|
schemeProductSku.LastPurchasedPrice = pssStatistic?.LastPurchasedPrice ?? 0; |
|
|
|
|
|
schemeProductSku.LastPurchasedTime = pssStatistic?.LastPurchasedTime; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -984,6 +947,7 @@ namespace BBWYB.Server.Business |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return purchaseSchemeList; |
|
|
return purchaseSchemeList; |
|
|
} |
|
|
} |
|
|