|
@ -18,11 +18,17 @@ namespace BBWY.Server.Business.Sync |
|
|
{ |
|
|
{ |
|
|
public class JDServiceOrderSyncBusiness : BaseSyncBusiness, IDenpendency |
|
|
public class JDServiceOrderSyncBusiness : BaseSyncBusiness, IDenpendency |
|
|
{ |
|
|
{ |
|
|
|
|
|
private IList<LogisticsCompanyRelationship> jd_kd100_logisticsCompanyDictionary; |
|
|
|
|
|
|
|
|
public JDServiceOrderSyncBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService, options, nLogManager, fsql, idGenerator, taskSchedulerManager, venderBusiness, yunDingBusiness) |
|
|
public JDServiceOrderSyncBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService, options, nLogManager, fsql, idGenerator, taskSchedulerManager, venderBusiness, yunDingBusiness) |
|
|
{ |
|
|
{ |
|
|
|
|
|
jd_kd100_logisticsCompanyDictionary = new List<LogisticsCompanyRelationship>() |
|
|
|
|
|
{ |
|
|
|
|
|
new LogisticsCompanyRelationship(){ SourceName="<JD>",TargetName="<Kuaii100>",SecondTargetName="<kuaidi100 2>" } |
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void SyncAllShopServiceOrder() |
|
|
public void SyncServiceOrder() |
|
|
{ |
|
|
{ |
|
|
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.京东); |
|
|
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.京东); |
|
|
//SyncAfterOrder(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), string.Empty, isAuto: true);
|
|
|
//SyncAfterOrder(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), string.Empty, isAuto: true);
|
|
@ -31,10 +37,19 @@ namespace BBWY.Server.Business.Sync |
|
|
Task.Factory.StartNew(() => SyncServiceOrder(shop, string.Empty, isAuto: true), |
|
|
Task.Factory.StartNew(() => SyncServiceOrder(shop, string.Empty, isAuto: true), |
|
|
System.Threading.CancellationToken.None, |
|
|
System.Threading.CancellationToken.None, |
|
|
TaskCreationOptions.LongRunning, |
|
|
TaskCreationOptions.LongRunning, |
|
|
taskSchedulerManager.SyncAfterOrderTaskScheduler); |
|
|
taskSchedulerManager.SyncServiceOrderTaskScheduler); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void SyncServiceOrder(long shopId, string serviceId) |
|
|
|
|
|
{ |
|
|
|
|
|
var shopList = venderBusiness.GetShopList(shopId); |
|
|
|
|
|
Task.Factory.StartNew(() => SyncServiceOrder(shopList[0], serviceId, isAuto: true), |
|
|
|
|
|
System.Threading.CancellationToken.None, |
|
|
|
|
|
TaskCreationOptions.LongRunning, |
|
|
|
|
|
taskSchedulerManager.SyncServiceOrderTaskScheduler); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void SyncServiceOrder(ShopResponse shop, long shopId, IList<JToken> jtokenList, string relayAPIHost, string appKey, string appSecret, string token) |
|
|
private void SyncServiceOrder(ShopResponse shop, long shopId, IList<JToken> jtokenList, string relayAPIHost, string appKey, string appSecret, string token) |
|
|
{ |
|
|
{ |
|
|
var serviceIdList = jtokenList.Select(j => j.Value<string>("serviceId")).ToList(); |
|
|
var serviceIdList = jtokenList.Select(j => j.Value<string>("serviceId")).ToList(); |
|
@ -145,7 +160,7 @@ namespace BBWY.Server.Business.Sync |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void SyncServiceOrder(ShopResponse shop, string orderId, DateTime? startTime = null, DateTime? endTime = null, bool isAuto = false) |
|
|
private void SyncServiceOrder(ShopResponse shop, string serviceId, DateTime? startTime = null, DateTime? endTime = null, bool isAuto = false) |
|
|
{ |
|
|
{ |
|
|
/* |
|
|
/* |
|
|
审核阶段: |
|
|
审核阶段: |
|
@ -183,14 +198,15 @@ namespace BBWY.Server.Business.Sync |
|
|
PageSize = 50, |
|
|
PageSize = 50, |
|
|
Platform = shop.PlatformId, |
|
|
Platform = shop.PlatformId, |
|
|
SaveResponseLog = true, |
|
|
SaveResponseLog = true, |
|
|
OrderId = orderId, |
|
|
ServiceId = serviceId, |
|
|
VenderId = shop.VenderId |
|
|
VenderId = shop.VenderId |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
List<JToken> jtokenList = new List<JToken>(); |
|
|
List<JToken> jtokenList = new List<JToken>(); |
|
|
foreach (var serviceStatus in serviceStatusList) |
|
|
foreach (var serviceStatus in serviceStatusList) |
|
|
{ |
|
|
{ |
|
|
request.ServiceStatus = serviceStatus; |
|
|
if (string.IsNullOrEmpty(serviceId)) |
|
|
|
|
|
request.ServiceStatus = serviceStatus; |
|
|
var serviceOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderList", request, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
var serviceOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderList", request, GetYunDingRequestHeader(), HttpMethod.Post); |
|
|
if (serviceOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
if (serviceOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
throw new Exception($"获取服务单失败 {serviceOrderListApiResult.Content}"); |
|
|
throw new Exception($"获取服务单失败 {serviceOrderListApiResult.Content}"); |
|
@ -198,6 +214,8 @@ namespace BBWY.Server.Business.Sync |
|
|
if (!serviceOrderListResponse.Success) |
|
|
if (!serviceOrderListResponse.Success) |
|
|
throw new Exception($"获取服务单失败 {serviceOrderListResponse.Msg}"); |
|
|
throw new Exception($"获取服务单失败 {serviceOrderListResponse.Msg}"); |
|
|
jtokenList.AddRange(serviceOrderListResponse.Data); |
|
|
jtokenList.AddRange(serviceOrderListResponse.Data); |
|
|
|
|
|
if (!string.IsNullOrEmpty(serviceId)) |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
SyncServiceOrder(shop, shopId, jtokenList, relayAPIHost, request.AppKey, request.AppSecret, request.AppToken); |
|
|
SyncServiceOrder(shop, shopId, jtokenList, relayAPIHost, request.AppKey, request.AppSecret, request.AppToken); |
|
@ -207,5 +225,37 @@ namespace BBWY.Server.Business.Sync |
|
|
nLogManager.GetLogger(loggerName).Error(ex, $"SyncServiceOrder ShopName:{shop.ShopName} ShopId:{shop.ShopId}"); |
|
|
nLogManager.GetLogger(loggerName).Error(ex, $"SyncServiceOrder ShopName:{shop.ShopName} ShopId:{shop.ShopId}"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void SubscribeKuaiDi100() |
|
|
|
|
|
{ |
|
|
|
|
|
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.京东); |
|
|
|
|
|
foreach (var shop in shopList) |
|
|
|
|
|
{ |
|
|
|
|
|
Task.Factory.StartNew(() => SyncServiceOrder(shop, string.Empty, isAuto: true), |
|
|
|
|
|
System.Threading.CancellationToken.None, |
|
|
|
|
|
TaskCreationOptions.LongRunning, |
|
|
|
|
|
taskSchedulerManager.SyncServiceOrderTaskScheduler); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void SubscribeKuaiDi100(ShopResponse shop) |
|
|
|
|
|
{ |
|
|
|
|
|
var serviceOrderList = fsql.Select<ServiceOrder>().Where(s => s.ShopId == shop.Id && |
|
|
|
|
|
s.IsNeedSubscribeKuaiDi100 == true && |
|
|
|
|
|
s.IsSubscribeKuaiDi100 == false) |
|
|
|
|
|
.Page(1, 50) |
|
|
|
|
|
.ToList(); |
|
|
|
|
|
foreach (var serviceOrder in serviceOrderList) |
|
|
|
|
|
{ |
|
|
|
|
|
if (string.IsNullOrEmpty(serviceOrder.WaybillNo) || string.IsNullOrEmpty(serviceOrder.ExpressName)) |
|
|
|
|
|
{ |
|
|
|
|
|
#region 查询服务单运单详情
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|