|
|
@ -6,6 +6,7 @@ using BBWY.Server.Model.Db; |
|
|
|
using BBWY.Server.Model.Db.Mds; |
|
|
|
using BBWY.Server.Model.Dto; |
|
|
|
using FreeSql; |
|
|
|
using Jd.Api.Request; |
|
|
|
using Microsoft.Extensions.Caching.Memory; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Newtonsoft.Json; |
|
|
@ -425,6 +426,44 @@ namespace BBWY.Server.Business |
|
|
|
Console.WriteLine(b["123"]); |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateSkuGift() |
|
|
|
{ |
|
|
|
var dbSkuIdList = fsql.Select<ProductSku>().Where(ps => ps.IsGift == false).ToList(ps => ps.Id); |
|
|
|
var ptList = fsql.Select<PromotionTask>().Where(pt => !string.IsNullOrEmpty(pt.GiftTemplatePutNewSku)).ToList(); |
|
|
|
var giftSkuList = new List<string>(); |
|
|
|
var splitChar = new char[] { ',' }; |
|
|
|
foreach (var pt in ptList) |
|
|
|
{ |
|
|
|
giftSkuList.AddRange(pt.GiftTemplatePutNewSku.Split(splitChar, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
} |
|
|
|
var updateGiftSkuIdList = dbSkuIdList.Intersect(giftSkuList).ToList(); |
|
|
|
|
|
|
|
var updateList = new List<string>(); |
|
|
|
var index = 1; |
|
|
|
foreach (var skuId in updateGiftSkuIdList) |
|
|
|
{ |
|
|
|
updateList.Add(skuId); |
|
|
|
if (updateList.Count() == 20) |
|
|
|
{ |
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
fsql.Update<ProductSku>(updateList).Set(ps => ps.IsGift, true).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
updateList.Clear(); |
|
|
|
Console.WriteLine($"update productsku gift {index}"); |
|
|
|
index++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (updateList.Count() > 0) |
|
|
|
{ |
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
fsql.Update<ProductSku>(updateList).Set(ps => ps.IsGift, true).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
updateList.Clear(); |
|
|
|
Console.WriteLine($"last update productsku gift"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|