|
|
@ -29,6 +29,7 @@ namespace BBWY.Server.Business |
|
|
|
private IIdGenerator idGenerator; |
|
|
|
private TaskSchedulerManager taskSchedulerManager; |
|
|
|
private MDSBusiness mdsBusiness; |
|
|
|
private VenderBusiness venderBusiness; |
|
|
|
private Lazy<FreeSqlMultiDBManager> freeSqlMultiDBManagerLazy; |
|
|
|
private FreeSqlMultiDBManager freeSqlMultiDBManager => freeSqlMultiDBManagerLazy.Value; |
|
|
|
|
|
|
@ -39,6 +40,7 @@ namespace BBWY.Server.Business |
|
|
|
IOptions<GlobalConfig> options, |
|
|
|
TaskSchedulerManager taskSchedulerManager, |
|
|
|
MDSBusiness mdsBusiness, |
|
|
|
VenderBusiness venderBusiness, |
|
|
|
IServiceProvider serviceProvider) : base(restApiService, options) |
|
|
|
{ |
|
|
|
this.logger = logger; |
|
|
@ -50,6 +52,7 @@ namespace BBWY.Server.Business |
|
|
|
{ Enums.Platform.京东, SyncJDOrder } |
|
|
|
}; |
|
|
|
this.mdsBusiness = mdsBusiness; |
|
|
|
this.venderBusiness = venderBusiness; |
|
|
|
freeSqlMultiDBManagerLazy = new Lazy<FreeSqlMultiDBManager>(() => serviceProvider.GetService<FreeSqlMultiDBManager>()); |
|
|
|
} |
|
|
|
|
|
|
@ -982,11 +985,17 @@ namespace BBWY.Server.Business |
|
|
|
public void SyncOrder(long shopId, string orderId, DateTime? startTime = null, DateTime? endTime = null) |
|
|
|
{ |
|
|
|
var shop = mdsBusiness.GetShopInfoByShopId(shopId); |
|
|
|
SyncOrder(shop, orderId, startTime, endTime); |
|
|
|
} |
|
|
|
|
|
|
|
private void SyncOrder(ShopResponse shop, string orderId, DateTime? startTime = null, DateTime? endTime = null, bool isAuto = false) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
logger.Info($"订单同步 {shop.ShopName} isAuto {isAuto}"); |
|
|
|
if (!syncOrderMethodDic.ContainsKey(shop.PlatformId)) |
|
|
|
throw new Exception("不支持的平台"); |
|
|
|
|
|
|
|
var shopId = long.Parse(shop.ShopId); |
|
|
|
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId); |
|
|
|
var orderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetOrderList", new SearchPlatformOrderRequest() |
|
|
|
{ |
|
|
@ -999,7 +1008,7 @@ namespace BBWY.Server.Business |
|
|
|
PageSize = 100, |
|
|
|
Platform = shop.PlatformId, |
|
|
|
JDColType = string.IsNullOrEmpty(shop.ShopType) ? "0" : shop.ShopType, |
|
|
|
SaveResponseLog = true, |
|
|
|
//SaveResponseLog = true,
|
|
|
|
OrderId = orderId |
|
|
|
}, null, HttpMethod.Post); |
|
|
|
if (orderListApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
@ -1511,5 +1520,17 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 同步所有店铺的订单
|
|
|
|
/// </summary>
|
|
|
|
public void SyncAllShopOrder() |
|
|
|
{ |
|
|
|
var shopList = venderBusiness.GetShopList(); |
|
|
|
foreach (var shop in shopList) |
|
|
|
{ |
|
|
|
Task.Factory.StartNew(() => SyncOrder(shop, string.Empty, isAuto: true), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|