feat(tenpayv3): 新增商家转账到 QQ 钱包相关接口

This commit is contained in:
Fu Diwei
2025-04-21 17:13:51 +08:00
parent ae2815f7d2
commit 297ccb060c
17 changed files with 672 additions and 8 deletions

View File

@@ -53,13 +53,6 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string? OpenId { get; set; }
/// <summary>
/// 获取或设置失败原因。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_reason")]
[System.Text.Json.Serialization.JsonPropertyName("fail_reason")]
public string? FailReason { get; set; }
/// <summary>
/// 获取或设置更新时间。
/// </summary>
@@ -77,5 +70,12 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置失败原因。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_reason")]
[System.Text.Json.Serialization.JsonPropertyName("fail_reason")]
public string? FailReason { get; set; }
}
}

View File

@@ -0,0 +1,109 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
{
/// <summary>
/// <para>表示 MCHTRANSFER.QQWALLETBILL.FINISHED", 通知的数据。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014301851 ]]> <br/>
/// </para>
/// </summary>
public class MerchantTransferQQWalletBillFinishedResource : WechatTenpayEvent.Types.IDecryptedResource
{
/// <summary>
/// 获取或设置微信商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("mchid")]
[System.Text.Json.Serialization.JsonPropertyName("mchid")]
public string MerchantId { get; set; } = default!;
/// <summary>
/// 获取或设置 QQ 互联开放平台 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = default!;
/// <summary>
/// 获取或设置商户转账单号
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]
public string OutBillNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信转账单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_bill_no")]
public string TransferBillNumber { get; set; } = default!;
/// <summary>
/// 获取或设置单据状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("state")]
[System.Text.Json.Serialization.JsonPropertyName("state")]
public string State { get; set; } = default!;
/// <summary>
/// 获取或设置转账金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_amount")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_amount")]
public int TransferAmount { get; set; }
/// <summary>
/// 获取或设置转账备注。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_remark")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_remark")]
public string TransferRemark { get; set; } = default!;
/// <summary>
/// 获取或设置收款用户的 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string? OpenId { get; set; }
/// <summary>
/// 获取或设置收款用户的 QQ 号。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_qq")]
[System.Text.Json.Serialization.JsonPropertyName("user_qq")]
public string? UserQQ { get; set; }
/// <summary>
/// 获取或设置收款用户姓名(需使用商户私钥解密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_name")]
public string? UserName { get; set; }
/// <summary>
/// 获取或设置更新时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("update_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("update_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset UpdateTime { get; set; }
/// <summary>
/// 获取或设置创建时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置失败原因。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_reason")]
[System.Text.Json.Serialization.JsonPropertyName("fail_reason")]
public string? FailReason { get; set; }
}
}

View File

@@ -189,6 +189,74 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
return await client.SendFlurlRequestAsJsonAsync<Models.GetFundAppMerchantTransferBillByTransferBillNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion
#region MerchantTransfer/TransferToQQWalletBills
/// <summary>
/// <para>异步调用 [POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014297386 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateFundAppMerchantTransferToQQWalletBillResponse> ExecuteCreateFundAppMerchantTransferToQQWalletBillAsync(this WechatTenpayClient client, Models.CreateFundAppMerchantTransferToQQWalletBillRequest 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, "fund-app", "mch-transfer", "transfer-to-qq-wallet-bills");
return await client.SendFlurlRequestAsJsonAsync<Models.CreateFundAppMerchantTransferToQQWalletBillResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no}/cancel 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014297396 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CancelFundAppMerchantTransferToQQWalletBillResponse> ExecuteCancelFundAppMerchantTransferToQQWalletBillAsync(this WechatTenpayClient client, Models.CancelFundAppMerchantTransferToQQWalletBillRequest 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, "fund-app", "mch-transfer", "transfer-to-qq-wallet-bills", request.OutBillNumber, "cancel");
return await client.SendFlurlRequestAsJsonAsync<Models.CancelFundAppMerchantTransferToQQWalletBillResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [GET] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no} 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014297440 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetFundAppMerchantTransferToQQWalletBillByOutBillNumberResponse> ExecuteGetFundAppMerchantTransferToQQWalletBillByOutBillNumberAsync(this WechatTenpayClient client, Models.GetFundAppMerchantTransferToQQWalletBillByOutBillNumberRequest 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.Get, "fund-app", "mch-transfer", "transfer-to-qq-wallet-bills", request.OutBillNumber);
return await client.SendFlurlRequestAsJsonAsync<Models.GetFundAppMerchantTransferToQQWalletBillByOutBillNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no}/cancel 接口的请求。</para>
/// </summary>
public class CancelFundAppMerchantTransferToQQWalletBillRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string OutBillNumber { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no}/cancel 接口的响应。</para>
/// </summary>
public class CancelFundAppMerchantTransferToQQWalletBillResponse : GetFundAppMerchantTransferToQQWalletBillByOutBillNumberResponse
{
}
}

