diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index aaf8c222..dc3c37fc 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/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"]; + } } } diff --git a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs index ce14a9a9..23b63707 100644 --- a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs +++ b/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(); + } } } diff --git a/BBWY.Server.Model/Dto/Request/JD/GetProductByIdRequest.cs b/BBWY.Server.Model/Dto/Request/JD/GetProductByIdRequest.cs new file mode 100644 index 00000000..bd7f0b23 --- /dev/null +++ b/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 + { + /// + /// 商品spuId + /// + public long? SpuId { get; set; } + + /// + /// 查询对应的字段数据 + /// + public string Field { get; set; } + } +} diff --git a/JD.API/Controllers/PlatformSDKController.cs b/JD.API/Controllers/PlatformSDKController.cs index 143f60ea..62736558 100644 --- a/JD.API/Controllers/PlatformSDKController.cs +++ b/JD.API/Controllers/PlatformSDKController.cs @@ -459,5 +459,17 @@ namespace JD.API.API.Controllers { return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetStockNumByWareHouseNo(request); } + + + /// + /// 通过spuId 获取对应的商品详情 + /// + /// + /// + [HttpPost] + public JToken GetProductById([FromBody] GetProductByIdRequest request) + { + return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetProductById(request); + } } }