diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Extensions/WechatTenpayClientExecutePayScoreBillExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Extensions/WechatTenpayClientExecutePayScoreBillExtensions.cs new file mode 100644 index 00000000..fde4cca8 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Extensions/WechatTenpayClientExecutePayScoreBillExtensions.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Flurl; +using Flurl.Http; + +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3 +{ + /// + /// 为 提供微信支付分账单相关的 API 扩展方法。 + /// + public static class WechatTenpayClientExecutePayScoreBillExtensions + { + /// + /// 异步调用 [GET] /payscore/merchant-bill 接口。 + /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_29.shtml + /// + /// + /// + /// + /// + public static async Task ExecuteGetPayScoreMerchantBillAsync(this WechatTenpayClient client, Models.GetPayScoreMerchantBillRequest 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, "payscore", "merchant-bill") + .SetQueryParam("bill_date", request.BillDateString) + .SetQueryParam("algorithm", request.Algorithm) + .SetQueryParam("tar_type", request.TarType) + .SetQueryParam("algorithm", request.Algorithm); + + if (!string.IsNullOrEmpty(request.TarType)) + flurlReq.SetQueryParam("tar_type", request.TarType); + + return await client.SendRequestWithJsonAsync(flurlReq, cancellationToken: cancellationToken); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/EcommerceBill/GetEcommerceBillFundflowBillRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/EcommerceBill/GetEcommerceBillFundflowBillRequest.cs index c410bc93..0b1cf950 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/EcommerceBill/GetEcommerceBillFundflowBillRequest.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/EcommerceBill/GetEcommerceBillFundflowBillRequest.cs @@ -32,6 +32,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models /// /// 获取或设置加密算法。 + /// 默认值: /// [Newtonsoft.Json.JsonIgnore] [System.Text.Json.Serialization.JsonIgnore] diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/PayScoreBill/GetPayScoreMerchantBillRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/PayScoreBill/GetPayScoreMerchantBillRequest.cs new file mode 100644 index 00000000..e0b2f3b7 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/PayScoreBill/GetPayScoreMerchantBillRequest.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [GET] /payscore/merchant-bill 接口的请求。 + /// + public class GetPayScoreMerchantBillRequest : WechatTenpayRequest + { + /// + /// 获取或设置账单日期(格式:yyyy-MM-dd)。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string BillDateString { get; set; } = string.Empty; + + /// + /// 获取或设置服务 ID。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string ServiceId { get; set; } = string.Empty; + + /// + /// 获取或设置压缩类型。 + /// 默认值:GZIP + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string TarType { get; set; } = "GZIP"; + + /// + /// 获取或设置加密算法。 + /// 默认值: + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string Algorithm { get; set; } = Constants.EncryptionAlgorithms.AEAD_AES_256_GCM; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/PayScoreBill/GetPayScoreMerchantBillResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/PayScoreBill/GetPayScoreMerchantBillResponse.cs new file mode 100644 index 00000000..36d3a61a --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.TenpayV3/Models/PayScoreBill/GetPayScoreMerchantBillResponse.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models +{ + /// + /// 表示 [GET] /payscore/merchant-bill 接口的响应。 + /// + public class GetPayScoreMerchantBillResponse : WechatTenpayResponse + { + public static class Types + { + public class DownloadBill + { + /// + /// 获取或设置账单文件序号。 + /// + [Newtonsoft.Json.JsonProperty("bill_sequence")] + [System.Text.Json.Serialization.JsonPropertyName("bill_sequence")] + public int BillSequence { get; set; } + + /// + /// 获取或设置哈希类型。 + /// + [Newtonsoft.Json.JsonProperty("hash_type")] + [System.Text.Json.Serialization.JsonPropertyName("hash_type")] + public string HashType { get; set; } = default!; + + /// + /// 获取或设置哈希值。 + /// + [Newtonsoft.Json.JsonProperty("hash_value")] + [System.Text.Json.Serialization.JsonPropertyName("hash_value")] + public string HashValue { get; set; } = default!; + + /// + /// 获取或设置账单下载地址。 + /// + [Newtonsoft.Json.JsonProperty("download_url")] + [System.Text.Json.Serialization.JsonPropertyName("download_url")] + public string DownloadUrl { get; set; } = default!; + + /// + /// 获取或设置账单加密密钥(需使用商户私钥解密)。 + /// + [Newtonsoft.Json.JsonProperty("encrypt_key")] + [System.Text.Json.Serialization.JsonPropertyName("encrypt_key")] + public string EncryptKey { get; set; } = default!; + + /// + /// 获取或设置账单加密使用的随机字符串。 + /// + [Newtonsoft.Json.JsonProperty("nonce")] + [System.Text.Json.Serialization.JsonPropertyName("nonce")] + public string Nonce { get; set; } = default!; + } + } + + /// + /// 获取或设置下载信息总数。 + /// + [Newtonsoft.Json.JsonProperty("download_bill_count")] + [System.Text.Json.Serialization.JsonPropertyName("download_bill_count")] + public int DownloadBillCount { get; set; } + + /// + /// 获取或设置下载信息明细列表。 + /// + [Newtonsoft.Json.JsonProperty("download_bill_list")] + [System.Text.Json.Serialization.JsonPropertyName("download_bill_list")] + public Types.DownloadBill[] DownloadBillList { get; set; } = default!; + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/PayScoreBill/GetPayScoreMerchantBillRequest.json b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/PayScoreBill/GetPayScoreMerchantBillRequest.json new file mode 100644 index 00000000..22fdca1b --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/PayScoreBill/GetPayScoreMerchantBillRequest.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/PayScoreBill/GetPayScoreMerchantBillResponse.json b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/PayScoreBill/GetPayScoreMerchantBillResponse.json new file mode 100644 index 00000000..30d2555e --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/ModelSamples/PayScoreBill/GetPayScoreMerchantBillResponse.json @@ -0,0 +1,13 @@ +{ + "download_bill_count": 1, + "download_bill_list": [ + { + "bill_sequence": 1, + "download_url": "https://api.mch.weixin.qq.com/v3/payscore/bill/downloadurl?token=xxx", + "encrypt_key": "a0YK7p+9XaKzE9N4qtFfG/9za1oqKlLXXJWBkH+kX84onAs2Ol/E1fk+6S+FuBXczGDRU8I8D+6PfbwKYBGm0wANUTqHOSezzfbieIo2t51UIId7sP9SoN38W2+IcYDviIsu59KSdyiL3TY2xqZNT8UDcnMWzTNZdSv+CLsSgblB6OKGN9JONTadOFGfv1OKkTp86Li+X7S9bG62wsa572/5Rm4MmDCiKwY4bX2EynWQHBEOExD5URxT6/MX3F1D3BNYrE4fUu1F03k25xVlXnZDjksy6Rf3SCgadR+Cepc6mdfF9b2gTxNsJFMEdYXbqL0W1WQZ3UqSPQCguK6uLA==", + "hash_type": "SHA1", + "hash_value": "79bb0f45fc4c42234a918000b2668d689e2bde04", + "nonce": "5K8264ILTKCH16CQ2502SI8ZNMTM67VS" + } + ] +} \ No newline at end of file