View File

@@ -0,0 +1,76 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills 接口的请求。</para>
/// </summary>
[WechatTenpaySensitive]
public class CreateFundAppMerchantTransferToQQWalletBillRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置 QQ 互联开放平台 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]
public string OutBillNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置转账金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_amount")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_amount")]
public int TransferAmount { get; set; }
/// <summary>
/// 获取或设置转账备注。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_remark")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_remark")]
public string TransferRemark { get; set; } = string.Empty;
/// <summary>
/// 获取或设置收款用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string? OpenId { get; set; }
/// <summary>
/// 获取或设置收款用户 QQ 号。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_qq")]
[System.Text.Json.Serialization.JsonPropertyName("user_qq")]
public string? UserQQ { get; set; }
/// <summary>
/// 获取或设置收款用户姓名(需使用平台公钥/证书加密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_name")]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)]
public string? UserName { get; set; }
/// <summary>
/// 获取或设置转账场景 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_scene_id")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_scene_id")]
public string? TransferSceneId { get; set; }
/// <summary>
/// 获取或设置通知地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("notify_url")]
[System.Text.Json.Serialization.JsonPropertyName("notify_url")]
public string? NotifyUrl { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills 接口的响应。</para>
/// </summary>
public class CreateFundAppMerchantTransferToQQWalletBillResponse : GetFundAppMerchantTransferToQQWalletBillByOutBillNumberResponse
{
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no} 接口的请求。</para>
/// </summary>
public class GetFundAppMerchantTransferToQQWalletBillByOutBillNumberRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string OutBillNumber { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,108 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no} 接口的响应。</para>
/// </summary>
[WechatTenpaySensitive]
public class GetFundAppMerchantTransferToQQWalletBillByOutBillNumberResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置微信商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("mchid")]
[System.Text.Json.Serialization.JsonPropertyName("mchid")]
public string MerchantId { get; set; } = default!;
/// <summary>
/// 获取或设置 QQ 互联开放平台 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = default!;
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]
public string OutBillNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信转账单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_bill_no")]
public string TransferBillNumber { get; set; } = default!;
/// <summary>
/// 获取或设置单据状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("state")]
[System.Text.Json.Serialization.JsonPropertyName("state")]
public string State { get; set; } = default!;
/// <summary>
/// 获取或设置转账金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_amount")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_amount")]
public int TransferAmount { get; set; }
/// <summary>
/// 获取或设置转账备注。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_remark")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_remark")]
public string TransferRemark { get; set; } = default!;
/// <summary>
/// 获取或设置收款用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string? OpenId { get; set; }
/// <summary>
/// 获取或设置收款用户 QQ 号。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_qq")]
[System.Text.Json.Serialization.JsonPropertyName("user_qq")]
public string? UserQQ { get; set; }
/// <summary>
/// 获取或设置收款用户姓名(需使用商户私钥解密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_name")]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)]
public string? UserName { get; set; }
/// <summary>
/// 获取或设置单据创建时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置单据更新时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("update_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("update_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset UpdateTime { get; set; }
/// <summary>
/// 获取或设置失败原因。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_reason")]
[System.Text.Json.Serialization.JsonPropertyName("fail_reason")]
public string? FailReason { get; set; }
}
}