|
|
|
using BBWY.Common.Http;
|
|
|
|
using BBWY.Common.Models;
|
|
|
|
using BBWY.Server.Model;
|
|
|
|
using BBWY.Server.Model.Dto;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Net.Http;
|
|
|
|
|
|
|
|
namespace BBWY.Server.Business
|
|
|
|
{
|
|
|
|
public class ProductBusiness : BasePlatformRelayBusiness, IDenpendency
|
|
|
|
{
|
|
|
|
public ProductBusiness(RestApiService restApiService, IConfiguration configuration, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness) : base(restApiService, options, yunDingBusiness)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public ProductListResponse GetProductList(SearchProductRequest searchProductRequest)
|
|
|
|
{
|
|
|
|
var relayAPIHost = GetPlatformRelayAPIHost(searchProductRequest.Platform);
|
|
|
|
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductList", searchProductRequest, GetYunDingRequestHeader(), HttpMethod.Post);
|
|
|
|
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
|
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(sendResult.Content);
|
|
|
|
if (!response.Success)
|
|
|
|
throw new BusinessException(response.Msg) { Code = response.Code };
|
|
|
|
return response.Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IList<ProductSkuResponse> GetProductSkuList(SearchProductSkuRequest searchProductSkuRequest)
|
|
|
|
{
|
|
|
|
var relayAPIHost = GetPlatformRelayAPIHost(searchProductSkuRequest.Platform);
|
|
|
|
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductSkuList", searchProductSkuRequest, GetYunDingRequestHeader(), HttpMethod.Post);
|
|
|
|
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
|
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(sendResult.Content);
|
|
|
|
if (!response.Success)
|
|
|
|
throw new BusinessException(response.Msg) { Code = response.Code };
|
|
|
|
return response.Data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|