Browse Source

jd接口 新增 查通过spuid 获取单个商品

AddValidOverTime
506583276@qq.com 2 years ago
parent
commit
7bc7a3926f
  1. 15
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  2. 5
      BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
  3. 19
      BBWY.Server.Model/Dto/Request/JD/GetProductByIdRequest.cs
  4. 12
      JD.API/Controllers/PlatformSDKController.cs

15
BBWY.Server.Business/PlatformSDK/JDBusiness.cs

@ -1757,5 +1757,20 @@ namespace BBWY.Server.Business
res.Json = JObject.Parse(res.Body);
return (JArray)res.Json["jingdong_eclp_stock_queryStock_responce"]["querystock_result"];
}
public override JToken GetProductById(GetProductByIdRequest request)
{
var jdClient = GetJdClient(request.AppKey, request.AppSecret);
var req = new WareReadFindWareByIdRequest() { wareId = request.SpuId};
if (request.Field != null)
req.field = request.Field;
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (res.Json == null)
res.Json = JObject.Parse(res.Body);
return (JArray)res.Json["jingdong_ware_read_findWareById_responce"];
}
}
}

5
BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs

@ -276,5 +276,10 @@ namespace BBWY.Server.Business
{
throw new NotImplementedException();
}
public virtual JToken GetProductById(GetProductByIdRequest request)
{
throw new NotImplementedException();
}
}
}

19
BBWY.Server.Model/Dto/Request/JD/GetProductByIdRequest.cs

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BBWY.Server.Model.Dto.Request.JD
{
public class GetProductByIdRequest : PlatformRequest
{
/// <summary>
/// 商品spuId
/// </summary>
public long? SpuId { get; set; }
/// <summary>
/// 查询对应的字段数据
/// </summary>
public string Field { get; set; }
}
}

12
JD.API/Controllers/PlatformSDKController.cs

@ -459,5 +459,17 @@ namespace JD.API.API.Controllers
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetStockNumByWareHouseNo(request);
}
/// <summary>
/// 通过spuId 获取对应的商品详情
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public JToken GetProductById([FromBody] GetProductByIdRequest request)
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetProductById(request);
}
}
}

Loading…
Cancel
Save