From 19791404130a1665459b69a34737eb54b3b3bbf3 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Mon, 29 Sep 2025 21:18:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E6=96=B0=E5=A2=9E=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=B0=8F=E5=BA=97=E7=B1=BB=E7=9B=AE=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...echatApiClientExecuteChannelsExtensions.cs | 25 +++++++ ...hannelsECProductCategoryClassifyRequest.cs | 38 +++++++++++ ...annelsECProductCategoryClassifyResponse.cs | 65 +++++++++++++++++++ ...nnelsECProductCategoryClassifyRequest.json | 10 +++ ...nelsECProductCategoryClassifyResponse.json | 62 ++++++++++++++++++ 5 files changed, 200 insertions(+) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs index 3670c2d2..353c867c 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs @@ -5103,6 +5103,31 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } #endregion + #region ECProduct/Category + /// + /// 异步调用 [POST] /channels/ec/product/category/classify 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteChannelsECProductCategoryClassifyAsync(this WechatApiClient client, Models.ChannelsECProductCategoryClassifyRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + IFlurlRequest flurlReq = client + .CreateFlurlRequest(request, HttpMethod.Post, "channels", "ec", "product", "category", "classify") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + #endregion + #region ECProduct/Gift /// /// 异步调用 [POST] /channels/ec/product/gift/add 接口。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.cs new file mode 100644 index 00000000..5ac9dfa3 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/product/category/classify 接口的请求。 + /// + public class ChannelsECProductCategoryClassifyRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置请求类型。 + /// + [Newtonsoft.Json.JsonProperty("req_type")] + [System.Text.Json.Serialization.JsonPropertyName("req_type")] + public int RequestType { get; set; } + + /// + /// 获取或设置商品标题。 + /// + [Newtonsoft.Json.JsonProperty("title")] + [System.Text.Json.Serialization.JsonPropertyName("title")] + public string Title { get; set; } = string.Empty; + + /// + /// 获取或设置商品主图 URL 列表。 + /// + [Newtonsoft.Json.JsonProperty("head_imgs")] + [System.Text.Json.Serialization.JsonPropertyName("head_imgs")] + public IList HeadImageUrlList { get; set; } = new List(); + + /// + /// 获取或设置商品类目 ID。 + /// + [Newtonsoft.Json.JsonProperty("cat_id")] + [System.Text.Json.Serialization.JsonPropertyName("cat_id")] + public long? CategoryId { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.cs new file mode 100644 index 00000000..ff58a745 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.cs @@ -0,0 +1,65 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/product/category/classify 接口的响应。 + /// + public class ChannelsECProductCategoryClassifyResponse : WechatApiResponse + { + public static class Types + { + public class CategoryList + { + /// + /// 获取或设置类目列表。 + /// + [Newtonsoft.Json.JsonProperty("cats")] + [System.Text.Json.Serialization.JsonPropertyName("cats")] + public CategoryItem[] Items { get; set; } = default!; + } + + public class CategoryItem + { + public static class Types + { + public class Category + { + /// + /// 获取或设置类目 ID。 + /// + [Newtonsoft.Json.JsonProperty("cat_id")] + [System.Text.Json.Serialization.JsonPropertyName("cat_id")] + public long CategoryId { get; set; } + } + } + + /// + /// 获取或设置类目信息。 + /// + [Newtonsoft.Json.JsonProperty("cat_info")] + [System.Text.Json.Serialization.JsonPropertyName("cat_info")] + public Types.Category Category { get; set; } = default!; + + /// + /// 获取或设置是否有该类目的权限。 + /// + [Newtonsoft.Json.JsonProperty("has_permission")] + [System.Text.Json.Serialization.JsonPropertyName("has_permission")] + public bool HasPermission { get; set; } + } + } + + /// + /// 获取或设置推荐类目列表。 + /// + [Newtonsoft.Json.JsonProperty("categories")] + [System.Text.Json.Serialization.JsonPropertyName("categories")] + public Types.CategoryList[] CategoryList { get; set; } = default!; + + /// + /// 获取或设置是否类目错放。 + /// + [Newtonsoft.Json.JsonProperty("wrong_cat")] + [System.Text.Json.Serialization.JsonPropertyName("wrong_cat")] + public bool? IsWrongCategory { get; set; } + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.json new file mode 100644 index 00000000..091e5305 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyRequest.json @@ -0,0 +1,10 @@ +{ + "req_type": 1, + "title": "猕猴桃新鲜水果", + "head_imgs": [ + "https://mmecimage.cn/p/wx2b255582a7b4bfd0/HMpEI3XtWmJc2CHv4lhnfoZcLtxVTBhH8QU48DcKtHr1", + "https://mmecimage.cn/p/wx2b255582a7b4bfd0/HKcyK0PMZvTGfiLiV0AXk0NTkg5NGkj-UOL8ZiKoYtTp", + "https://mmecimage.cn/p/wx2b255582a7b4bfd0/HIQR0SYL9WPTmI81SCoPREi8EYjd9l1qEzU2Lb0vNT0z", + "https://mmecimage.cn/p/wx2b255582a7b4bfd0/HGwaot5cxQsDrcZRZrlCGjn66Ha6ZSG_ZUTkjpfnCXpJ" + ] +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.json new file mode 100644 index 00000000..d75038df --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECProduct/Category/ChannelsECProductCategoryClassifyResponse.json @@ -0,0 +1,62 @@ +{ + "errcode": 0, + "errmsg": "ok", + "categories": [ + { + "cats": [ + { + "cat_info": { + "cat_id": "10000155" + }, + "has_permission": false + }, + { + "cat_info": { + "cat_id": "10000161" + }, + "has_permission": false + }, + { + "cat_info": { + "cat_id": "10000556" + }, + "has_permission": false + }, + { + "cat_info": { + "cat_id": "546334" + }, + "has_permission": false + } + ] + }, + { + "cats": [ + { + "cat_info": { + "cat_id": "10000155" + }, + "has_permission": false + }, + { + "cat_info": { + "cat_id": "10000161" + }, + "has_permission": false + }, + { + "cat_info": { + "cat_id": "10000558" + }, + "has_permission": false + }, + { + "cat_info": { + "cat_id": "546346" + }, + "has_permission": true + } + ] + } + ] +}