|
|
|
|
|
|
|
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 System.Collections.Generic;
|
|
|
|
using System.Net.Http;
|
|
|
|
|
|
|
|
namespace BBWY.Server.Business
|
|
|
|
{
|
|
|
|
public class VenderBusiness : BasePlatformRelayBusiness, IDenpendency
|
|
|
|
{
|
|
|
|
public VenderBusiness(RestApiService restApiService, IOptions<GlobalConfig> options) : base(restApiService, options)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public VenderResponse GetVenderInfo(PlatformRequest platformRequest)
|
|
|
|
{
|
|
|
|
var relayAPIHost = GetPlatformRelayAPIHost(platformRequest.Platform);
|
|
|
|
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetVenderInfo", platformRequest, null, System.Net.Http.HttpMethod.Post);
|
|
|
|
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
|
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse<VenderResponse>>(sendResult.Content);
|
|
|
|
if (!response.Success)
|
|
|
|
throw new BusinessException(response.Msg) { Code = response.Code };
|
|
|
|
return response.Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IList<LogisticsResponse> GetLogisticsList(PlatformRequest platformRequest)
|
|
|
|
{
|
|
|
|
var relayAPIHost = GetPlatformRelayAPIHost(platformRequest.Platform);
|
|
|
|
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetLogisticsList", platformRequest, null, System.Net.Http.HttpMethod.Post);
|
|
|
|
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
|
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse<IList<LogisticsResponse>>>(sendResult.Content);
|
|
|
|
if (!response.Success)
|
|
|
|
throw new BusinessException(response.Msg) { Code = response.Code };
|
|
|
|
return response.Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void AcceptJDShopToken(JDShopToken jDShopToken)
|
|
|
|
{
|
|
|
|
var venderResponse = GetVenderInfo(new PlatformRequest()
|
|
|
|
{
|
|
|
|
AppKey = "120EA9EC65AB017567D78CC1139EEEA5",
|
|
|
|
AppSecret = "866a9877f5f24b03b537483b4defe75d",
|
|
|
|
AppToken = jDShopToken.Access_Token,
|
|
|
|
Platform = Enums.Platform.京东
|
|
|
|
});
|
|
|
|
|
|
|
|
restApiService.SendRequest(globalConfig.MdsApi, "/TaskList/Shop/UpdateShop", new
|
|
|
|
{
|
|
|
|
venderResponse.ShopName,
|
|
|
|
venderResponse.ShopId,
|
|
|
|
ShopType = venderResponse.ColType,
|
|
|
|
AppToken = jDShopToken.Access_Token
|
|
|
|
}, new Dictionary<string, string>() { { "qy", "qy" } }, HttpMethod.Post);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|