|
|
@ -37,24 +37,9 @@ namespace BBWY.Server.Business.Sync |
|
|
|
this.productBusiness = productBusiness; |
|
|
|
} |
|
|
|
|
|
|
|
private void SyncProduct(ShopResponse shop) |
|
|
|
{ |
|
|
|
try |
|
|
|
private void SyncProduct(ShopResponse shop, ProductListResponse productList) |
|
|
|
{ |
|
|
|
var shopId = long.Parse(shop.ShopId); |
|
|
|
var productList = productBusiness.GetProductList(new SearchProductRequest() |
|
|
|
{ |
|
|
|
PageSize = 50, |
|
|
|
PageIndex = 1, |
|
|
|
AppKey = shop.AppKey, |
|
|
|
AppSecret = shop.AppSecret, |
|
|
|
AppToken = shop.AppToken, |
|
|
|
Platform = shop.PlatformId |
|
|
|
}); |
|
|
|
|
|
|
|
if (productList == null || productList.Count == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
List<Product> insertProductList = new List<Product>(); |
|
|
|
List<IUpdate<Product>> updateProductList = new List<IUpdate<Product>>(); |
|
|
|
|
|
|
@ -135,6 +120,31 @@ namespace BBWY.Server.Business.Sync |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void SyncProduct(ShopResponse shop, bool IsSyncAllProduct = false) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
var request = new SearchProductRequest() |
|
|
|
{ |
|
|
|
PageSize = 50, |
|
|
|
PageIndex = 1, |
|
|
|
AppKey = shop.AppKey, |
|
|
|
AppSecret = shop.AppSecret, |
|
|
|
AppToken = shop.AppToken, |
|
|
|
Platform = shop.PlatformId |
|
|
|
}; |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
var productList = productBusiness.GetProductList(request); |
|
|
|
if (productList == null || productList.Count == 0) |
|
|
|
return; |
|
|
|
SyncProduct(shop, productList); |
|
|
|
if (productList.Items.Count < 50 || !IsSyncAllProduct) |
|
|
|
break; |
|
|
|
request.PageIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
var shopData = JsonConvert.SerializeObject(shop); |
|
|
@ -143,17 +153,30 @@ namespace BBWY.Server.Business.Sync |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 同步所有店铺的订单
|
|
|
|
/// 同步所有店铺的前50个产品
|
|
|
|
/// </summary>
|
|
|
|
public void SyncAllShopProduct() |
|
|
|
{ |
|
|
|
var shopList = venderBusiness.GetShopList(); |
|
|
|
//SyncProduct(shopList[0]);
|
|
|
|
//SyncProduct(shopList.FirstOrDefault(s => s.ShopId == "10388155"), true); //布莱特玩具专营店
|
|
|
|
foreach (var shop in shopList) |
|
|
|
{ |
|
|
|
Task.Factory.StartNew(() => SyncProduct(shop), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 同步所有店铺的全部产品
|
|
|
|
/// </summary>
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|