From 6ba068832d0a61113b9502700017da81022af475 Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Fri, 5 Jan 2024 01:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E5=8A=A9=E6=89=8B=E4=B8=8A?= =?UTF-8?q?=E6=9E=B6=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformSDK/JDBusiness.cs | 83 ++++++++++--------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index 44ca8da5..25cd6760 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -1058,7 +1058,6 @@ namespace BBWY.Server.Business } else if (res.Json["jingdong_category_read_findSaleAttrTemplates_responce"]["categoryAttrTemplates"]["templateType"].ToString() == "2") { - isStruts = true; var tempDataJarray = JArray.Parse(res.Json["jingdong_category_read_findSaleAttrTemplates_responce"]["categoryAttrTemplates"]["templateData"].ToString()); var tempDataJToken = tempDataJarray.FirstOrDefault(j => j.Value("valueRules").Contains("颜色") || j.Value("valueRules").Contains("款式") || @@ -1066,33 +1065,36 @@ namespace BBWY.Server.Business if (tempDataJToken == null) { RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, haveGiftTemplateSku); - throw new BusinessException("缺少结构化属性-颜色"); + throw new BusinessException("缺少必要的结构化属性"); } attrId = tempDataJToken.Value("attrId"); - var tempDataValuesJToken = JObject.Parse(tempDataJToken["valueRules"].ToString()); - var tempDataValues_Level1_JToken = tempDataValuesJToken["items"][0]; - if (tempDataValuesJToken["items"].Count() == 3 && - tempDataValuesJToken["items"][0]["properties"]["id"]["type"].ToString() == "model" && - tempDataValuesJToken["items"][1]["properties"]["id"]["type"].ToString() == "number" && - tempDataValuesJToken["items"][1]["properties"]["value"]["type"].ToString() == "number" && - tempDataValuesJToken["items"][2]["properties"]["id"]["type"].ToString() == "number" && - tempDataValuesJToken["items"][2]["properties"]["value"]["type"].ToString() == "string") + if (tempDataJToken.Value("type") == "1") { - var f_id = int.Parse(tempDataValuesJToken["items"][0]["properties"]["id"]["enum"][0].ToString()); - var f_tempJarray = tempDataValuesJToken["items"][0]["properties"]["value"]["enum"][0]["preprocessingSaleAttrValTemplateValueList"] as JArray; - var f_value = f_tempJarray.FirstOrDefault().Value("name"); - var f_valueId = f_tempJarray.FirstOrDefault().Value("id"); + isStruts = true; + var tempDataValuesJToken = JObject.Parse(tempDataJToken["valueRules"].ToString()); + var tempDataValues_Level1_JToken = tempDataValuesJToken["items"][0]; + if (tempDataValuesJToken["items"].Count() == 3 && + tempDataValuesJToken["items"][0]["properties"]["id"]["type"].ToString() == "model" && + tempDataValuesJToken["items"][1]["properties"]["id"]["type"].ToString() == "number" && + tempDataValuesJToken["items"][1]["properties"]["value"]["type"].ToString() == "number" && + tempDataValuesJToken["items"][2]["properties"]["id"]["type"].ToString() == "number" && + tempDataValuesJToken["items"][2]["properties"]["value"]["type"].ToString() == "string") + { + var f_id = int.Parse(tempDataValuesJToken["items"][0]["properties"]["id"]["enum"][0].ToString()); + var f_tempJarray = tempDataValuesJToken["items"][0]["properties"]["value"]["enum"][0]["preprocessingSaleAttrValTemplateValueList"] as JArray; + var f_value = f_tempJarray.FirstOrDefault().Value("name"); + var f_valueId = f_tempJarray.FirstOrDefault().Value("id"); - var s_id = int.Parse(tempDataValuesJToken["items"][1]["properties"]["id"]["enum"][0].ToString()); - var s_unit = tempDataValuesJToken["items"][1]["properties"]["unit"]["enum"][0].ToString(); - //var s_value = "1"; + var s_id = int.Parse(tempDataValuesJToken["items"][1]["properties"]["id"]["enum"][0].ToString()); + var s_unit = tempDataValuesJToken["items"][1]["properties"]["unit"]["enum"][0].ToString(); + //var s_value = "1"; - var t_id = int.Parse(tempDataValuesJToken["items"][2]["properties"]["id"]["enum"][0].ToString()); - var t_value = "待替换的备注"; + var t_id = int.Parse(tempDataValuesJToken["items"][2]["properties"]["id"]["enum"][0].ToString()); + var t_value = "待替换的备注"; - for (var i = 0; i < request.GiftTemplateSkuList.Count(); i++) - { - strutsSaleAttrValueList.Add(new List() + for (var i = 0; i < request.GiftTemplateSkuList.Count(); i++) + { + strutsSaleAttrValueList.Add(new List() { new AttrValueAliasJson() { @@ -1114,13 +1116,13 @@ namespace BBWY.Server.Business isReName = true } }); + } } - } - else if (tempDataValues_Level1_JToken["properties"]["id"]["type"].ToString() == "model") - { - //[{\"id\":5,\"unit\":\"\",\"value\":\"红色\","valueId":1234567}] - var tempJarray = tempDataValues_Level1_JToken["properties"]["value"]["enum"][0]["preprocessingSaleAttrValTemplateValueList"] as JArray; - strutsSaleAttrValueList.AddRange(tempJarray.Select(j => new List() + else if (tempDataValues_Level1_JToken["properties"]["id"]["type"].ToString() == "model") + { + //[{\"id\":5,\"unit\":\"\",\"value\":\"红色\","valueId":1234567}] + var tempJarray = tempDataValues_Level1_JToken["properties"]["value"]["enum"][0]["preprocessingSaleAttrValTemplateValueList"] as JArray; + strutsSaleAttrValueList.AddRange(tempJarray.Select(j => new List() { new AttrValueAliasJson { @@ -1131,17 +1133,17 @@ namespace BBWY.Server.Business isReName = true } })); - } - else if (tempDataValues_Level1_JToken["properties"]["id"]["type"].ToString() == "number" && - tempDataValues_Level1_JToken["properties"]["value"]["type"].ToString() == "number" && - tempDataValuesJToken["items"][1]["properties"]["id"]["type"].ToString() == "number" && - tempDataValuesJToken["items"][1]["properties"]["value"]["type"].ToString() == "string") - { - var f_id = int.Parse(tempDataValues_Level1_JToken["properties"]["id"]["enum"][0].ToString()); - var f_unit = tempDataValues_Level1_JToken["properties"]["unit"]["enum"][0].ToString(); - var s_id = int.Parse(tempDataValuesJToken["items"][1]["properties"]["id"]["enum"][0].ToString()); + } + else if (tempDataValues_Level1_JToken["properties"]["id"]["type"].ToString() == "number" && + tempDataValues_Level1_JToken["properties"]["value"]["type"].ToString() == "number" && + tempDataValuesJToken["items"][1]["properties"]["id"]["type"].ToString() == "number" && + tempDataValuesJToken["items"][1]["properties"]["value"]["type"].ToString() == "string") + { + var f_id = int.Parse(tempDataValues_Level1_JToken["properties"]["id"]["enum"][0].ToString()); + var f_unit = tempDataValues_Level1_JToken["properties"]["unit"]["enum"][0].ToString(); + var s_id = int.Parse(tempDataValuesJToken["items"][1]["properties"]["id"]["enum"][0].ToString()); - strutsSaleAttrValueList.AddRange(request.GiftTemplateSkuList.Select(x => new List() + strutsSaleAttrValueList.AddRange(request.GiftTemplateSkuList.Select(x => new List() { new AttrValueAliasJson() { @@ -1157,9 +1159,10 @@ namespace BBWY.Server.Business } })); + } + else + throw new BusinessException($"不支持的properties.id.type {tempDataValues_Level1_JToken["properties"]["id"]["type"]} 或取其分支情况"); } - else - throw new BusinessException($"不支持的properties.id.type {tempDataValues_Level1_JToken["properties"]["id"]["type"]} 或取其分支情况"); } } #endregion