|
@ -15,6 +15,7 @@ using System.Threading.Tasks; |
|
|
using Yitter.IdGenerator; |
|
|
using Yitter.IdGenerator; |
|
|
using BBWY.Common.Extensions; |
|
|
using BBWY.Common.Extensions; |
|
|
using BBWY.Server.Model.Db; |
|
|
using BBWY.Server.Model.Db; |
|
|
|
|
|
using System.Threading; |
|
|
|
|
|
|
|
|
namespace BBWY.Server.Business.Sync |
|
|
namespace BBWY.Server.Business.Sync |
|
|
{ |
|
|
{ |
|
@ -67,8 +68,9 @@ namespace BBWY.Server.Business.Sync |
|
|
fsql.Insert(insertList).ExecuteAffrows(); |
|
|
fsql.Insert(insertList).ExecuteAffrows(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void SyncShopPopularizeRecord(ShopResponse shop, DateTime startDate, DateTime endDate) |
|
|
private void SyncShopPopularizeRecord(ShopResponse shop, DateTime startDate, DateTime endDate, int pageIndex, out int currentCount) |
|
|
{ |
|
|
{ |
|
|
|
|
|
currentCount = 0; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId); |
|
|
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId); |
|
@ -80,6 +82,7 @@ namespace BBWY.Server.Business.Sync |
|
|
EndDate = endDate, |
|
|
EndDate = endDate, |
|
|
StartDate = startDate, |
|
|
StartDate = startDate, |
|
|
Platform = shop.PlatformId, |
|
|
Platform = shop.PlatformId, |
|
|
|
|
|
PageIndex = pageIndex |
|
|
}, null, HttpMethod.Post); |
|
|
}, null, HttpMethod.Post); |
|
|
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
throw new Exception($"获取JD推广费用失败 {httpResult.Content}"); |
|
|
throw new Exception($"获取JD推广费用失败 {httpResult.Content}"); |
|
@ -89,6 +92,7 @@ namespace BBWY.Server.Business.Sync |
|
|
throw new Exception($"获取JD推广费用失败 {presponse.Msg}"); |
|
|
throw new Exception($"获取JD推广费用失败 {presponse.Msg}"); |
|
|
|
|
|
|
|
|
SyncShopPopularizeRecord(long.Parse(shop.ShopId), presponse.Data); |
|
|
SyncShopPopularizeRecord(long.Parse(shop.ShopId), presponse.Data); |
|
|
|
|
|
currentCount = presponse.Data?.Count() ?? 0; |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
@ -97,21 +101,16 @@ namespace BBWY.Server.Business.Sync |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 俺也书
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="shop"></param>
|
|
|
|
|
|
/// <param name="startDate"></param>
|
|
|
|
|
|
/// <param name="endDate"></param>
|
|
|
|
|
|
private void SyncAllShopPopularizeRecordByDate(ShopResponse shop, DateTime startDate, DateTime endDate) |
|
|
private void SyncAllShopPopularizeRecordByDate(ShopResponse shop, DateTime startDate, DateTime endDate) |
|
|
{ |
|
|
{ |
|
|
var currentDate = startDate; |
|
|
var pageIndex = 1; |
|
|
while (true) |
|
|
while (true) |
|
|
{ |
|
|
{ |
|
|
SyncShopPopularizeRecord(shop, currentDate, currentDate); |
|
|
SyncShopPopularizeRecord(shop, startDate, endDate, pageIndex, out int count); |
|
|
currentDate = currentDate.AddDays(1); |
|
|
if (count < 100) |
|
|
if (currentDate > endDate) |
|
|
|
|
|
break; |
|
|
break; |
|
|
|
|
|
pageIndex++; |
|
|
|
|
|
Thread.Sleep(3000); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -128,7 +127,7 @@ namespace BBWY.Server.Business.Sync |
|
|
DeleteOldData(shopList, date, date); |
|
|
DeleteOldData(shopList, date, date); |
|
|
foreach (var shop in shopList) |
|
|
foreach (var shop in shopList) |
|
|
{ |
|
|
{ |
|
|
Task.Factory.StartNew(() => SyncShopPopularizeRecord(shop, date, date), |
|
|
Task.Factory.StartNew(() => SyncShopPopularizeRecord(shop, date, date, 1, out _), |
|
|
System.Threading.CancellationToken.None, |
|
|
System.Threading.CancellationToken.None, |
|
|
TaskCreationOptions.LongRunning, |
|
|
TaskCreationOptions.LongRunning, |
|
|
taskSchedulerManager.JDPopularizeTaskScheduler); |
|
|
taskSchedulerManager.JDPopularizeTaskScheduler); |
|
@ -149,7 +148,5 @@ namespace BBWY.Server.Business.Sync |
|
|
taskSchedulerManager.JDPopularizeTaskScheduler); |
|
|
taskSchedulerManager.JDPopularizeTaskScheduler); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|