|
|
@ -165,15 +165,22 @@ namespace BBWY.Server.Business.Sync |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 找出状态变化的SKU
|
|
|
|
var stateChangeProductSkuList = productSkuList.Where(p => dbProductSkuList.Any(dp => dp.Id == p.Id && (dp.State != p.State || dp.Title != p.Title || dp.Price != p.Price || dp.Logo != p.Logo))).ToList(); |
|
|
|
var stateChangeProductSkuList = productSkuList.Where(p => dbProductSkuList.Any(dp => dp.Id == p.Id && (dp.State != p.State || |
|
|
|
dp.Title != p.Title || |
|
|
|
dp.Price != p.Price || |
|
|
|
dp.Logo != p.Logo || |
|
|
|
dp.CategoryId != p.Source.Value<int>("categoryId")))).ToList(); |
|
|
|
if (stateChangeProductSkuList.Count() > 0) |
|
|
|
{ |
|
|
|
foreach (var productSku in stateChangeProductSkuList) |
|
|
|
{ |
|
|
|
var categoryName = GetCategoryName(shop, productSku.Source.Value<string>("categoryId")); |
|
|
|
var update = fsql.Update<ProductSku>(productSku.Id).Set(p => p.State, productSku.State) |
|
|
|
.Set(p => p.Title, productSku.Title) |
|
|
|
.Set(p => p.Price, productSku.Price) |
|
|
|
.Set(p => p.Logo, productSku.Logo); |
|
|
|
.Set(p => p.Logo, productSku.Logo) |
|
|
|
.Set(p => p.CategoryId, productSku.Source.Value<int>("categoryId")) |
|
|
|
.Set(p => p.CategoryName, categoryName); |
|
|
|
updateProductSkuList.Add(update); |
|
|
|
} |
|
|
|
} |
|
|
@ -256,6 +263,19 @@ namespace BBWY.Server.Business.Sync |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 同步所有店铺的全部产品
|
|
|
|
/// </summary>
|
|
|
|
public void SyncOneShopProduct(long shopId) |
|
|
|
{ |
|
|
|
var shopList = venderBusiness.GetShopList(shopId, platform: Enums.Platform.京东); |
|
|
|
//SyncProduct(shopList.FirstOrDefault(s => s.ShopId == "11482739"), true);
|
|
|
|
foreach (var shop in shopList) |
|
|
|
{ |
|
|
|
Task.Factory.StartNew(() => SyncProduct(shop, true), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private string GetCategoryName(ShopResponse shop, string categoryId) |
|
|
|
{ |
|
|
|
if (categoryCache.TryGetValue(categoryId, out string name)) |
|
|
|