mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-20 02:29:40 +08:00
feat(wxapi): 新增小程序联盟获取商品推广素材接口
This commit is contained in:
@@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /union/promoter/product/category 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/product/category.html#_1-%E8%8E%B7%E5%8F%96%E8%81%94%E7%9B%9F%E5%95%86%E5%93%81%E7%B1%BB%E7%9B%AE%E5%88%97%E8%A1%A8%E5%8F%8A%E7%B1%BB%E7%9B%AEID </para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
@@ -118,7 +118,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /union/promoter/product/list 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/product/category.html#_2-%E6%9F%A5%E8%AF%A2%E5%95%86%E5%93%81%E8%AF%A6%E6%83%85%E4%BF%A1%E6%81%AF </para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
@@ -241,7 +241,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /union/promoter/product/generate 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/product/category.html#_3-%E8%8E%B7%E5%8F%96%E5%95%86%E5%93%81%E6%8E%A8%E5%B9%BF%E7%B4%A0%E6%9D%90 </para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/access-guidelines/promoter/api/product/category.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
@@ -263,7 +263,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
#region OpenProduct
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /union/promoter/open_product/list 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/custom_component/api/promoter/openproduct.html</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/custom_component/api/promoter/openproduct.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
@@ -318,6 +318,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.UnionPromoterOpenProductListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /union/promoter/open_product/generate 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/union/custom_component/api/promoter/openpromotion.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.UnionPromoterOpenProductGenerateResponse> ExecuteUnionPromoterOpenProductGenerateAsync(this WechatApiClient client, Models.UnionPromoterOpenProductGenerateRequest 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
|
||||
.CreateRequest(request, HttpMethod.Post, "union", "promoter", "open_product", "generate")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.UnionPromoterOpenProductGenerateResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Order
|
||||
|
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /union/promoter/open_product/generate 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class UnionPromoterOpenProductGenerateRequest : WechatApiRequest, IInferable<UnionPromoterOpenProductGenerateRequest, UnionPromoterOpenProductGenerateResponse>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置商品 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("productId")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("productId")]
|
||||
public long ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置所属小商店 AppId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("appId")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("appId")]
|
||||
public string AppId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置自定义扩展参数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("customizeInfo")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("customizeInfo")]
|
||||
public string? CustomizeExtra { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置推广位 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pid")]
|
||||
public string PromotionId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否拉取短链和推广文案。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("getShortUrl")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("getShortUrl")]
|
||||
public bool? RequireGetShortUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否拉取商品信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("getInfo")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("getInfo")]
|
||||
public bool? RequireGetInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置商品列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("productList")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("productList")]
|
||||
public IList<Types.Product> ProductList { get; set; } = new List<Types.Product>();
|
||||
}
|
||||
}
|
@@ -0,0 +1,157 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /union/promoter/open_product/generate 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class UnionPromoterOpenProductGenerateResponse : WechatApiResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class ProductPromotion
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置商品 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("productId")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("productId")]
|
||||
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
|
||||
public long ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置商品标题。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("title")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("title")]
|
||||
public string Title { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置商品副标题。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("subTitle")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("subTitle")]
|
||||
public string? SubTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置主图 Url 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("headImg")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("headImg")]
|
||||
public string[] HeadImageUrlList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 SKU 最低价格(单位:分)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("minPrice")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("minPrice")]
|
||||
public int MinPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置商品库存。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("totalStockNum")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("totalStockNum")]
|
||||
public int Stock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置小商店名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("shopName")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("shopName")]
|
||||
public string? ShopName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置店铺状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("shopStatus")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("shopStatus")]
|
||||
public int? ShopStatus { get; set; }
|
||||
}
|
||||
|
||||
public class Share
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置小程序 AppId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("appId")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("appId")]
|
||||
public string AppId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置小程序原始 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("username")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("username")]
|
||||
public string Username { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置小程序页面路径。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("path")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("path")]
|
||||
public string PagePath { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置推广商品文案。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("promotionWording")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("promotionWording")]
|
||||
public string? PromotionText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置推广商品链接。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("promotionUrl")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("promotionUrl")]
|
||||
public string? PromotionUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置推广商品 Tag。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("promotionTag")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("promotionTag")]
|
||||
public string? PromotionTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置获取素材状态码。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("code")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("code")]
|
||||
public int Code { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置推广位 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pid")]
|
||||
public string PromotionId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置商品信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("productInfo")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("productInfo")]
|
||||
public Types.Product Product { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置推广相关信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("shareInfo")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("shareInfo")]
|
||||
public Types.Share? Share { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置商品推广素材列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("list")]
|
||||
public Types.ProductPromotion[] ProductPromotionList { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -161,7 +161,6 @@
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("list")]
|
||||
|
||||
public Types.ProductPromotion[] ProductPromotionList { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"pid": "oUnIc49zinb1mtlfB5K-NfGJxxNE_341161518",
|
||||
"productList": [
|
||||
{
|
||||
"productId": "14495788",
|
||||
"appId": "wxb82530c28"
|
||||
}
|
||||
]
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"list": [
|
||||
{
|
||||
"pid": "oJtf15NzExNvQ8UnT9SNOWQpyOpw_466373468",
|
||||
"productInfo": {
|
||||
"productId": "413063159",
|
||||
"shopName": "测试商品精品商城",
|
||||
"totalStockNum": 100
|
||||
},
|
||||
"shareInfo": {
|
||||
"appId": "wxd5246f9e9041f745",
|
||||
"username": "gh_760d082de91f",
|
||||
"path": "pages/detail/detail?productId=3354&open_league_ticket=bGVhZ3VldGlja2V0OjE1NjAzOTc5NzU1MDA2MjU1Mjg0NDM5OTg2",
|
||||
"promotionWording": "😨大家都在等这款,每次都巨抢手👑把它带回家!❗️售完即止💰\n————\n测试礼盒\n\n优惠价:62元\n\n下单:https://mmbizurl.cn/u/Kr1xRsVy",
|
||||
"promotionUrl": "https://mmbizurl.cn/u/Kr1xRsV",
|
||||
"promotionTag": "#小程序://测试商品精品商城/【佳琦会员专享测试商品/gRDKwkGQYkTc"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user