using AlibabaSDK.Api;
|
using AlibabaSDK.Request;
|
using Operater.DTO.System;
|
using CommonUtil;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using AlibabaSDK.Domain;
|
|
namespace Operater.Service.System
|
{
|
public class ProductManageService : IProductManageService
|
{
|
/// <summary>
|
/// 获取1688商品详情
|
/// </summary>
|
/// <param name="request"></param>
|
/// <returns></returns>
|
public GetAliProductInfoResponse GetAliProductInfo(CompareChangeRequest request)
|
{
|
GetAliProductInfoResponse rsp= new GetAliProductInfoResponse()
|
{
|
Success = false
|
};
|
if (request.ProSource == 0)
|
{//精选
|
List<string> ls = new List<string>();
|
ls.Add(request.AliProductId.ToString());
|
PFTProductDetailRequest jxrequest = new PFTProductDetailRequest()
|
{
|
offerIds = ls
|
};
|
var response = AliabaClient.Execute(jxrequest, request.AliToken);
|
if (response.IsNull() || !response.result.success || response.result.result.Count == 0)
|
{//获取商品详情失败
|
rsp.Error = $"获取精选商品详情错误:" + response.result.message;
|
return rsp;
|
}
|
rsp.Success = true;
|
rsp.JXProduct = response.result.result[0].productInfo;
|
return rsp;
|
}
|
else
|
{//代发
|
FenXiaoProductInfoGetRequest dfrequest = new FenXiaoProductInfoGetRequest()
|
{
|
offerId = request.AliProductId
|
};
|
var dfresponse = AliabaClient.Execute(dfrequest, request.AliToken);
|
if (dfresponse.IsNull() || !dfresponse.Success)
|
{//获取商品详情失败
|
rsp.Error = $"获取代发商品详情错误:" + dfresponse.ErrorMsg;
|
return rsp;
|
}
|
List<SkuInfosItem> res = JSONUtil.JsonToObject<List<SkuInfosItem>>(JSONUtil.ObjectToJson(dfresponse.productInfo.productSkuInfos));
|
rsp.Success = true;
|
rsp.DFProduct = dfresponse.productInfo;
|
return rsp;
|
}
|
}
|
|
public class GetAliProductInfoResponse
|
{
|
public bool Success { get; set; }
|
|
public string Error { get; set; }
|
|
/// <summary>
|
/// 精选
|
/// </summary>
|
public PFTProductDetailDomainProInfo JXProduct { get; set; }
|
|
/// <summary>
|
/// 代发
|
/// </summary>
|
public FenXiaoProductInfoGetDomain DFProduct { get; set; }
|
}
|
}
|
}
|