mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-19 18:22:24 +08:00
feat(tenpayv3): 新增银行提现免费券相关接口
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
| √ | 营销工具:图片上传(营销专用) | 直连商户 & 服务商 | |
|
||||
| × | <del>营销工具:现金红包</del> | 直连商户 & 服务商 | 官方未提供 v3 API |
|
||||
| √ | 营销工具:银行定向促活 | 直连商户 & 服务商 | |
|
||||
| √ | 营销工具:银行提现免费券 | 服务商 | |
|
||||
| × | <del>资金应用:转账到银行卡</del> | 直连商户 | 官方未提供 v3 API |
|
||||
| √ | 资金应用:转账到零钱 | 直连商户 & 服务商 | |
|
||||
| √ | 资金应用:分账 | 直连商户 & 服务商 | |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
/// <summary>
|
||||
/// 为 <see cref="WechatTenpayClient"/> 提供银行提现免费券相关的 API 扩展方法。
|
||||
/// </summary>
|
||||
public static class WechatTenpayClientExecuteMarketingWithdrawFavorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /marketing/withdraw-favor/users/{openid}/coupons 接口。</para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter3_2_1.shtml </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.SendMarketingWithdrawFavorUserCouponResponse> ExecuteSendMarketingWithdrawFavorUserCouponAsync(this WechatTenpayClient client, Models.SendMarketingWithdrawFavorUserCouponRequest 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, "marketing", "withdraw-favor", "users", request.OpenId, "coupons");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.SendMarketingWithdrawFavorUserCouponResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /marketing/withdraw-favor/users/{openid}/coupons 接口。</para>
|
||||
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter3_2_2.shtml </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.QueryMarketingWithdrawFavorUserCouponsResponse> ExecuteQueryMarketingWithdrawFavorUserCouponsAsync(this WechatTenpayClient client, Models.QueryMarketingWithdrawFavorUserCouponsRequest 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.Get, "marketing", "withdraw-favor", "users", request.OpenId, "coupons")
|
||||
.SetQueryParam("appid", request.AppId)
|
||||
.SetQueryParam("mchid", request.CreatorMerchantId)
|
||||
.SetQueryParam("stock_id", request.StockId);
|
||||
|
||||
if (request.Limit != null)
|
||||
flurlReq.SetQueryParam("limit", request.Limit.Value.ToString());
|
||||
|
||||
if (request.Offset != null)
|
||||
flurlReq.SetQueryParam("offset", request.Offset.Value.ToString());
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.QueryMarketingWithdrawFavorUserCouponsResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
|
||||
{
|
||||
|
@@ -0,0 +1,50 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /marketing/withdraw-favor/users/{openid}/coupons 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class QueryMarketingWithdrawFavorUserCouponsRequest : WechatTenpayRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置微信 AppId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string AppId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置批次号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string StockId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置创建批次的商户号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string CreatorMerchantId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分页大小。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public int? Limit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分页开始位置。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public int? Offset { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /marketing/withdraw-favor/users/{openid}/coupons 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class QueryMarketingWithdrawFavorUserCouponsResponse : WechatTenpayResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Coupon
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置代金券 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("coupon_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("coupon_id")]
|
||||
public string CouponId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置券状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("coupon_state")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("coupon_state")]
|
||||
public string? CouponState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置发放额度(单位:分)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("send_quota")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("send_quota")]
|
||||
public int SendQuota { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置使用额度(单位:分)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("use_quota")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("use_quota")]
|
||||
public int UseQuota { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置发券时间。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("send_time")]
|
||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("send_time")]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
|
||||
public DateTimeOffset SendTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置券列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("data")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("data")]
|
||||
public Types.Coupon[] CouponList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分页大小。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("limit")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("limit")]
|
||||
public int Limit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分页开始位置。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("offset")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("offset")]
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置券总数量。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("total_count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("total_count")]
|
||||
public int TotalCount { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /marketing/withdraw-favor/users/{openid}/coupons 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class SendMarketingWithdrawFavorUserCouponRequest : WechatTenpayRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置银行提现免费券批次创建方商户号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("mchid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("mchid")]
|
||||
public string CreatorMerchantId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置银行提现免费券批次 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("stock_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("stock_id")]
|
||||
public string StockId { get; set; } = string.Empty;
|
||||
|
||||
/// <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("send_request_no")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("send_request_no")]
|
||||
public string SendOutRequestNumber { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /marketing/withdraw-favor/users/{openid}/coupons 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class SendMarketingWithdrawFavorUserCouponResponse : WechatTenpayResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置银行提现免费券 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("coupon_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("coupon_id")]
|
||||
public string CouponId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置过期时间。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("expire_time")]
|
||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("expire_time")]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
|
||||
public DateTimeOffset? ExpireTime { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"coupon_id": "C688134DB8D27165DCD630B319A870679F29B3720EF89F4F8EAE01429641F8C2-17-1505164059",
|
||||
"coupon_state": "VALID",
|
||||
"send_quota": 1000,
|
||||
"send_time": "2021-05-20T13:29:35.120+08:00",
|
||||
"use_quota": 500
|
||||
}
|
||||
],
|
||||
"limit": 10,
|
||||
"offset": 1,
|
||||
"total_count": 100
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"appid": "wxd678efh567hg6787",
|
||||
"mchid": "1230000109",
|
||||
"send_request_no": "89560002019101000121",
|
||||
"stock_id": "1304490000000059"
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"coupon_id": "C688134DB8D27165DCD630B319A870679F29B3720EF89F4F8EAE01429641F8C2-17-1505164059",
|
||||
"expire_time": "2021-05-20T13:29:35.120+08:00"
|
||||
}
|
Reference in New Issue
Block a user