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
{
///
/// 获取1688商品详情
///
///
///
public GetAliProductInfoResponse GetAliProductInfo(CompareChangeRequest request)
{
GetAliProductInfoResponse rsp= new GetAliProductInfoResponse()
{
Success = false
};
if (request.ProSource == 0)
{//精选
List ls = new List();
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 res = JSONUtil.JsonToObject>(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; }
///
/// 精选
///
public PFTProductDetailDomainProInfo JXProduct { get; set; }
///
/// 代发
///
public FenXiaoProductInfoGetDomain DFProduct { get; set; }
}
}
}