refactor(tenpayv2): 优化反射性能

This commit is contained in:
Fu Diwei
2024-02-01 20:09:15 +08:00
committed by RHQYZ
parent 5eed125d49
commit 1eef179f0a
12 changed files with 848 additions and 513 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Reflection;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
@@ -113,15 +114,19 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
internal static class Converters
{
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase<QueryMerchantCustomsCustomDeclarationResponse>
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.Internal.FlattenNArrayObjectConverterBase<QueryMerchantCustomsCustomDeclarationResponse, Types.Record>
{
protected override PropertyInfo FlattenProperty => QueryMerchantCustomsCustomDeclarationResponse._flattenProperty;
}
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Converters.FlattenNArrayObjectConverterBase<QueryMerchantCustomsCustomDeclarationResponse>
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Serialization.Internal.FlattenNArrayObjectConverterBase<QueryMerchantCustomsCustomDeclarationResponse, Types.Record>
{
protected override PropertyInfo FlattenProperty => QueryMerchantCustomsCustomDeclarationResponse._flattenProperty;
}
}
private readonly static PropertyInfo _flattenProperty = typeof(QueryMerchantCustomsCustomDeclarationResponse).GetProperty(nameof(RecordList), BindingFlags.Instance | BindingFlags.Public)!;
/// <summary>
/// <inheritdoc/>
/// </summary>
@@ -154,8 +159,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
/// <summary>
/// 获取或设置记录列表。
/// </summary>
[Newtonsoft.Json.JsonProperty(Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[System.Text.Json.Serialization.JsonPropertyName(System.Text.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[Newtonsoft.Json.JsonProperty(Converters.ResponseClassNewtonsoftJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
[System.Text.Json.Serialization.JsonPropertyName(Converters.ResponseClassSystemTextJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
public Types.Record[] RecordList { get; set; } = default!;
/// <summary>

View File

@@ -1,3 +1,5 @@
using System.Reflection;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
/// <summary>
@@ -9,7 +11,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
public static class Types
{
public class Coupon
public class RefundCoupon
{
/// <summary>
/// 获取或设置代金券 ID。
@@ -36,15 +38,19 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
internal static class Converters
{
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase<CreatePayRefundResponse>
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.Internal.FlattenNArrayObjectConverterBase<CreatePayRefundResponse, Types.RefundCoupon>
{
protected override PropertyInfo FlattenProperty => CreatePayRefundResponse._flattenProperty;
}
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Converters.FlattenNArrayObjectConverterBase<CreatePayRefundResponse>
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Serialization.Internal.FlattenNArrayObjectConverterBase<CreatePayRefundResponse, Types.RefundCoupon>
{
protected override PropertyInfo FlattenProperty => CreatePayRefundResponse._flattenProperty;
}
}
private readonly static PropertyInfo _flattenProperty = typeof(CreatePayRefundResponse).GetProperty(nameof(CouponRefundList), BindingFlags.Instance | BindingFlags.Public)!;
/// <summary>
/// <inheritdoc/>
/// </summary>
@@ -167,9 +173,9 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
/// <summary>
/// 获取或设置代金券退款列表。
/// </summary>
[Newtonsoft.Json.JsonProperty(Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[System.Text.Json.Serialization.JsonPropertyName(System.Text.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
public Types.Coupon[]? CouponRefundList { get; set; }
[Newtonsoft.Json.JsonProperty(Converters.ResponseClassNewtonsoftJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
[System.Text.Json.Serialization.JsonPropertyName(Converters.ResponseClassSystemTextJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
public Types.RefundCoupon[]? CouponRefundList { get; set; }
/// <summary>
/// 获取或设置现金支付金额(单位:分)。

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
@@ -227,15 +228,19 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
internal static class Converters
{
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase<GetPayOrderResponse>
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.Internal.FlattenNArrayObjectConverterBase<GetPayOrderResponse, Types.Coupon>
{
protected override PropertyInfo FlattenProperty => GetPayOrderResponse._flattenProperty;
}
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Converters.FlattenNArrayObjectConverterBase<GetPayOrderResponse>
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Serialization.Internal.FlattenNArrayObjectConverterBase<GetPayOrderResponse, Types.Coupon>
{
protected override PropertyInfo FlattenProperty => GetPayOrderResponse._flattenProperty;
}
}
private readonly static PropertyInfo _flattenProperty = typeof(GetPayOrderResponse).GetProperty(nameof(CouponList), BindingFlags.Instance | BindingFlags.Public)!;
/// <summary>
/// <inheritdoc/>
/// </summary>
@@ -381,8 +386,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
/// <summary>
/// 获取或设置代金券使用列表。
/// </summary>
[Newtonsoft.Json.JsonProperty(Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[System.Text.Json.Serialization.JsonPropertyName(System.Text.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[Newtonsoft.Json.JsonProperty(Converters.ResponseClassNewtonsoftJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
[System.Text.Json.Serialization.JsonPropertyName(Converters.ResponseClassSystemTextJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
public Types.Coupon[]? CouponList { get; set; }
/// <summary>
@@ -447,9 +452,5 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
[System.Text.Json.Serialization.JsonPropertyName("promotion_detail")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.StringifiedObjectInJsonFormatConverter))]
public Types.PromotionDetail? PromotionDetail { get; set; }
[Newtonsoft.Json.JsonProperty]
[Newtonsoft.Json.JsonExtensionData]
public IDictionary<string, Newtonsoft.Json.Linq.JToken>? ExtensionData { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Reflection;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
@@ -92,15 +93,19 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
internal static class Converters
{
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase<GetPayRefundResponse>
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.Internal.FlattenNArrayObjectConverterBase<GetPayRefundResponse, Types.Refund>
{
protected override PropertyInfo FlattenProperty => GetPayRefundResponse._flattenProperty;
}
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Converters.FlattenNArrayObjectConverterBase<GetPayRefundResponse>
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Serialization.Internal.FlattenNArrayObjectConverterBase<GetPayRefundResponse, Types.Refund>
{
protected override PropertyInfo FlattenProperty => GetPayRefundResponse._flattenProperty;
}
}
private readonly static PropertyInfo _flattenProperty = typeof(GetPayRefundResponse).GetProperty(nameof(RefundList), BindingFlags.Instance | BindingFlags.Public)!;
/// <summary>
/// <inheritdoc/>
/// </summary>
@@ -185,8 +190,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
/// <summary>
/// 获取或设置记录列表。
/// </summary>
[Newtonsoft.Json.JsonProperty(Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[System.Text.Json.Serialization.JsonPropertyName(System.Text.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[Newtonsoft.Json.JsonProperty(Converters.ResponseClassNewtonsoftJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
[System.Text.Json.Serialization.JsonPropertyName(Converters.ResponseClassSystemTextJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
public Types.Refund[] RefundList { get; set; } = default!;
/// <summary>

View File

@@ -1,4 +1,5 @@
using System;
using System.Reflection;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
@@ -18,15 +19,19 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
internal static class Converters
{
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase<GetTransitOrderResponse>
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.Internal.FlattenNArrayObjectConverterBase<GetTransitOrderResponse, Types.Coupon>
{
protected override PropertyInfo FlattenProperty => GetTransitOrderResponse._flattenProperty;
}
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Converters.FlattenNArrayObjectConverterBase<GetTransitOrderResponse>
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Serialization.Internal.FlattenNArrayObjectConverterBase<GetTransitOrderResponse, Types.Coupon>
{
protected override PropertyInfo FlattenProperty => GetTransitOrderResponse._flattenProperty;
}
}
private readonly static PropertyInfo _flattenProperty = typeof(GetTransitOrderResponse).GetProperty(nameof(CouponList), BindingFlags.Instance | BindingFlags.Public)!;
/// <summary>
/// <inheritdoc/>
/// </summary>
@@ -142,8 +147,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
/// <summary>
/// 获取或设置代金券使用列表。
/// </summary>
[Newtonsoft.Json.JsonProperty(Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[System.Text.Json.Serialization.JsonPropertyName(System.Text.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[Newtonsoft.Json.JsonProperty(Converters.ResponseClassNewtonsoftJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
[System.Text.Json.Serialization.JsonPropertyName(Converters.ResponseClassSystemTextJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
public Types.Coupon[]? CouponList { get; set; }
/// <summary>

View File

@@ -1,3 +1,6 @@
using System;
using System.Reflection;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
{
/// <summary>
@@ -5,7 +8,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
/// </summary>
[Newtonsoft.Json.JsonConverter(typeof(Converters.ResponseClassNewtonsoftJsonConverter))]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.ResponseClassSystemTextJsonConverter))]
public class GetTransitPartnerOrderResponse : GetTransitOrderResponse
public class GetTransitPartnerOrderResponse : WechatTenpaySignableResponse
{
public static new class Types
{
@@ -14,17 +17,43 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
}
}
internal static new class Converters
internal static class Converters
{
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase<GetTransitPartnerOrderResponse>
internal class ResponseClassNewtonsoftJsonConverter : Newtonsoft.Json.Converters.Internal.FlattenNArrayObjectConverterBase<GetTransitPartnerOrderResponse, Types.Coupon>
{
protected override PropertyInfo FlattenProperty => GetTransitPartnerOrderResponse._flattenProperty;
}
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Converters.FlattenNArrayObjectConverterBase<GetTransitPartnerOrderResponse>
internal class ResponseClassSystemTextJsonConverter : System.Text.Json.Serialization.Internal.FlattenNArrayObjectConverterBase<GetTransitPartnerOrderResponse, Types.Coupon>
{
protected override PropertyInfo FlattenProperty => GetTransitPartnerOrderResponse._flattenProperty;
}
}
private readonly static PropertyInfo _flattenProperty = typeof(GetTransitPartnerOrderResponse).GetProperty(nameof(CouponList), BindingFlags.Instance | BindingFlags.Public)!;
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("mch_id")]
[System.Text.Json.Serialization.JsonPropertyName("mch_id")]
#pragma warning disable CS8618
#pragma warning disable CS8765
public override string MerchantId { get; set; }
#pragma warning restore CS8765
#pragma warning restore CS8618
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
#pragma warning disable CS8618
#pragma warning disable CS8765
public override string AppId { get; set; }
#pragma warning restore CS8765
#pragma warning restore CS8618
/// <summary>
/// 获取或设置子商户号。
/// </summary>
@@ -39,11 +68,146 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Models
[System.Text.Json.Serialization.JsonPropertyName("sub_appid")]
public string? SubAppId { get; set; }
/// <summary>
/// 获取或设置终端设备号。
/// </summary>
[Newtonsoft.Json.JsonProperty("device_info")]
[System.Text.Json.Serialization.JsonPropertyName("device_info")]
public string? DeviceInfo { get; set; }
/// <summary>
/// 获取或设置用户唯一标识。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = default!;
/// <summary>
/// 获取或设置用户是否订阅该公众号标识。
/// </summary>
[Newtonsoft.Json.JsonProperty("is_subscribe")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Internal.YesOrNoBooleanConverter))]
[System.Text.Json.Serialization.JsonPropertyName("is_subscribe")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Internal.YesOrNoBooleanConverter))]
public bool? IsSubscribed { get; set; }
/// <summary>
/// 获取或设置交易状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("trade_state")]
[System.Text.Json.Serialization.JsonPropertyName("trade_state")]
public string TradeState { get; set; } = default!;
/// <summary>
/// 获取或设置交易状态描述。
/// </summary>
[Newtonsoft.Json.JsonProperty("trade_state_desc")]
[System.Text.Json.Serialization.JsonPropertyName("trade_state_desc")]
public string TradeStateDescription { get; set; } = default!;
/// <summary>
/// 获取或设置交易类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("trade_type")]
[System.Text.Json.Serialization.JsonPropertyName("trade_type")]
public string TradeType { get; set; } = default!;
/// <summary>
/// 获取或设置付款银行。
/// </summary>
[Newtonsoft.Json.JsonProperty("bank_type")]
[System.Text.Json.Serialization.JsonPropertyName("bank_type")]
public string BankType { get; set; } = default!;
/// <summary>
/// 获取或设置订单金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("total_fee")]
[System.Text.Json.Serialization.JsonPropertyName("total_fee")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int TotalFee { get; set; }
/// <summary>
/// 获取或设置货币类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("fee_type")]
[System.Text.Json.Serialization.JsonPropertyName("fee_type")]
public string? FeeType { get; set; }
/// <summary>
/// 获取或设置应结订单金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("settlement_total_fee")]
[System.Text.Json.Serialization.JsonPropertyName("settlement_total_fee")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int? SettlementFee { get; set; }
/// <summary>
/// 获取或设置代金券金额。
/// </summary>
[Newtonsoft.Json.JsonProperty("coupon_fee")]
[System.Text.Json.Serialization.JsonPropertyName("coupon_fee")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int? CouponFee { get; set; }
/// <summary>
/// 获取或设置代金券使用数量。
/// </summary>
[Newtonsoft.Json.JsonProperty("coupon_count")]
[System.Text.Json.Serialization.JsonPropertyName("coupon_count")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int? CouponCount { get; set; }
/// <summary>
/// 获取或设置代金券使用列表。
/// </summary>
[Newtonsoft.Json.JsonProperty(Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
[System.Text.Json.Serialization.JsonPropertyName(System.Text.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_NAME_NARRAY)]
public new Types.Coupon[]? CouponList { get; set; }
[Newtonsoft.Json.JsonProperty(Converters.ResponseClassNewtonsoftJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
[System.Text.Json.Serialization.JsonPropertyName(Converters.ResponseClassSystemTextJsonConverter.FLATTEN_PROPERTY_JSON_NAME)]
public Types.Coupon[]? CouponList { get; set; }
/// <summary>
/// 获取或设置现金支付金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("cash_fee")]
[System.Text.Json.Serialization.JsonPropertyName("cash_fee")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int? CashFee { get; set; }
/// <summary>
/// 获取或设置现金支付货币类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("cash_fee_type")]
[System.Text.Json.Serialization.JsonPropertyName("cash_fee_type")]
public string? CashFeeType { get; set; }
/// <summary>
/// 获取或设置商户订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_trade_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_trade_no")]
public string OutTradeNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信支付订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_id")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_id")]
public string TransactionId { get; set; } = default!;
/// <summary>
/// 获取或设置附加数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("attach")]
[System.Text.Json.Serialization.JsonPropertyName("attach")]
public string? Attachment { get; set; }
/// <summary>
/// 获取或设置支付完成时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("time_end")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.DigitalDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("time_end")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.DigitalDateTimeOffsetConverter))]
public DateTimeOffset? EndTime { get; set; }
}
}