diff --git a/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs b/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs index abd77684..3587f82f 100644 --- a/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs +++ b/BBWY.JDSDK/Request/SkuWriteUpdateSkusRequest.cs @@ -1,4 +1,5 @@ using Jd.Api.Response; +using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -22,6 +23,9 @@ namespace Jd.Api.Request public class SkuWriteUpdateSkusItem { + [JsonProperty("@type")] + public string type { get; set; } = "com.jd.pop.ware.ic.api.domain.Sku"; + public Nullable wareId { get; set; } public Nullable skuId { get; set; } @@ -39,6 +43,9 @@ namespace Jd.Api.Request public class SkuWriteUpdateSkusItemSaleAttrs { + [JsonProperty("@type")] + public string type { get; set; } + public string attrId { get; set; } public List attrValues { get; set; } diff --git a/BBWY.JDSDK/Request/WareWriteUpdateWareSaleAttrvalueAliasRequest.cs b/BBWY.JDSDK/Request/WareWriteUpdateWareSaleAttrvalueAliasRequest.cs new file mode 100644 index 00000000..e9296b0e --- /dev/null +++ b/BBWY.JDSDK/Request/WareWriteUpdateWareSaleAttrvalueAliasRequest.cs @@ -0,0 +1,40 @@ +using BBWY.JDSDK.Response; +using Jd.Api; +using Jd.Api.Response; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Jd.Api.Request +{ + public class WareWriteUpdateWareSaleAttrvalueAliasRequest : JdRequestBase + { + public override string ApiName => "jingdong.ware.write.updateWareSaleAttrvalueAlias"; + + public Nullable wareId { get; set; } + + public IList props { get; set; } + + + + protected override void PrepareParam(IDictionary paramters) + { + paramters.Add("wareId", wareId); + paramters.Add("props", props); + } + } + + public class WareWriteUpdateWareSaleAttrvalueAliasRequestItem + { + public string attrId { get; set; } + + public IList attrValues { get; set; } + + public IList attrValueAlias { get; set; } + + + [JsonProperty("@type")] + public string type { get; set; } = "com.jd.pop.ware.ic.api.domain.Prop"; + } +} diff --git a/BBWY.JDSDK/Response/WareWriteUpdateWareSaleAttrvalueAliasResponse.cs b/BBWY.JDSDK/Response/WareWriteUpdateWareSaleAttrvalueAliasResponse.cs new file mode 100644 index 00000000..b56e7929 --- /dev/null +++ b/BBWY.JDSDK/Response/WareWriteUpdateWareSaleAttrvalueAliasResponse.cs @@ -0,0 +1,8 @@ +using Jd.Api; + +namespace Jd.Api.Response +{ + public class WareWriteUpdateWareSaleAttrvalueAliasResponse : JdResponse + { + } +} diff --git a/BBWY.Test/JDProductAPITest.cs b/BBWY.Test/JDProductAPITest.cs index aad4701d..23609641 100644 --- a/BBWY.Test/JDProductAPITest.cs +++ b/BBWY.Test/JDProductAPITest.cs @@ -6,7 +6,6 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; -using System.Text; namespace BBWY.Test { @@ -53,7 +52,7 @@ namespace BBWY.Test public void ShangJiaTest(IJdClient client, string token) { - var mainSpu = "10022515718131"; + var mainSpu = "10022905456671"; var giftSpu = "10023500913672"; var barCode = ""; @@ -137,7 +136,7 @@ namespace BBWY.Test Console.WriteLine("销售属性"); if (response.Json == null) response.Json = JObject.Parse(response.Body); - var colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j.Value("id") == 1000007121); + var colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j.Value("name") == "颜色"); if (colorProperty == null) throw new Exception("缺少颜色属性"); colorSaleAttrs = colorProperty["attrValueList"].ToList(); @@ -147,8 +146,8 @@ namespace BBWY.Test #region 增量保存sku { var skusParamList = new List(); - var takeColorIndex = colorSaleAttrs.Count() - 1; - for (var i = 0; i < 2; i++) + var takeColorIndex = colorSaleAttrs.Count() - 10; + for (var i = 0; i < 3; i++) { var giftSku = selectGiftSkuList[i]; var p = new SkuWriteUpdateSkusItem() @@ -164,9 +163,13 @@ namespace BBWY.Test p.saleAttrs = new List(); var m = new SkuWriteUpdateSkusItemSaleAttrs(); + m.type = "com.jd.pop.ware.ic.api.domain.Prop"; m.attrId = colorProperty.Value("attId"); m.attrValues = new List() { colorProperty.Value("id") }; - m.attrValueAlias = new List() { colorProperty.Value("name") }; + m.attrValueAlias = new List() { + giftSku.Title + //colorProperty.Value("name") + }; m.index = takeColorIndex; p.saleAttrs.Add(m); takeColorIndex--; @@ -207,5 +210,42 @@ namespace BBWY.Test } #endregion } + + public void 修改属性别名(IJdClient client, string token) + { + var mainSpu = "10022905456671"; + var request = new WareWriteUpdateWareSaleAttrvalueAliasRequest(); + request.wareId = long.Parse(mainSpu); + request.props = new List(); + request.props.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem() + { + attrId = "1001050679", + attrValues = new List() { "2912651180" }, + attrValueAlias = new List() { "粉丝价" } + }); + + request.props.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem() + { + attrId = "1001050679", + attrValues = new List() { "2912655473" }, + attrValueAlias = new List() { "放心购" } + }); + + request.props.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem() + { + attrId = "1001050679", + attrValues = new List() { "2912660446" }, + attrValueAlias = new List() { "闪电退款" } + }); + + Console.WriteLine("请求参数"); + Console.WriteLine(JsonConvert.SerializeObject(request)); + var res = client.Execute(request, token, DateTime.Now.ToLocalTime()); + + Console.WriteLine(); + Console.WriteLine("返回内容"); + Console.WriteLine(JsonConvert.SerializeObject(res)); + + } } } diff --git a/BBWY.Test/JDServiceAPITest.cs b/BBWY.Test/JDServiceAPITest.cs index 7e3b8059..4ec306da 100644 --- a/BBWY.Test/JDServiceAPITest.cs +++ b/BBWY.Test/JDServiceAPITest.cs @@ -17,8 +17,8 @@ namespace BBWY.Test req.buId = "10598776"; req.operatePin = "布莱特玩具"; req.operateNick = "布莱特玩具"; - req.serviceId = 1597963593; - req.orderId = 256149123505; + req.serviceId = 1606469473; + req.orderId = 256567714100; //req.extJsonStr = "abc"; diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs index c374d9e0..a6c0cb8a 100644 --- a/BBWY.Test/Program.cs +++ b/BBWY.Test/Program.cs @@ -58,8 +58,8 @@ namespace BBWY.Test //var ddTest = new DingDingAPITest(); //ddTest.Send(); - test1.ShangJiaTest(client, token); - + //test1.ShangJiaTest(client, token); + test1.修改属性别名(client, token); Console.ReadKey(); } }