From 7bc7a3926f100fd1522ea178491185ffbc414af4 Mon Sep 17 00:00:00 2001
From: "506583276@qq.com" <506583276@qq.com>
Date: Wed, 8 Nov 2023 20:13:27 +0800
Subject: [PATCH] =?UTF-8?q?jd=E6=8E=A5=E5=8F=A3=20=20=E6=96=B0=E5=A2=9E=20?=
=?UTF-8?q?=E6=9F=A5=E9=80=9A=E8=BF=87spuid=20=E8=8E=B7=E5=8F=96=E5=8D=95?=
=?UTF-8?q?=E4=B8=AA=E5=95=86=E5=93=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../PlatformSDK/JDBusiness.cs | 15 +++++++++++++++
.../PlatformSDK/PlatformSDKBusiness.cs | 5 +++++
.../Dto/Request/JD/GetProductByIdRequest.cs | 19 +++++++++++++++++++
JD.API/Controllers/PlatformSDKController.cs | 12 ++++++++++++
4 files changed, 51 insertions(+)
create mode 100644 BBWY.Server.Model/Dto/Request/JD/GetProductByIdRequest.cs
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);
+ }
}
}