|
|
@ -47,6 +47,7 @@ namespace BBWYB.Server.Business |
|
|
|
Console.WriteLine($"聚合{i + 1}/{purchaserIdList.Count()}"); |
|
|
|
Aggregion(tempPurchaserIdList); |
|
|
|
tempPurchaserIdList.Clear(); |
|
|
|
Thread.Sleep(2000); |
|
|
|
} |
|
|
|
} |
|
|
|
if (tempPurchaserIdList.Count() > 0) |
|
|
@ -59,9 +60,24 @@ namespace BBWYB.Server.Business |
|
|
|
|
|
|
|
private void Aggregion(IList<string> purchaserIdList) |
|
|
|
{ |
|
|
|
Thread.Sleep(2000); |
|
|
|
|
|
|
|
List<IUpdate<Purchaser>> updatePurchaserList = new List<IUpdate<Purchaser>>(); |
|
|
|
List<long> deletePeiList = new List<long>(); |
|
|
|
List<Purchaser_ExtendedInfo_Relation> insertPeiList = new List<Purchaser_ExtendedInfo_Relation>(); |
|
|
|
|
|
|
|
List<Purchaser_ExtendedInfo_Relation> dbPeiList = fsql.Select<Purchaser_ExtendedInfo_Relation>() |
|
|
|
.Where(pei => pei.ExtendedType == Enums.PurchaserBasicInfoType.主营类目 && |
|
|
|
purchaserIdList.Contains(pei.PurchaserId)) |
|
|
|
.ToList(); |
|
|
|
|
|
|
|
var pspList = fsql.Select<PurchaseSchemeProduct, Product>() |
|
|
|
.InnerJoin((psp, p) => psp.ProductId == p.Id) |
|
|
|
.Where((psp, p) => p.CategoryId != null && purchaserIdList.Contains(psp.PurchaserId)) |
|
|
|
.ToList((psp, p) => new |
|
|
|
{ |
|
|
|
psp.PurchaserId, |
|
|
|
psp.ProductId, |
|
|
|
p.CategoryId |
|
|
|
}); |
|
|
|
|
|
|
|
#region 查询SPU绑定数/SKU绑定数
|
|
|
|
var bindList = fsql.Select<PurchaseSchemeProduct, PurchaseScheme>() |
|
|
@ -192,6 +208,32 @@ namespace BBWYB.Server.Business |
|
|
|
var recent90dPurchasedCount = recent90dPurchasedCountList.FirstOrDefault(x => x.PurchaserId == purchaserId)?.Count ?? 0; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 主营类目
|
|
|
|
{ |
|
|
|
var currentDbPeiList = dbPeiList.Where(pei => pei.PurchaserId == purchaserId).ToList(); |
|
|
|
var currentDbPspList = pspList.Where(psp => psp.PurchaserId == purchaserId).ToList(); |
|
|
|
|
|
|
|
var currentDeletePeiList = currentDbPeiList.Where(pei => !currentDbPspList.Any(psp => psp.PurchaserId == pei.PurchaserId && |
|
|
|
psp.CategoryId == pei.ExtendedInfoId)) |
|
|
|
.Select(pei => pei.Id).ToList(); |
|
|
|
if (currentDeletePeiList.Count() > 0) |
|
|
|
deletePeiList.AddRange(currentDeletePeiList); |
|
|
|
|
|
|
|
var currentInsertPeiList = currentDbPspList.Where(psp => !currentDbPeiList.Any(pei => pei.PurchaserId == psp.PurchaserId && |
|
|
|
pei.ExtendedInfoId == psp.CategoryId)) |
|
|
|
.GroupBy(psp => psp.CategoryId) |
|
|
|
.Select(g => new Purchaser_ExtendedInfo_Relation() |
|
|
|
{ |
|
|
|
Id = idGenerator.NewLong(), |
|
|
|
ExtendedInfoId = g.Key, |
|
|
|
ExtendedType = Enums.PurchaserBasicInfoType.主营类目, |
|
|
|
PurchaserId = purchaserId |
|
|
|
}).ToList(); |
|
|
|
if (currentInsertPeiList.Count() > 0) |
|
|
|
insertPeiList.AddRange(currentInsertPeiList); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
var update = fsql.Update<Purchaser>(purchaserId) |
|
|
|
.Set(p => p.BindingSpuCount, bindingSpuCount) |
|
|
|
.Set(p => p.BindingSkuCount, bindingSkuCount) |
|
|
@ -209,6 +251,10 @@ namespace BBWYB.Server.Business |
|
|
|
{ |
|
|
|
foreach (var update in updatePurchaserList) |
|
|
|
update.ExecuteAffrows(); |
|
|
|
if (deletePeiList.Count() > 0) |
|
|
|
fsql.Delete<Purchaser_ExtendedInfo_Relation>(deletePeiList).ExecuteAffrows(); |
|
|
|
if (insertPeiList.Count() > 0) |
|
|
|
fsql.Insert(insertPeiList).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|