1 changed files with 97 additions and 0 deletions
@ -0,0 +1,97 @@ |
|||||
|
using BBWY.Common.Http; |
||||
|
using BBWY.Common.Models; |
||||
|
using BBWY.Server.Model; |
||||
|
using BBWY.Server.Model.Dto; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Newtonsoft.Json; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using System; |
||||
|
using System.Net.Http; |
||||
|
using System.Threading.Tasks; |
||||
|
using Yitter.IdGenerator; |
||||
|
|
||||
|
namespace BBWY.Server.Business.Sync |
||||
|
{ |
||||
|
public class JDServiceOrderSyncBusiness : BaseSyncBusiness, IDenpendency |
||||
|
{ |
||||
|
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 void SyncAllShopServiceOrder() |
||||
|
{ |
||||
|
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.京东); |
||||
|
//SyncAfterOrder(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), string.Empty, isAuto: true);
|
||||
|
foreach (var shop in shopList) |
||||
|
{ |
||||
|
Task.Factory.StartNew(() => SyncServiceOrder(shop, string.Empty, isAuto: true), |
||||
|
System.Threading.CancellationToken.None, |
||||
|
TaskCreationOptions.LongRunning, |
||||
|
taskSchedulerManager.SyncAfterOrderTaskScheduler); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void SyncServiceOrder(ShopResponse shop, JArray jArray) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void SyncServiceOrder(ShopResponse shop, string orderId, DateTime? startTime = null, DateTime? endTime = null, bool isAuto = false) |
||||
|
{ |
||||
|
/* |
||||
|
审核阶段: |
||||
|
待审核: 10001 |
||||
|
待用户反馈: 10002 |
||||
|
用户已反馈: 10012 |
||||
|
【待收货: 10005】 |
||||
|
【取消: 10011】 |
||||
|
审核关闭: 10004 |
||||
|
待用户确认: 10009 |
||||
|
【完成: 10010】 |
||||
|
处理阶段: |
||||
|
已收货,待处理 : 10007 |
||||
|
原返取消,待处理:7060 |
||||
|
换新取消,待处理:7023 |
||||
|
线下换新取消,待处理:7090 |
||||
|
商家催收: 13000 |
||||
|
*/ |
||||
|
try |
||||
|
{ |
||||
|
var shopId = long.Parse(shop.ShopId); |
||||
|
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId); |
||||
|
|
||||
|
var _10005ServiceOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderList", new QueryServiceOrderRequest() |
||||
|
{ |
||||
|
UpdateTimeBegin = startTime ?? DateTime.Now.Date.AddDays(-3), |
||||
|
UpdateTimeEnd = endTime ?? DateTime.Now, |
||||
|
AppKey = shop.AppKey, |
||||
|
AppSecret = shop.AppSecret, |
||||
|
AppToken = shop.AppToken, |
||||
|
PageIndex = 1, |
||||
|
PageSize = 50, |
||||
|
Platform = shop.PlatformId, |
||||
|
SaveResponseLog = true, |
||||
|
OrderId = orderId, |
||||
|
VenderId = shop.VenderId, |
||||
|
ServiceStatus = 10005 |
||||
|
}, GetYunDingRequestHeader(), HttpMethod.Post); |
||||
|
|
||||
|
if (_10005ServiceOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
||||
|
throw new Exception($"获取服务单失败 {_10005ServiceOrderListApiResult.Content}"); |
||||
|
|
||||
|
var serviceOrderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(_10005ServiceOrderListApiResult.Content); |
||||
|
if (!serviceOrderListResponse.Success) |
||||
|
throw new Exception($"获取服务单失败 {serviceOrderListResponse.Msg}"); |
||||
|
|
||||
|
|
||||
|
|
||||
|
//SyncServiceOrder(shop, serviceOrderListResponse.Data);
|
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
var shopData = JsonConvert.SerializeObject(shop); |
||||
|
nLogManager.Default().Error(ex, $"SyncServiceOrder ShopData:{shopData}"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue