feat(wxapi): 新增微信小店类目推荐接口

This commit is contained in:
Fu Diwei
2025-09-29 21:18:47 +08:00
parent 2deeff2cf3
commit 1979140413
5 changed files with 200 additions and 0 deletions

View File

@@ -5103,6 +5103,31 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
}
#endregion
#region ECProduct/Category
/// <summary>
/// <para>异步调用 [POST] /channels/ec/product/category/classify 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developers.weixin.qq.com/doc/store/shop/API/channels-shop-product/shop/api_product_classify.html ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ChannelsECProductCategoryClassifyResponse> 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<Models.ChannelsECProductCategoryClassifyResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion
#region ECProduct/Gift
/// <summary>
/// <para>异步调用 [POST] /channels/ec/product/gift/add 接口。</para>

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/product/category/classify 接口的请求。</para>
/// </summary>
public class ChannelsECProductCategoryClassifyRequest : WechatApiRequest, IInferable<ChannelsECProductCategoryClassifyRequest, ChannelsECProductCategoryClassifyResponse>
{
/// <summary>
/// 获取或设置请求类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("req_type")]
[System.Text.Json.Serialization.JsonPropertyName("req_type")]
public int RequestType { get; set; }
/// <summary>
/// 获取或设置商品标题。
/// </summary>
[Newtonsoft.Json.JsonProperty("title")]
[System.Text.Json.Serialization.JsonPropertyName("title")]
public string Title { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商品主图 URL 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("head_imgs")]
[System.Text.Json.Serialization.JsonPropertyName("head_imgs")]
public IList<string> HeadImageUrlList { get; set; } = new List<string>();
/// <summary>
/// 获取或设置商品类目 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("cat_id")]
[System.Text.Json.Serialization.JsonPropertyName("cat_id")]
public long? CategoryId { get; set; }
}
}

View File

@@ -0,0 +1,65 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/product/category/classify 接口的响应。</para>
/// </summary>
public class ChannelsECProductCategoryClassifyResponse : WechatApiResponse
{
public static class Types
{
public class CategoryList
{
/// <summary>
/// 获取或设置类目列表。
/// </summary>
[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
{
/// <summary>
/// 获取或设置类目 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("cat_id")]
[System.Text.Json.Serialization.JsonPropertyName("cat_id")]
public long CategoryId { get; set; }
}
}
/// <summary>
/// 获取或设置类目信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("cat_info")]
[System.Text.Json.Serialization.JsonPropertyName("cat_info")]
public Types.Category Category { get; set; } = default!;
/// <summary>
/// 获取或设置是否有该类目的权限。
/// </summary>
[Newtonsoft.Json.JsonProperty("has_permission")]
[System.Text.Json.Serialization.JsonPropertyName("has_permission")]
public bool HasPermission { get; set; }
}
}
/// <summary>
/// 获取或设置推荐类目列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("categories")]
[System.Text.Json.Serialization.JsonPropertyName("categories")]
public Types.CategoryList[] CategoryList { get; set; } = default!;
/// <summary>
/// 获取或设置是否类目错放。
/// </summary>
[Newtonsoft.Json.JsonProperty("wrong_cat")]
[System.Text.Json.Serialization.JsonPropertyName("wrong_cat")]
public bool? IsWrongCategory { get; set; }
}
}

View File

@@ -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"
]
}

View File

@@ -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
}
]
}
]
}