feat(tenpayv2): 新增拉取订单评价数据接口

This commit is contained in:
Fu Diwei 2023-04-03 22:12:22 +08:00
parent 019e77fccd
commit a903743a77
4 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,30 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2
{
public static class WechatTenpayClientExecuteBillCommentExtensions
{
/// <summary>
/// <para>异步调用 [POST] /billcommentsp/batchquerycomment 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_17 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.BatchQueryBillCommentResponse> ExecuteBatchQueryBillCommentAsync(this WechatTenpayClient client, Models.BatchQueryBillCommentRequest 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, "billcommentsp", "batchquerycomment");
return await client.SendRequestWithXmlAsync<Models.BatchQueryBillCommentResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}

View File

@ -0,0 +1,66 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
/// <summary>
/// <para>表示 [POST] /billcommentsp/batchquerycomment 接口的请求。</para>
/// </summary>
public class BatchQueryBillCommentRequest : WechatTenpaySignableRequest
{
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("mch_id")]
[System.Text.Json.Serialization.JsonPropertyName("mch_id")]
public override string? MerchantId { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public override string? AppId { get; set; }
/// <summary>
/// <inheritdoc/>
/// <para>默认值:<see cref="Constants.SignTypes.HMAC_SHA256"/></para>
/// </summary>
[Newtonsoft.Json.JsonProperty("sign_type")]
[System.Text.Json.Serialization.JsonPropertyName("sign_type")]
#pragma warning disable CS8765
public override string SignType { get; set; } = Constants.SignTypes.HMAC_SHA256;
#pragma warning restore CS8765
/// <summary>
/// 获取或设置开始时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("begin_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.PureDigitalTextDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("begin_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.PureDigitalTextDateTimeOffsetConverter))]
public DateTimeOffset BeginTime { get; set; }
/// <summary>
/// 获取或设置结束时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("end_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.PureDigitalTextDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("end_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.PureDigitalTextDateTimeOffsetConverter))]
public DateTimeOffset EndTime { get; set; }
/// <summary>
/// 获取或设置分页起始位置。
/// </summary>
[Newtonsoft.Json.JsonProperty("offset")]
[System.Text.Json.Serialization.JsonPropertyName("offset")]
public int Offset { get; set; }
/// <summary>
/// 获取或设置分页每页数量。
/// </summary>
[Newtonsoft.Json.JsonProperty("limit")]
[System.Text.Json.Serialization.JsonPropertyName("limit")]
public int? Limit { get; set; }
}
}

View File

@ -0,0 +1,27 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
/// <summary>
/// <para>表示 [POST] /billcommentsp/batchquerycomment 接口的响应。</para>
/// </summary>
public class BatchQueryBillCommentResponse : WechatTenpayResponse
{
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public override string? MerchantId { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public override string? AppId { get; set; }
public override bool IsSuccessful()
{
return base.IsSuccessful() && RawBytes?.Length > 0;
}
}
}

View File

@ -0,0 +1,11 @@
{
"appid": "wxe062425f740c30d8",
"mch_id": "1900000109",
"nonce_str": "5K8264ILTKCH16CQ2502SI8ZNMTM67VS",
"offset": 0,
"limit": 100,
"begin_time": "20170724000000",
"end_time": "20170725000000",
"sign_type": "HMAC-SHA256",
"sign": "3AE1368BD96B4644FA5823E024CFE938F1B852EFA87919EDDEE324AE24C8C04F"
}