|
@ -1,4 +1,6 @@ |
|
|
using BBWY._1688SDK.entity.OrderPreview; |
|
|
using BBWY._1688SDK.entity.OrderPreview; |
|
|
|
|
|
using BBWY.Common.Http; |
|
|
|
|
|
using BBWY.Common.Models; |
|
|
using BBWY.Server.Model; |
|
|
using BBWY.Server.Model; |
|
|
using BBWY.Server.Model.Dto; |
|
|
using BBWY.Server.Model.Dto; |
|
|
using com.alibaba.openapi.client; |
|
|
using com.alibaba.openapi.client; |
|
@ -13,17 +15,18 @@ namespace BBWY.Server.Business |
|
|
public class _1688Business : PlatformSDKBusiness |
|
|
public class _1688Business : PlatformSDKBusiness |
|
|
{ |
|
|
{ |
|
|
public override Enums.Platform Platform => Enums.Platform.阿里巴巴; |
|
|
public override Enums.Platform Platform => Enums.Platform.阿里巴巴; |
|
|
|
|
|
private RestApiService restApiService; |
|
|
|
|
|
|
|
|
public _1688Business(IMemoryCache memoryCache, ILogger logger) : base(memoryCache, logger) |
|
|
public _1688Business(IMemoryCache memoryCache, ILogger logger, RestApiService restApiService) : base(memoryCache, logger) |
|
|
{ |
|
|
{ |
|
|
|
|
|
this.restApiService = restApiService; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private SyncAPIClient GetSyncAPIClient(string appKey, string appSecret) |
|
|
private SyncAPIClient GetSyncAPIClient(string appKey, string appSecret) |
|
|
{ |
|
|
{ |
|
|
if (!memoryCache.TryGetValue(appKey, out SyncAPIClient syncAPIClient)) |
|
|
if (!memoryCache.TryGetValue(appKey, out SyncAPIClient syncAPIClient)) |
|
|
{ |
|
|
{ |
|
|
syncAPIClient = new SyncAPIClient(appKey, appSecret); |
|
|
syncAPIClient = new SyncAPIClient(appKey, appSecret, restApiService); |
|
|
memoryCache.Set(appKey, syncAPIClient, expirationTimeSpan); |
|
|
memoryCache.Set(appKey, syncAPIClient, expirationTimeSpan); |
|
|
} |
|
|
} |
|
|
return syncAPIClient; |
|
|
return syncAPIClient; |
|
@ -35,7 +38,7 @@ namespace BBWY.Server.Business |
|
|
RequestPolicy reqPolicy = new RequestPolicy(); |
|
|
RequestPolicy reqPolicy = new RequestPolicy(); |
|
|
reqPolicy.HttpMethod = "POST"; |
|
|
reqPolicy.HttpMethod = "POST"; |
|
|
reqPolicy.NeedAuthorization = false; |
|
|
reqPolicy.NeedAuthorization = false; |
|
|
reqPolicy.RequestSendTimestamp = true; |
|
|
reqPolicy.RequestSendTimestamp = false; |
|
|
reqPolicy.UseHttps = false; |
|
|
reqPolicy.UseHttps = false; |
|
|
reqPolicy.UseSignture = true; |
|
|
reqPolicy.UseSignture = true; |
|
|
reqPolicy.AccessPrivateApi = false; |
|
|
reqPolicy.AccessPrivateApi = false; |
|
@ -74,7 +77,13 @@ namespace BBWY.Server.Business |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
request.RequestEntity = param; |
|
|
request.RequestEntity = param; |
|
|
var result = client.send<JObject>(request, reqPolicy); |
|
|
if (!string.IsNullOrEmpty(previewOrderReuqest.AppToken)) |
|
|
|
|
|
request.AccessToken = previewOrderReuqest.AppToken; |
|
|
|
|
|
var result = client.NewRequest(request, reqPolicy); |
|
|
|
|
|
if (result.Value<bool>("success") != true) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new BusinessException(result.Value<string>("errorMsg")) { Code = result.Value<int>("errorCode") }; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return new PreviewOrderResponse() |
|
|
return new PreviewOrderResponse() |
|
|
{ |
|
|
{ |
|
|