shanji 2 years ago
parent
commit
609b50b8b4
  1. 20
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  2. 5
      BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
  3. 58
      BBWY.Server.Business/Sync/JD/JDServiceOrderSyncBusiness.cs
  4. 3
      BBWY.Server.Business/TaskSchedulerManager.cs
  5. 11
      JD.API/Controllers/PlatformSDKController.cs

20
BBWY.Server.Business/PlatformSDK/JDBusiness.cs

@ -1399,5 +1399,25 @@ namespace BBWY.Server.Business
return res.Json["jingdong_asc_query_view_responce"]["result"]["data"];
}
public override JToken GetServiceOrderDeliveryDetail(QueryServiceOrderDetailRequest request)
{
var jdClient = GetJdClient(request.AppKey, request.AppSecret);
var req = new AscFreightViewRequest();
req.buId = request.VenderId;
req.operatePin = "开发测试";
req.operateNick = "开发测试";
req.serviceId = int.Parse(request.ServiceId);
req.orderId = long.Parse(request.OrderId);
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (res.IsError)
throw new BusinessException($"查询服务单运单失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
if (res.Json == null)
res.Json = JsonConvert.DeserializeObject<JObject>(res.Body);
return res.Json["jingdong_asc_freight_view_responce"]["result"]["data"];
}
}
}

5
BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs

@ -197,5 +197,10 @@ namespace BBWY.Server.Business
{
throw new NotImplementedException();
}
public virtual JToken GetServiceOrderDeliveryDetail(QueryServiceOrderDetailRequest request)
{
throw new NotImplementedException();
}
}
}

58
BBWY.Server.Business/Sync/JD/JDServiceOrderSyncBusiness.cs

@ -18,11 +18,17 @@ namespace BBWY.Server.Business.Sync
{
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)
{
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.);
//SyncAfterOrder(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), string.Empty, isAuto: true);
@ -31,8 +37,17 @@ namespace BBWY.Server.Business.Sync
Task.Factory.StartNew(() => SyncServiceOrder(shop, string.Empty, isAuto: true),
System.Threading.CancellationToken.None,
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)
@ -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,13 +198,14 @@ namespace BBWY.Server.Business.Sync
PageSize = 50,
Platform = shop.PlatformId,
SaveResponseLog = true,
OrderId = orderId,
ServiceId = serviceId,
VenderId = shop.VenderId
};
List<JToken> jtokenList = new List<JToken>();
foreach (var serviceStatus in serviceStatusList)
{
if (string.IsNullOrEmpty(serviceId))
request.ServiceStatus = serviceStatus;
var serviceOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderList", request, GetYunDingRequestHeader(), HttpMethod.Post);
if (serviceOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
@ -198,6 +214,8 @@ namespace BBWY.Server.Business.Sync
if (!serviceOrderListResponse.Success)
throw new Exception($"获取服务单失败 {serviceOrderListResponse.Msg}");
jtokenList.AddRange(serviceOrderListResponse.Data);
if (!string.IsNullOrEmpty(serviceId))
break;
}
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}");
}
}
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
}
}
}
}
}

3
BBWY.Server.Business/TaskSchedulerManager.cs

@ -12,6 +12,8 @@ namespace BBWY.Server.Business
public LimitedConcurrencyLevelTaskScheduler SyncAfterOrderTaskScheduler { get; private set; }
public LimitedConcurrencyLevelTaskScheduler SyncServiceOrderTaskScheduler { get; private set; }
public LimitedConcurrencyLevelTaskScheduler PurchaseOrderCallbackTaskScheduler { get; private set; }
public LimitedConcurrencyLevelTaskScheduler JDPopularizeTaskScheduler { get; private set; }
@ -33,6 +35,7 @@ namespace BBWY.Server.Business
SyncOrderTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
SyncRefundOrderTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
SyncAfterOrderTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
SyncServiceOrderTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
PurchaseOrderCallbackTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
ProductSyncTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(2);
JDPopularizeTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);

11
JD.API/Controllers/PlatformSDKController.cs

@ -355,5 +355,16 @@ namespace JD.API.API.Controllers
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetServiceOrderDetail(request);
}
/// <summary>
/// 查询服务单运单详情
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public JToken GetServiceOrderDeliveryDetail(QueryServiceOrderDetailRequest request)
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetServiceOrderDeliveryDetail(request);
}
}
}

Loading…
Cancel
Save