feat(tenpayv3): 新增连锁品牌门店相关接口

This commit is contained in:
Fu Diwei
2023-08-11 18:07:55 +08:00
parent 65970c98e4
commit a69769648a
20 changed files with 664 additions and 2 deletions

View File

@@ -0,0 +1,107 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
public static class WechatTenpayClientExecuteMerchantStoreExtensions
{
/// <summary>
/// <para>异步调用 [POST] /merchant-store/stores 接口。</para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateMerchantStoreResponse> ExecuteCreateMerchantStoreAsync(this WechatTenpayClient client, Models.CreateMerchantStoreRequest 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, "merchant-store", "stores");
return await client.SendRequestWithJsonAsync<Models.CreateMerchantStoreResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /merchant-store/stores/{store_id} 接口。</para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetMerchantStoreByStoreIdResponse> ExecuteGetMerchantStoreByStoreIdAsync(this WechatTenpayClient client, Models.GetMerchantStoreByStoreIdRequest 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, "merchant-store", "stores", request.StoreId);
if (request.SubMerchantId != null)
flurlReq.SetQueryParam("sub_mchid", request.SubMerchantId);
return await client.SendRequestWithJsonAsync<Models.GetMerchantStoreByStoreIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [PATCH] /merchant-store/stores/{store_id} 接口。</para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ModifyMerchantStoreResponse> ExecuteModifyMerchantStoreAsync(this WechatTenpayClient client, Models.ModifyMerchantStoreRequest 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, new HttpMethod("PATCH"), "merchant-store", "stores", request.StoreId);
return await client.SendRequestWithJsonAsync<Models.ModifyMerchantStoreResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#region
/// <summary>
/// <para>异步调用 [POST] /merchant-store/stores/{store_id}/recipients/bind 接口。</para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.BindMerchantStoreRecipientResponse> ExecuteBindMerchantStoreRecipientAsync(this WechatTenpayClient client, Models.BindMerchantStoreRecipientRequest 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, "merchant-store", "stores", request.StoreId, "recipients", "bind");
return await client.SendRequestWithJsonAsync<Models.BindMerchantStoreRecipientResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /merchant-store/stores/{store_id}/recipients/unbind 接口。</para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.UnbindMerchantStoreRecipientResponse> ExecuteUnbindMerchantStoreRecipientAsync(this WechatTenpayClient client, Models.UnbindMerchantStoreRecipientRequest 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, "merchant-store", "stores", request.StoreId, "recipients", "unbind");
return await client.SendRequestWithJsonAsync<Models.UnbindMerchantStoreRecipientResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
}
}

View File

