|
|
@ -1077,5 +1077,56 @@ namespace BBWYB.Server.Business |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void SyncPurchaserCategory() |
|
|
|
{ |
|
|
|
var purchaserIdList = fsql.Select<Purchaser>() |
|
|
|
.Where(p => !fsql.Select<Purchaser_ExtendedInfo_Relation>().Where(per => per.ExtendedType == Enums.PurchaserBasicInfoType.主营类目 && |
|
|
|
per.PurchaserId == p.Id).Any()) |
|
|
|
.ToList(p => p.Id); |
|
|
|
if (purchaserIdList.Count() == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
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 |
|
|
|
}); |
|
|
|
|
|
|
|
if (pspList.Count() == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
List<Purchaser_ExtendedInfo_Relation> insertList = new List<Purchaser_ExtendedInfo_Relation>(); |
|
|
|
|
|
|
|
foreach (var purchaserId in purchaserIdList) |
|
|
|
{ |
|
|
|
var currentPspList = pspList.Where(x => x.PurchaserId == purchaserId).ToList(); |
|
|
|
if (currentPspList.Count() > 0) |
|
|
|
{ |
|
|
|
var categoryList = currentPspList.GroupBy(x => x.CategoryId).Select(g => new Purchaser_ExtendedInfo_Relation() |
|
|
|
{ |
|
|
|
Id = idGenerator.NewLong(), |
|
|
|
ExtendedInfoId = g.Key, |
|
|
|
ExtendedType = Enums.PurchaserBasicInfoType.主营类目, |
|
|
|
PurchaserId = purchaserId |
|
|
|
}).ToList(); |
|
|
|
insertList.AddRange(categoryList); |
|
|
|
Console.WriteLine($"insert count {insertList.Count()}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (insertList.Count() > 0) |
|
|
|
{ |
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
fsql.Insert(insertList).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|