mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 09:54:44 +08:00
fix(tenpayv3): 修复查询代金券相关接口的响应模型定义错误
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace Newtonsoft.Json.Converters
|
||||
{
|
||||
internal class JsonTypedStringArrayConverter : JsonConverter<string[]?>
|
||||
{
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override string[]? ReadJson(JsonReader reader, Type objectType, string[]? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (reader.TokenType == JsonToken.String)
|
||||
{
|
||||
string? value = serializer.Deserialize<string>(reader);
|
||||
if (value == null)
|
||||
return existingValue;
|
||||
|
||||
if (value.StartsWith("[") && value.EndsWith("["))
|
||||
return JsonConvert.DeserializeObject<string[]>(value);
|
||||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return new string[0];
|
||||
else
|
||||
return new string[1] { value };
|
||||
}
|
||||
|
||||
throw new JsonReaderException();
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, string[]? value, JsonSerializer serializer)
|
||||
{
|
||||
if (value != null)
|
||||
writer.WriteValue(JsonConvert.SerializeObject(value, Formatting.None));
|
||||
else
|
||||
writer.WriteNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace System.Text.Json.Converters
|
||||
{
|
||||
internal class JsonTypedStringArrayConverter : JsonConverter<string[]?>
|
||||
{
|
||||
public override string[]? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
string? value = reader.GetString();
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
if (value.StartsWith("[") && value.EndsWith("["))
|
||||
return JsonSerializer.Deserialize<string[]>(value, options);
|
||||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return new string[0];
|
||||
else
|
||||
return new string[1] { value };
|
||||
}
|
||||
|
||||
throw new JsonException();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, string[]? value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value != null)
|
||||
writer.WriteStringValue(JsonSerializer.Serialize(value, options));
|
||||
else
|
||||
writer.WriteNullValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,9 +85,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
|
||||
/// 获取或设置指定支付方式列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("trade_type")]
|
||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.JsonTypedStringArrayConverter))]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("trade_type")]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.JsonTypedStringArrayConverter))]
|
||||
public string[]? TradeTypeList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"max_amount": 5000,
|
||||
"max_amount_by_day": 400,
|
||||
"max_coupons_per_user": 3,
|
||||
"trade_type": "MICROAPP"
|
||||
"trade_type": [ "OTHER", "APPPAY" ]
|
||||
},
|
||||
"available_begin_time": "2015-05-20T13:29:35.120+08:00",
|
||||
"available_end_time": "2015-05-20T13:29:35.120+08:00",
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
"transaction_minimum": 100
|
||||
},
|
||||
"max_coupons_per_user": 3,
|
||||
"trade_type": "APPPAY"
|
||||
"trade_type": [ "OTHER", "APPPAY" ]
|
||||
},
|
||||
"available_begin_time": "2015-05-20T13:29:35.120+08:00",
|
||||
"available_end_time": "2015-05-20T13:29:35.120+08:00",
|
||||
"distributed_coupons": 100,
|
||||
"no_cash": true,
|
||||
"singleitem": true,
|
||||
"singleitem ": true,
|
||||
"stock_type": "NORMAL"
|
||||
}
|
||||
],
|
||||
"limit": 8,
|
||||
"offset": 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user