@@ -0,0 +1,151 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /merchant-store/stores 接口的请求。</para>
/// </summary>
public class CreateMerchantStoreRequest : WechatTenpayRequest
{
public static class Types
{
public class Basic
{
/// <summary>
/// 获取或设置商家门店编号。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_reference_id")]
[System.Text.Json.Serialization.JsonPropertyName("store_reference_id")]
public string? StoreReferenceId { get; set; }
/// <summary>
/// 获取或设置品牌名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("brand_name")]
[System.Text.Json.Serialization.JsonPropertyName("brand_name")]
public string BrandName { get; set; } = string.Empty;
/// <summary>
/// 获取或设置门店名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_name")]
[System.Text.Json.Serialization.JsonPropertyName("store_name")]
public string StoreName { get; set; } = string.Empty;
/// <summary>
/// 获取或设置分店名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("branch_name")]
[System.Text.Json.Serialization.JsonPropertyName("branch_name")]
public string? BranchName { get; set; }
}
public class Address
{
/// <summary>
/// 获取或设置门店省市编码。
/// </summary>
[Newtonsoft.Json.JsonProperty("address_code")]
[System.Text.Json.Serialization.JsonPropertyName("address_code")]
public string? AddressCode { get; set; }
/// <summary>
/// 获取或设置门店地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("address_detail")]
[System.Text.Json.Serialization.JsonPropertyName("address_detail")]
public string AddressDetail { get; set; } = string.Empty;
/// <summary>
/// 获取或设置门店地址辅助描述。
/// </summary>
[Newtonsoft.Json.JsonProperty("address_complements")]
[System.Text.Json.Serialization.JsonPropertyName("address_complements")]
public string? AddressComplements { get; set; }
/// <summary>
/// 获取或设置门店经度。
/// </summary>
[Newtonsoft.Json.JsonProperty("longitude")]
[System.Text.Json.Serialization.JsonPropertyName("longitude")]
public string? Longitude { get; set; }
/// <summary>
/// 获取或设置门店纬度。
/// </summary>
[Newtonsoft.Json.JsonProperty("latitude")]
[System.Text.Json.Serialization.JsonPropertyName("latitude")]
public string? Latitude { get; set; }
}
public class Business
{
/// <summary>
/// 获取或设置门店服务电话。
/// </summary>
[Newtonsoft.Json.JsonProperty("service_phone")]
[System.Text.Json.Serialization.JsonPropertyName("service_phone")]
public string? ServicePhoneNumber { get; set; }
/// <summary>
/// 获取或设置门店经营时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("business_hours")]
[System.Text.Json.Serialization.JsonPropertyName("business_hours")]
public string? BusinessHours { get; set; }
}
public class Recipient
{
/// <summary>
/// 获取或设置门店收款商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("mchid")]
[System.Text.Json.Serialization.JsonPropertyName("mchid")]
public string MerchantId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置门店收款主体。
/// </summary>
[Newtonsoft.Json.JsonProperty("company_name")]
[System.Text.Json.Serialization.JsonPropertyName("company_name")]
public string? CompanyName { get; set; }
}
}
/// <summary>
/// 获取或设置子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
public string? SubMerchantId { get; set; }
/// <summary>
/// 获取或设置门店基础信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_basics")]
[System.Text.Json.Serialization.JsonPropertyName("store_basics")]
public Types.Basic Basic { get; set; } = new Types.Basic();
/// <summary>
/// 获取或设置门店地址信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_address")]
[System.Text.Json.Serialization.JsonPropertyName("store_address")]
public Types.Address Address { get; set; } = new Types.Address();
/// <summary>
/// 获取或设置门店经营信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_business")]
[System.Text.Json.Serialization.JsonPropertyName("store_business")]
public Types.Business Business { get; set; } = new Types.Business();
/// <summary>
/// 获取或设置门店收款信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_recipient")]
[System.Text.Json.Serialization.JsonPropertyName("store_recipient")]
public IList<Types.Recipient>? RecipientList { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /merchant-store/stores 接口的响应。</para>
/// </summary>
public class CreateMerchantStoreResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置门店 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_id")]
[System.Text.Json.Serialization.JsonPropertyName("store_id")]
public long StoreId { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /merchant-store/stores/{store_id} 接口的请求。</para>
/// </summary>
public class GetMerchantStoreByStoreIdRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置门店 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public long StoreId { get; set; }
/// <summary>
/// 获取或设置子商户号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string? SubMerchantId { get; set; }
}
}

View File

@@ -0,0 +1,55 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /merchant-store/stores/{store_id} 接口的响应。</para>
/// </summary>
public class GetMerchantStoreByStoreIdResponse : WechatTenpayResponse
{
public static class Types
{
public class Basic : CreateMerchantStoreRequest.Types.Basic
{
}
public class Address : CreateMerchantStoreRequest.Types.Address
{
}
public class Business : CreateMerchantStoreRequest.Types.Business
{
}
public class Recipient : CreateMerchantStoreRequest.Types.Recipient
{
}
}
/// <summary>
/// 获取或设置门店基础信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_basics")]
[System.Text.Json.Serialization.JsonPropertyName("store_basics")]
public Types.Basic Basic { get; set; } = default!;
/// <summary>
/// 获取或设置门店地址信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_address")]
[System.Text.Json.Serialization.JsonPropertyName("store_address")]
public Types.Address Address { get; set; } = default!;
/// <summary>
/// 获取或设置门店经营信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_business")]
[System.Text.Json.Serialization.JsonPropertyName("store_business")]
public Types.Business Business { get; set; } = default!;
/// <summary>
/// 获取或设置门店收款信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_recipient")]
[System.Text.Json.Serialization.JsonPropertyName("store_recipient")]
public Types.Recipient[] RecipientList { get; set; } = default!;
}
}

View File

@@ -0,0 +1,71 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [PATCH] /merchant-store/stores/{store_id} 接口的请求。</para>
/// </summary>
public class ModifyMerchantStoreRequest : WechatTenpayRequest
{
public static class Types
{
public class Basic : CreateMerchantStoreRequest.Types.Basic
{
}
public class Address : CreateMerchantStoreRequest.Types.Address
{
}
public class Business : CreateMerchantStoreRequest.Types.Business
{
}
public class Recipient : CreateMerchantStoreRequest.Types.Recipient
{
}
}
/// <summary>
/// 获取或设置门店 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public long StoreId { get; set; }
/// <summary>
/// 获取或设置子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
public string? SubMerchantId { get; set; }
/// <summary>
/// 获取或设置门店基础信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_basics")]
[System.Text.Json.Serialization.JsonPropertyName("store_basics")]
public Types.Basic Basic { get; set; } = new Types.Basic();
/// <summary>
/// 获取或设置门店地址信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_address")]
[System.Text.Json.Serialization.JsonPropertyName("store_address")]
public Types.Address Address { get; set; } = new Types.Address();
/// <summary>
/// 获取或设置门店经营信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_business")]
[System.Text.Json.Serialization.JsonPropertyName("store_business")]
public Types.Business Business { get; set; } = new Types.Business();
/// <summary>
/// 获取或设置门店收款信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_recipient")]
[System.Text.Json.Serialization.JsonPropertyName("store_recipient")]
public IList<Types.Recipient>? RecipientList { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [PATCH] /merchant-store/stores/{store_id} 接口的响应。</para>
/// </summary>
public class ModifyMerchantStoreResponse : WechatTenpayResponse
{
}
}

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /merchant-store/stores/{store_id}/recipients/bind 接口的请求。</para>
/// </summary>
public class BindMerchantStoreRecipientRequest : WechatTenpayRequest
{
public static class Types
{
public class Recipient : CreateMerchantStoreRequest.Types.Recipient
{
}
}
/// <summary>
/// 获取或设置门店 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public long StoreId { get; set; }
/// <summary>
/// 获取或设置子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
public string? SubMerchantId { get; set; }
/// <summary>
/// 获取或设置门店收款信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_recipient")]
[System.Text.Json.Serialization.JsonPropertyName("store_recipient")]
public IList<Types.Recipient> RecipientList { get; set; } = new List<Types.Recipient>();
}
}

