diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinSchoolExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinSchoolExtensions.cs index 71dd871a..315b50ec 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinSchoolExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinSchoolExtensions.cs @@ -94,7 +94,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Work } #region User - /// /// 异步调用 [GET] /cgi-bin/school/user/get 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/92337 @@ -639,5 +638,47 @@ namespace SKIT.FlurlHttpClient.Wechat.Work return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } #endregion + + #region Payment + /// + /// 异步调用 [POST] /cgi-bin/school/get_payment_result 接口。 + /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94470 + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinSchoolGetPaymentResultAsync(this WechatWorkClient client, Models.CgibinSchoolGetPaymentResultRequest 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, "cgi-bin", "school", "get_payment_result") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/school/get_trade 接口。 + /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94471 + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinSchoolGetTradeAsync(this WechatWorkClient client, Models.CgibinSchoolGetTradeRequest 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, "cgi-bin", "school", "get_trade") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + #endregion } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetPaymentResultRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetPaymentResultRequest.cs new file mode 100644 index 00000000..a38a354e --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetPaymentResultRequest.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/school/get_payment_result 接口的请求。 + /// + public class CgibinSchoolGetPaymentResultRequest : WechatWorkRequest + { + /// + /// 获取或设置收款项目 ID。 + /// + [Newtonsoft.Json.JsonProperty("payment_id")] + [System.Text.Json.Serialization.JsonPropertyName("payment_id")] + public string PaymentId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetPaymentResultResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetPaymentResultResponse.cs new file mode 100644 index 00000000..b701f0c6 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetPaymentResultResponse.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/school/get_payment_result 接口的响应。 + /// + public class CgibinSchoolGetPaymentResultResponse : WechatWorkResponse + { + public static class Types + { + public class PaymentResult + { + /// + /// 获取或设置学生账号。 + /// + [Newtonsoft.Json.JsonProperty("student_userid")] + [System.Text.Json.Serialization.JsonPropertyName("student_userid")] + public string StudentUserId { get; set; } = default!; + + /// + /// 获取或设置家长账号。 + /// + [Newtonsoft.Json.JsonProperty("payer_parent_userid")] + [System.Text.Json.Serialization.JsonPropertyName("payer_parent_userid")] + public string? ParentUserId { get; set; } + + /// + /// 获取或设置付款状态。 + /// + [Newtonsoft.Json.JsonProperty("trade_state")] + [System.Text.Json.Serialization.JsonPropertyName("trade_state")] + public int TradeState { get; set; } + + /// + /// 获取或设置订单号。 + /// + [Newtonsoft.Json.JsonProperty("trade_no")] + [System.Text.Json.Serialization.JsonPropertyName("trade_no")] + public string TradeNumber { get; set; } = default!; + } + } + + /// + /// 获取或设置收款项目名称。 + /// + [Newtonsoft.Json.JsonProperty("project_name")] + [System.Text.Json.Serialization.JsonPropertyName("project_name")] + public string ProjectName { get; set; } = default!; + + /// + /// 获取或设置收款金额(单位:分)。 + /// + [Newtonsoft.Json.JsonProperty("amount")] + [System.Text.Json.Serialization.JsonPropertyName("amount")] + public int Amount { get; set; } + + /// + /// 获取或设置付款结果列表。 + /// + [Newtonsoft.Json.JsonProperty("payment_result")] + [System.Text.Json.Serialization.JsonPropertyName("payment_result")] + public Types.PaymentResult[] PaymentResultList { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetTradeRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetTradeRequest.cs new file mode 100644 index 00000000..0fb48f66 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetTradeRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/school/get_trade 接口的请求。 + /// + public class CgibinSchoolGetTradeRequest : WechatWorkRequest + { + /// + /// 获取或设置收款项目 ID。 + /// + [Newtonsoft.Json.JsonProperty("payment_id")] + [System.Text.Json.Serialization.JsonPropertyName("payment_id")] + public string PaymentId { get; set; } = string.Empty; + + /// + /// 获取或设置订单号。 + /// + [Newtonsoft.Json.JsonProperty("trade_no")] + [System.Text.Json.Serialization.JsonPropertyName("trade_no")] + public string TradeNumber { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetTradeResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetTradeResponse.cs new file mode 100644 index 00000000..beeefeab --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinSchool/Payment/CgibinSchoolGetTradeResponse.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/school/get_trade 接口的响应。 + /// + public class CgibinSchoolGetTradeResponse : WechatWorkResponse + { + /// + /// 获取或设置微信交易单号。 + /// + [Newtonsoft.Json.JsonProperty("transaction_id")] + [System.Text.Json.Serialization.JsonPropertyName("transaction_id")] + public string TransactionId { get; set; } = default!; + + /// + /// 获取或设置交易时间戳。 + /// + [Newtonsoft.Json.JsonProperty("pay_time")] + [System.Text.Json.Serialization.JsonPropertyName("pay_time")] + public long PayTimestamp { get; set; } + } +}