You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.2 KiB
85 lines
3.2 KiB
using BBWY._1688SDK.entity.OrderPreview;
|
|
using BBWY.Server.Model;
|
|
using BBWY.Server.Model.Dto;
|
|
using com.alibaba.openapi.client;
|
|
using com.alibaba.openapi.client.policy;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using Newtonsoft.Json.Linq;
|
|
using NLog;
|
|
using System.Collections.Generic;
|
|
|
|
namespace BBWY.Server.Business
|
|
{
|
|
public class _1688Business : PlatformSDKBusiness
|
|
{
|
|
public override Enums.Platform Platform => Enums.Platform.阿里巴巴;
|
|
|
|
public _1688Business(IMemoryCache memoryCache, ILogger logger) : base(memoryCache, logger)
|
|
{
|
|
|
|
}
|
|
|
|
private SyncAPIClient GetSyncAPIClient(string appKey, string appSecret)
|
|
{
|
|
if (!memoryCache.TryGetValue(appKey, out SyncAPIClient syncAPIClient))
|
|
{
|
|
syncAPIClient = new SyncAPIClient(appKey, appSecret);
|
|
memoryCache.Set(appKey, syncAPIClient, expirationTimeSpan);
|
|
}
|
|
return syncAPIClient;
|
|
}
|
|
|
|
public override PreviewOrderResponse PreviewOrder(PreviewOrderReuqest previewOrderReuqest)
|
|
{
|
|
var client = GetSyncAPIClient(previewOrderReuqest.AppKey, previewOrderReuqest.AppSecret);
|
|
RequestPolicy reqPolicy = new RequestPolicy();
|
|
reqPolicy.HttpMethod = "POST";
|
|
reqPolicy.NeedAuthorization = false;
|
|
reqPolicy.RequestSendTimestamp = true;
|
|
reqPolicy.UseHttps = false;
|
|
reqPolicy.UseSignture = true;
|
|
reqPolicy.AccessPrivateApi = false;
|
|
|
|
Request request = new Request();
|
|
APIId apiId = new APIId();
|
|
apiId.Name = "alibaba.createOrder.preview";
|
|
apiId.NamespaceValue = "com.alibaba.trade";
|
|
apiId.Version = 1;
|
|
request.ApiId = apiId;
|
|
|
|
var param = new CreateOrderPreview()
|
|
{
|
|
addressParam = new AddressParam()
|
|
{
|
|
fullName = previewOrderReuqest.ConsigneeRequest.ContactName,
|
|
mobile = previewOrderReuqest.ConsigneeRequest.Mobile,
|
|
phone = previewOrderReuqest.ConsigneeRequest.TelePhone,
|
|
postCode = "000000",
|
|
address = previewOrderReuqest.ConsigneeRequest.Address,
|
|
provinceText = previewOrderReuqest.ConsigneeRequest.Province,
|
|
cityText = previewOrderReuqest.ConsigneeRequest.City,
|
|
areaText = previewOrderReuqest.ConsigneeRequest.County,
|
|
townText = previewOrderReuqest.ConsigneeRequest.Town
|
|
},
|
|
cargoParamList = new List<CargoParam>(),
|
|
flow = "general"
|
|
};
|
|
foreach (var cargo in previewOrderReuqest.CargoParamList)
|
|
{
|
|
param.cargoParamList.Add(new CargoParam()
|
|
{
|
|
offerId = long.Parse(cargo.SkuId),
|
|
specId = cargo.SpecId,
|
|
quantity = cargo.Quantity
|
|
});
|
|
}
|
|
request.RequestEntity = param;
|
|
var result = client.send<JObject>(request, reqPolicy);
|
|
|
|
return new PreviewOrderResponse()
|
|
{
|
|
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|