feat(tenpayv3): 新增租用充电宝隔夜归还相关接口

This commit is contained in:
Fu Diwei 2023-03-30 23:14:53 +08:00
parent bdd1ccac59
commit efea789441
12 changed files with 273 additions and 0 deletions

View File

@ -45,6 +45,7 @@
| √ | 行业方案:电商收付通 | 服务商 | |
| √ | 行业方案:智慧商圈 | 直连商户 & 服务商 | |
| √ | 行业方案:微信支付分停车服务 | 直连商户 & 服务商 | |
| √ | 行业方案:租用充电宝隔夜归还 | 直连商户 | |
| √ | 营销工具:代金券 | 直连商户 & 服务商 | |
| √ | 营销工具:商家券 | 直连商户 & 服务商 | |
| √ | 营销工具:委托营销 | 直连商户 & 服务商 | |

View File

@ -0,0 +1,72 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
/// <summary>
/// 为 <see cref="WechatTenpayClient"/> 提供租用充电宝隔夜归还相关的 API 扩展方法。
/// </summary>
public static class WechatTenpayClientExecuteHirePowerBankExtensions
{
/// <summary>
/// <para>异步调用 [POST] /hire-power-bank/insurance-orders 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/merchant/apis/hire-power-bank-insurance/insurance-orders/create-insurance-order.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHirePowerBankInsuranceOrderResponse> ExecuteCreateHirePowerBankInsuranceOrderAsync(this WechatTenpayClient client, Models.CreateHirePowerBankInsuranceOrderRequest 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, "hire-power-bank", "insurance-orders");
return await client.SendRequestWithJsonAsync<Models.CreateHirePowerBankInsuranceOrderResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /hire-power-bank/insurance-orders/{out_order_no} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/merchant/apis/hire-power-bank-insurance/insurance-orders/get-by-out-trade-no.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetHirePowerBankInsuranceOrderByOutOrderNumberResponse> ExecuteGetHirePowerBankInsuranceOrderByOutOrderNumberAsync(this WechatTenpayClient client, Models.GetHirePowerBankInsuranceOrderByOutOrderNumberRequest 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, "hire-power-bank", "insurance-orders", request.OutOrderNumber);
return await client.SendRequestWithJsonAsync<Models.GetHirePowerBankInsuranceOrderByOutOrderNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /hire-power-bank/user-qualifications/{openid} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/merchant/apis/hire-power-bank-insurance/insurance-orders/get-qualification-by-open-id.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetHirePowerBankUserQualificationByOpenIdResponse> ExecuteGetHirePowerBankUserQualificationByOpenIdAsync(this WechatTenpayClient client, Models.GetHirePowerBankUserQualificationByOpenIdRequest 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, "hire-power-bank", "user-qualifications", request.OpenId);
return await client.SendRequestWithJsonAsync<Models.GetHirePowerBankUserQualificationByOpenIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}

View File

@ -0,0 +1,36 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /hire-power-bank/insurance-orders 接口的请求。</para>
/// </summary>
public class CreateHirePowerBankInsuranceOrderRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置商户保险订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_order_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_order_no")]
public string OutOrderNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置用户的 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置回调通知地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("notify_url")]
[System.Text.Json.Serialization.JsonPropertyName("notify_url")]
public string NotifyUrl { get; set; } = string.Empty;
/// <summary>
/// 获取或设置支付分服务 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("service_id")]
[System.Text.Json.Serialization.JsonPropertyName("service_id")]
public string? ServiceId { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /hire-power-bank/insurance-orders 接口的响应。</para>
/// </summary>
public class CreateHirePowerBankInsuranceOrderResponse : GetHirePowerBankInsuranceOrderByOutOrderNumberResponse
{
}
}

View File

@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /hire-power-bank/insurance-orders/{out_order_no} 接口的请求。</para>
/// </summary>
public class GetHirePowerBankInsuranceOrderByOutOrderNumberRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置商户保险订单号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string OutOrderNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,79 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /hire-power-bank/insurance-orders/{out_order_no} 接口的响应。</para>
/// </summary>
public class GetHirePowerBankInsuranceOrderByOutOrderNumberResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置商户保险订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_order_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_order_no")]
public string OutOrderNumber { get; set; } = default!;
/// <summary>
/// 获取或设置保险订单 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("order_id")]
[System.Text.Json.Serialization.JsonPropertyName("order_id")]
public string OrderId { get; set; } = default!;
/// <summary>
/// 获取或设置用户的 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = default!;
/// <summary>
/// 获取或设置最大理赔次数。
/// </summary>
[Newtonsoft.Json.JsonProperty("max_claim_count")]
[System.Text.Json.Serialization.JsonPropertyName("max_claim_count")]
public int MaxClaimCount { get; set; }
/// <summary>
/// 获取或设置已理赔次数。
/// </summary>
[Newtonsoft.Json.JsonProperty("claimed_count")]
[System.Text.Json.Serialization.JsonPropertyName("claimed_count")]
public int ClaimedCount { get; set; }
/// <summary>
/// 获取或设置保险订单领取状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("order_receive_state")]
[System.Text.Json.Serialization.JsonPropertyName("order_receive_state")]
public string ReceiveState { get; set; } = default!;
/// <summary>
/// 获取或设置保险订单领取时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("order_receive_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("order_receive_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset ReceiveTime { get; set; }
/// <summary>
/// 获取或设置保险订单开始时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("order_begin_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("order_begin_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? BeginTime { get; set; }
/// <summary>
/// 获取或设置保险订单结束时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("order_end_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("order_end_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? EndTime { get; set; }
}
}

View File

@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /hire-power-bank/user-qualifications/{openid} 接口的请求。</para>
/// </summary>
public class GetHirePowerBankUserQualificationByOpenIdRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置用户的 OpenId。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string OpenId { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /hire-power-bank/user-qualifications/{openid} 接口的响应。</para>
/// </summary>
public class GetHirePowerBankUserQualificationByOpenIdResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置是否具有领取资格。
/// </summary>
[Newtonsoft.Json.JsonProperty("qualified_user")]
[System.Text.Json.Serialization.JsonPropertyName("qualified_user")]
public bool IsQualifiedUser { get; set; }
}
}

View File

@ -0,0 +1,6 @@
{
"out_order_no": "6e8369071cd942c0476613f9d1ce9ca3",
"openid": "实例值",
"notify_url": "https://api.test.com",
"service_id": "实例值"
}

View File

@ -0,0 +1,11 @@
{
"order_id": "1234323JKHDFE1243252",
"out_order_no": "6e8369071cd942c0476613f9d1ce9ca3",
"openid": "2323dfsdf342342",
"max_claim_count": 3,
"claimed_count": 1,
"order_receive_time": "2015-05-20T13:29:35.120+08:00",
"order_begin_time": "2015-05-20T13:29:35.120+08:00",
"order_end_time": "2015-05-20T13:29:35.120+08:00",
"order_receive_state": "RECEIVING"
}

View File

@ -0,0 +1,11 @@
{
"order_id": "1234323JKHDFE1243252",
"out_order_no": "6e8369071cd942c0476613f9d1ce9ca3",
"openid": "2323dfsdf342342",
"max_claim_count": 3,
"claimed_count": 1,
"order_receive_time": "2015-05-20T13:29:35.120+08:00",
"order_begin_time": "2015-05-20T13:29:35.120+08:00",
"order_end_time": "2015-05-20T13:29:35.120+08:00",
"order_receive_state": "RECEIVING"
}