|
|
@ -37,7 +37,10 @@ namespace BBWY.Server.Business.Sync |
|
|
|
this.productBusiness = productBusiness; |
|
|
|
} |
|
|
|
|
|
|
|
private void SyncProduct(ShopResponse shop, ProductListResponse productList) |
|
|
|
private void SyncProduct(ShopResponse shop, ProductListResponse productList, out string productId) |
|
|
|
{ |
|
|
|
productId = ""; |
|
|
|
try |
|
|
|
{ |
|
|
|
var shopId = long.Parse(shop.ShopId); |
|
|
|
List<Product> insertProductList = new List<Product>(); |
|
|
@ -52,6 +55,7 @@ namespace BBWY.Server.Business.Sync |
|
|
|
|
|
|
|
foreach (var product in productList.Items) |
|
|
|
{ |
|
|
|
productId = product.Id; |
|
|
|
var dbProduct = dbProducts.FirstOrDefault(dbp => dbp.Id == product.Id); |
|
|
|
if (dbProduct == null) |
|
|
|
{ |
|
|
@ -80,7 +84,8 @@ namespace BBWY.Server.Business.Sync |
|
|
|
Platform = shop.PlatformId, |
|
|
|
Spu = product.Id |
|
|
|
}); |
|
|
|
|
|
|
|
if (skuList == null || skuList.Count() == 0) |
|
|
|
continue; |
|
|
|
foreach (var sku in skuList) |
|
|
|
{ |
|
|
|
var dbSku = dbProductSkus.FirstOrDefault(s => s.Id == sku.Id); |
|
|
@ -120,6 +125,11 @@ namespace BBWY.Server.Business.Sync |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new Exception(productId, ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void SyncProduct(ShopResponse shop, bool IsSyncAllProduct = false) |
|
|
|
{ |
|
|
@ -139,7 +149,7 @@ namespace BBWY.Server.Business.Sync |
|
|
|
var productList = productBusiness.GetProductList(request); |
|
|
|
if (productList == null || productList.Count == 0) |
|
|
|
return; |
|
|
|
SyncProduct(shop, productList); |
|
|
|
SyncProduct(shop, productList, out string productId); |
|
|
|
if (productList.Items.Count < 50 || !IsSyncAllProduct) |
|
|
|
break; |
|
|
|
request.PageIndex++; |
|
|
@ -171,11 +181,11 @@ namespace BBWY.Server.Business.Sync |
|
|
|
public void SyncAllShopAllProduct() |
|
|
|
{ |
|
|
|
var shopList = venderBusiness.GetShopList(); |
|
|
|
//SyncProduct(shopList.FirstOrDefault(s => s.ShopId == "10388155"), true); //布莱特玩具专营店
|
|
|
|
foreach (var shop in shopList) |
|
|
|
{ |
|
|
|
Task.Factory.StartNew(() => SyncProduct(shop, true), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler); |
|
|
|
} |
|
|
|
SyncProduct(shopList.FirstOrDefault(s => s.ShopName == "瑞源玩具专营店"), true); //瑞源玩具专营店
|
|
|
|
//foreach (var shop in shopList)
|
|
|
|
//{
|
|
|
|
// Task.Factory.StartNew(() => SyncProduct(shop, true), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler);
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|