feat(wxapi): 新增微信小店站内外商品属性映射接口

This commit is contained in:
Fu Diwei
2025-11-27 15:36:28 +08:00
parent 1a81effcbd
commit 3466c65569
5 changed files with 111 additions and 0 deletions

View File

@@ -5408,6 +5408,31 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
}
#endregion
#region ECProduct/ExternalProduct
/// <summary>
/// <para>异步调用 [POST] /channels/ec/product/externalproductmapping 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developers.weixin.qq.com/doc/store/shop/API/channels-shop-product/shop/api_externalproductmapping.html ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ChannelsECProductCategoryExternalProductMappingResponse> ExecuteChannelsECProductCategoryExternalProductMappingAsync(this WechatApiClient client, Models.ChannelsECProductCategoryExternalProductMappingRequest 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", "externalproductmapping")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendFlurlRequestAsJsonAsync<Models.ChannelsECProductCategoryExternalProductMappingResponse>(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,36 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/product/externalproductmapping 接口的请求。</para>
/// </summary>
public class ChannelsECProductCategoryExternalProductMappingRequest : WechatApiRequest, IInferable<ChannelsECProductCategoryExternalProductMappingRequest, ChannelsECProductCategoryExternalProductMappingResponse>
{
/// <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("external_attribute_name")]
[System.Text.Json.Serialization.JsonPropertyName("external_attribute_name")]
public string? ExternalAttributeName { get; set; }
/// <summary>
/// 获取或设置外部商品属性值。
/// </summary>
[Newtonsoft.Json.JsonProperty("external_attribute_value")]
[System.Text.Json.Serialization.JsonPropertyName("external_attribute_value")]
public string? ExternalAttributeValue { get; set; }
/// <summary>
/// 获取或设置外部商品类目名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("external_category_name")]
[System.Text.Json.Serialization.JsonPropertyName("external_category_name")]
public string? ExternalCategoryName { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/product/externalproductmapping 接口的响应。</para>
/// </summary>
public class ChannelsECProductCategoryExternalProductMappingResponse : WechatApiResponse
{
/// <summary>
/// 获取或设置外部商品属性键。
/// </summary>
[Newtonsoft.Json.JsonProperty("external_attribute_name")]
[System.Text.Json.Serialization.JsonPropertyName("external_attribute_name")]
public string? ExternalAttributeName { get; set; }
/// <summary>
/// 获取或设置外部商品属性值。
/// </summary>
[Newtonsoft.Json.JsonProperty("external_attribute_value")]
[System.Text.Json.Serialization.JsonPropertyName("external_attribute_value")]
public string? ExternalAttributeValue { get; set; }
/// <summary>
/// 获取或设置内部商品属性键。
/// </summary>
[Newtonsoft.Json.JsonProperty("internal_attribute_name")]
[System.Text.Json.Serialization.JsonPropertyName("internal_attribute_name")]
public string? InternalAttributeName { get; set; }
/// <summary>
/// 获取或设置内部商品属性值列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("internal_attribute_value")]
[System.Text.Json.Serialization.JsonPropertyName("internal_attribute_value")]
public string[]? InternalAttributeValueList { get; set; }
}
}

View File

@@ -0,0 +1,6 @@
{
"cat_id": 6261,
"external_attribute_name": "帮面材质",
"external_attribute_value": "塑胶",
"external_category_name": "母婴:童鞋:雨鞋"
}

View File

@@ -0,0 +1,8 @@
{
"errcode": 0,
"errmsg": "ok",
"external_attribute_name": "帮面材质",
"external_attribute_value": "塑胶",
"internal_attribute_name": "鞋面材质",
"internal_attribute_value": [ "塑胶" ]
}