diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaGameExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaGameExtensions.cs index b69c0e78..7b4a7a89 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaGameExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaGameExtensions.cs @@ -68,7 +68,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步调用 [POST] /wxa/game/getbalance 接口。 /// /// REF:
- /// + ///
+ /// ///
/// /// @@ -96,7 +97,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步调用 [POST] /wxa/game/pay 接口。 /// /// REF:
- /// + ///
+ /// ///
/// /// @@ -124,7 +126,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步调用 [POST] /wxa/game/cancelpay 接口。 /// /// REF:
- /// + ///
+ /// ///
/// /// @@ -152,7 +155,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步调用 [POST] /wxa/game/present 接口。 /// /// REF:
- /// + ///
+ /// ///
/// /// @@ -175,5 +179,33 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// 异步调用 [POST] /wxa/game/queryorderinfo 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteWxaGameQueryOrderInfoAsync(this WechatApiClient client, Models.WxaGameQueryOrderInfoRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + PreprocessRequest(client, ref request); + + IFlurlRequest flurlReq = client + .CreateFlurlRequest(request, HttpMethod.Post, "wxa", "game", "queryorderinfo") + .SetQueryParam("access_token", request.AccessToken) + .SetQueryParam("sig_method", request.SignMethod) + .SetQueryParam("signature", request.Signature) + .SetQueryParam("pay_sig", request.PaySign); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaGame/WxaGameQueryOrderInfoRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaGame/WxaGameQueryOrderInfoRequest.cs new file mode 100644 index 00000000..00a167bf --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaGame/WxaGameQueryOrderInfoRequest.cs @@ -0,0 +1,27 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/game/queryorderinfo 接口的请求。 + /// + public class WxaGameQueryOrderInfoRequest : WxaGameRequestBase, IInferable + { + /// + /// 获取或设置外部订单号。 + /// + [Newtonsoft.Json.JsonProperty("out_trade_no")] + [System.Text.Json.Serialization.JsonPropertyName("out_trade_no")] + public string OutTradeNumber { get; set; } = string.Empty; + + /// + /// 获取或设置业务类型。 + /// + [Newtonsoft.Json.JsonProperty("biz_id")] + [System.Text.Json.Serialization.JsonPropertyName("biz_id")] + public int BusinessType { get; set; } + + protected internal override string GetRequestPath() + { + return "/wxa/game/queryorderinfo"; + } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaGame/WxaGameQueryOrderInfoResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaGame/WxaGameQueryOrderInfoResponse.cs new file mode 100644 index 00000000..901a2bc5 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaGame/WxaGameQueryOrderInfoResponse.cs @@ -0,0 +1,57 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/game/queryorderinfo 接口的响应。 + /// + public class WxaGameQueryOrderInfoResponse : WechatApiResponse + { + /// + /// 获取或设置道具 ID。 + /// + [Newtonsoft.Json.JsonProperty("product_id")] + [System.Text.Json.Serialization.JsonPropertyName("product_id")] + public string ProductId { get; set; } = default!; + + /// + /// 获取或设置外部订单号。 + /// + [Newtonsoft.Json.JsonProperty("out_trade_no")] + [System.Text.Json.Serialization.JsonPropertyName("out_trade_no")] + public string OutTradeNumber { get; set; } = default!; + + /// + /// 获取或设置微信支付商户单号。 + /// + [Newtonsoft.Json.JsonProperty("mch_order_no")] + [System.Text.Json.Serialization.JsonPropertyName("mch_order_no")] + public string? MerchantOrderNumber { get; set; } + + /// + /// 获取或设置微信支付订单号。 + /// + [Newtonsoft.Json.JsonProperty("transaction_id")] + [System.Text.Json.Serialization.JsonPropertyName("transaction_id")] + public string? TransactionId { get; set; } = default!; + + /// + /// 获取或设置支付状态。 + /// + [Newtonsoft.Json.JsonProperty("pay_state")] + [System.Text.Json.Serialization.JsonPropertyName("pay_state")] + public int PayState { get; set; } + + /// + /// 获取或设置发货状态。 + /// + [Newtonsoft.Json.JsonProperty("deliver_state")] + [System.Text.Json.Serialization.JsonPropertyName("deliver_state")] + public int DeliverState { get; set; } + + /// + /// 获取或设置支付完成时间戳。 + /// + [Newtonsoft.Json.JsonProperty("pay_finish_time")] + [System.Text.Json.Serialization.JsonPropertyName("pay_finish_time")] + public long? PayFinishTimestamp { get; set; } + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaGame/WxaGameQueryOrderInfoRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaGame/WxaGameQueryOrderInfoRequest.json new file mode 100644 index 00000000..12533391 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaGame/WxaGameQueryOrderInfoRequest.json @@ -0,0 +1,8 @@ +{ + "openid": "oUrsfxxxxxxxxxx", + "ts": 1668512806, + "env": 0, + "out_trade_no": "test_queryorderinfo_1668512806", + "offer_id": "xxxx", + "biz_id": 1 +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaGame/WxaGameQueryOrderInfoResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaGame/WxaGameQueryOrderInfoResponse.json new file mode 100644 index 00000000..1ff8ac31 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaGame/WxaGameQueryOrderInfoResponse.json @@ -0,0 +1,11 @@ +{ + "errcode": 0, + "errmsg": "ok", + "out_trade_no": "test_queryorderinfo_1668512806", + "pay_finish_time": 1669364790, + "product_id": "id_100001", + "deliver_state": 1, + "pay_state": 1, + "mch_order_no": "1217752501201407033233368018", + "transaction_id": "1217752501201407033233368018" +}