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.
63 lines
3.3 KiB
63 lines
3.3 KiB
using BBWY.Common.Http;
|
|
using BBWY.Common.Models;
|
|
using BBWY.Server.Model;
|
|
using BBWY.Server.Model.Db;
|
|
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
|
|
{
|
|
private IFreeSql fsql;
|
|
public ProductBusiness(RestApiService restApiService, IConfiguration configuration, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql) : base(restApiService, options, yunDingBusiness)
|
|
{
|
|
this.fsql = fsql;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public IList<ProductSkuResponse> GetProductSkuListFromLocal(SearchProductSkuFromLocalRequest request)
|
|
{
|
|
return fsql.Select<ProductSku>(request.SkuList).Where(ps => ps.ShopId == request.ShopId).ToList<ProductSkuResponse>();
|
|
}
|
|
|
|
public ProductCategoryResponse GetCategoyrInfo(JDQueryCategoryRequest request)
|
|
{
|
|
var relayAPIHost = GetPlatformRelayAPIHost(request.Platform);
|
|
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetCategoryInfo", request, GetYunDingRequestHeader(), HttpMethod.Post);
|
|
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
|
|
var response = JsonConvert.DeserializeObject<ApiResponse<ProductCategoryResponse>>(sendResult.Content);
|
|
if (!response.Success)
|
|
throw new BusinessException(response.Msg) { Code = response.Code };
|
|
return response.Data;
|
|
}
|
|
}
|
|
}
|
|
|