View File

@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /merchant-store/stores/{store_id}/recipients/bind 接口的响应。</para>
/// </summary>
public class BindMerchantStoreRecipientResponse : WechatTenpayResponse
{
public static class Types
{
public class Recipient : BindMerchantStoreRecipientRequest.Types.Recipient
{
}
}
/// <summary>
/// 获取或设置绑定失败的门店收款信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("failed_store_recipient")]
[System.Text.Json.Serialization.JsonPropertyName("failed_store_recipient")]
public Types.Recipient[]? FailedRecipientList { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /merchant-store/stores/{store_id}/recipients/unbind 接口的请求。</para>
/// </summary>
public class UnbindMerchantStoreRecipientRequest : WechatTenpayRequest
{
public static class Types
{
public class Recipient : CreateMerchantStoreRequest.Types.Recipient
{
}
}
/// <summary>
/// 获取或设置门店 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public long StoreId { get; set; }
/// <summary>
/// 获取或设置子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
public string? SubMerchantId { get; set; }
/// <summary>
/// 获取或设置门店收款信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("store_recipient")]
[System.Text.Json.Serialization.JsonPropertyName("store_recipient")]
public IList<Types.Recipient> RecipientList { get; set; } = new List<Types.Recipient>();
}
}

View File

@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /merchant-store/stores/{store_id}/recipients/unbind 接口的响应。</para>
/// </summary>
public class UnbindMerchantStoreRecipientResponse : WechatTenpayResponse
{
public static class Types
{
public class Recipient : UnbindMerchantStoreRecipientRequest.Types.Recipient
{
}
}
/// <summary>
/// 获取或设置解绑失败的门店收款信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("failed_store_recipient")]
[System.Text.Json.Serialization.JsonPropertyName("failed_store_recipient")]
public Types.Recipient[]? FailedRecipientList { get; set; }
}
}

View File

@@ -1,5 +1,3 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
/// <summary>

View File

@@ -0,0 +1,26 @@
{
"sub_mchid": "1900000109",
"store_basics": {
"store_reference_id": "",
"brand_name": "",
"store_name": "",
"branch_name": ""
},
"store_address": {
"address_code": "440305",
"address_detail": "",
"address_complements": "",
"longitude": "",
"latitude": ""
},
"store_business": {
"service_phone": "0755-86013388",
"business_hours": "周一至周五 09:00-20:00|周六至周日 10:00-22:00"
},
"store_recipient": [
{
"mchid": "",
"company_name": ""
}
]
}

View File

@@ -0,0 +1,25 @@
{
"store_basics": {
"store_reference_id": "",
"brand_name": "",
"store_name": "",
"branch_name": ""
},
"store_address": {
"address_code": "440305",
"address_detail": "",
"address_complements": "",
"longitude": "",
"latitude": ""
},
"store_business": {
"service_phone": "0755-86013388",
"business_hours": "周一至周五 09:00-20:00|周六至周日 10:00-22:00"
},
"store_recipient": [
{
"mchid": "",
"company_name": ""
}
]
}

View File

@@ -0,0 +1,26 @@
{
"sub_mchid": "1900000109",
"store_basics": {
"store_reference_id": "",
"brand_name": "",
"store_name": "",
"branch_name": ""
},
"store_address": {
"address_code": "440305",
"address_detail": "",
"address_complements": "",
"longitude": "",
"latitude": ""
},
"store_business": {
"service_phone": "0755-86013388",
"business_hours": "周一至周五 09:00-20:00|周六至周日 10:00-22:00"
},
"store_recipient": [
{
"mchid": "",
"company_name": ""
}
]
}

View File

@@ -0,0 +1,9 @@
{
"sub_mchid": "1900000109",
"store_recipient": [
{
"mchid": "",
"company_name": ""
}
]
}

View File

@@ -0,0 +1,8 @@
{
"failed_store_recipient": [
{
"mchid": "",
"company_name": ""
}
]
}

View File

@@ -0,0 +1,9 @@
{
"sub_mchid": "1900000109",
"store_recipient": [
{
"mchid": "",
"company_name": ""
}
]
}

View File

@@ -0,0 +1,8 @@
{
"failed_store_recipient": [
{
"mchid": "",
"company_name": ""
}
]
}