From 9171c12acf23dbd74e0b026fe8f10b8e15789311 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Mon, 20 Jun 2022 10:49:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E6=96=B0=E5=A2=9E=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=94=AF=E4=BB=98=E7=AE=A1=E7=90=86=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E9=80=80=E6=AC=BE=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WechatApiClientExecuteShopExtensions.cs | 23 ++++++++ .../Shop/Pay/ShopPayRefundOrderRequest.cs | 57 +++++++++++++++++++ .../Shop/Pay/ShopPayRefundOrderResponse.cs | 9 +++ .../Shop/Pay/ShopPayRefundOrderRequest.json | 9 +++ 4 files changed, 98 insertions(+) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Shop/Pay/ShopPayRefundOrderRequest.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteShopExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteShopExtensions.cs index e6e639c0..0dd5c1b1 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteShopExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteShopExtensions.cs @@ -1510,6 +1510,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// /// 异步调用 [POST] /shop/funds/submitwithdraw 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent2/API/funds/submitwithdraw.html + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/funds/submitwithdraw.html /// /// /// @@ -1530,6 +1531,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// /// 异步调用 [POST] /shop/funds/scanwithdraw 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent2/API/funds/scanwithdraw.html + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/funds/scanwithdraw.html /// /// /// @@ -1550,6 +1552,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// /// 异步调用 [POST] /shop/funds/getwithdrawdetail 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent2/API/funds/getwithdrawdetail.html + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/funds/getwithdrawdetail.html /// /// /// @@ -1930,6 +1933,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + + /// + /// 异步调用 [POST] /shop/pay/refundorder 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/order/refunds_order.html + /// + /// + /// + /// + /// + public static async Task ExecuteShopPayRefundOrderAsync(this WechatApiClient client, Models.ShopPayRefundOrderRequest 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, "shop", "pay", "refundorder") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } #endregion } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderRequest.cs new file mode 100644 index 00000000..34652284 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderRequest.cs @@ -0,0 +1,57 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /shop/pay/refundorder 接口的请求。 + /// + public class ShopPayRefundOrderRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置微信商户号。 + /// + [Newtonsoft.Json.JsonProperty("mchid")] + [System.Text.Json.Serialization.JsonPropertyName("mchid")] + public string MerchantId { get; set; } = string.Empty; + + /// + /// 获取或设置用户的 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("openid")] + [System.Text.Json.Serialization.JsonPropertyName("openid")] + public string OpenId { get; set; } = string.Empty; + + /// + /// 获取或设置商户订单号。 + /// + [Newtonsoft.Json.JsonProperty("trade_no")] + [System.Text.Json.Serialization.JsonPropertyName("trade_no")] + public string? OutTradeNumber { get; set; } + + /// + /// 获取或设置微信支付交易单号。 + /// + [Newtonsoft.Json.JsonProperty("transaction_id")] + [System.Text.Json.Serialization.JsonPropertyName("transaction_id")] + public string? TransactionId { get; set; } + + /// + /// 获取或设置商户退款单号。 + /// + [Newtonsoft.Json.JsonProperty("refund_no")] + [System.Text.Json.Serialization.JsonPropertyName("refund_no")] + public string OutRefundNumber { get; set; } = string.Empty; + + /// + /// 获取或设置订单总金额(单位:分)。 + /// + [Newtonsoft.Json.JsonProperty("total_amount")] + [System.Text.Json.Serialization.JsonPropertyName("total_amount")] + public int TotalAmount { get; set; } + + /// + /// 获取或设置退款金额(单位:分)。 + /// + [Newtonsoft.Json.JsonProperty("refund_amount")] + [System.Text.Json.Serialization.JsonPropertyName("refund_amount")] + public int RefundAmount { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderResponse.cs new file mode 100644 index 00000000..54cbe73f --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Shop/Pay/ShopPayRefundOrderResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /shop/pay/refundorder 接口的响应。 + /// + public class ShopPayRefundOrderResponse : WechatApiResponse + { + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Shop/Pay/ShopPayRefundOrderRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Shop/Pay/ShopPayRefundOrderRequest.json new file mode 100644 index 00000000..ec26abaa --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Shop/Pay/ShopPayRefundOrderRequest.json @@ -0,0 +1,9 @@ +{ + "openid": "oTVP50O53a7jgmawAmxKukNlq3XI", + "mchid": "1230000109", + "trade_no": "1217752501201407033233368018", + "transaction_id": "4208450740201411110007820472", + "refund_no": "1217752501201407033233368018", + "total_amount": 100, + "refund_amount": 50 +}