From 2c87beda039b2abeb1fbf4022c2d0ff6775601e1 Mon Sep 17 00:00:00 2001 From: "506583276@qq.com" <506583276@qq.com> Date: Thu, 9 Nov 2023 14:14:00 +0800 Subject: [PATCH] =?UTF-8?q?JD=20=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=95=86=E5=93=81=E7=B1=BB=E7=9B=AEId=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=B1=BB=E7=9B=AE=E7=9A=84=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=88=97=E8=A1=A8(=E6=9D=90=E8=B4=A8,=E9=80=82=E7=94=A8?= =?UTF-8?q?=E5=B9=B4=E9=BE=84=E7=AD=89...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformSDK/JDBusiness.cs | 17 +++++++++++++ .../PlatformSDK/PlatformSDKBusiness.cs | 5 ++++ .../Request/JD/GetAttrsByCategoryIdRequest.cs | 24 +++++++++++++++++++ JD.API/Controllers/PlatformSDKController.cs | 11 +++++++++ 4 files changed, 57 insertions(+) create mode 100644 BBWY.Server.Model/Dto/Request/JD/GetAttrsByCategoryIdRequest.cs diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index dc3c37fc..79bcdc42 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -1772,5 +1772,22 @@ namespace BBWY.Server.Business res.Json = JObject.Parse(res.Body); return (JArray)res.Json["jingdong_ware_read_findWareById_responce"]; } + + + public override JToken GetAttrsByCategoryId(GetAttrsByCategoryIdRequest request) + { + var jdClient = GetJdClient(request.AppKey, request.AppSecret); + var req = new CategoryReadFindAttrsByCategoryIdUnlimitCateRequest() { cid=request.CatId}; + + if(request.AttributeType!=null) + req.attributeType = request.AttributeType; + 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_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"]; + } } } diff --git a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs index 23b63707..e14733f7 100644 --- a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs @@ -281,5 +281,10 @@ namespace BBWY.Server.Business { throw new NotImplementedException(); } + + public virtual JToken GetAttrsByCategoryId(GetAttrsByCategoryIdRequest request) + { + throw new NotImplementedException(); + } } } diff --git a/BBWY.Server.Model/Dto/Request/JD/GetAttrsByCategoryIdRequest.cs b/BBWY.Server.Model/Dto/Request/JD/GetAttrsByCategoryIdRequest.cs new file mode 100644 index 00000000..5fddbf71 --- /dev/null +++ b/BBWY.Server.Model/Dto/Request/JD/GetAttrsByCategoryIdRequest.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Server.Model.Dto.Request.JD +{ + public class GetAttrsByCategoryIdRequest : PlatformRequest + { + /// + ///spu 类目id + /// + public long CatId { get; set; } + + /// + /// 属性类型 1.关键属性 3.可变属性 4.销售属性 + /// + public int? AttributeType { get; set; } + + /// + /// 查询对应的字段数据 + /// + public string Field { get; set; } + } +} diff --git a/JD.API/Controllers/PlatformSDKController.cs b/JD.API/Controllers/PlatformSDKController.cs index 62736558..4b650cd0 100644 --- a/JD.API/Controllers/PlatformSDKController.cs +++ b/JD.API/Controllers/PlatformSDKController.cs @@ -471,5 +471,16 @@ namespace JD.API.API.Controllers { return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetProductById(request); } + + /// + /// 通过商品类目Id 获取类目的属性列表(材质,适用年龄等...) + /// + /// + /// + [HttpPost] + public JToken GetAttrsByCategoryId([FromBody] GetAttrsByCategoryIdRequest request) + { + return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetAttrsByCategoryId(request); + } } }