From aae5096349056df644e356256d29f85d6f0a46c4 Mon Sep 17 00:00:00 2001 From: "felord.cn" Date: Tue, 23 Mar 2021 21:19:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B7=B2=E7=9F=A5Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/enumeration/CouponBgColor.java | 42 +++++-------------- .../felord/payment/wechat/v3/AbstractApi.java | 14 ++++--- .../payment/wechat/v3/WechatPayCallback.java | 11 +++-- .../BusiFavorReceiveConsumeData.java | 2 +- 4 files changed, 24 insertions(+), 45 deletions(-) diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java index 1cb4b7b..b85ee46 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/CouponBgColor.java @@ -29,64 +29,42 @@ public enum CouponBgColor { /** * Color 010 coupon bg color. */ - COLOR010("#63B359"), + Color010, /** * Color 020 coupon bg color. */ - COLOR020("#2C9F67"), + Color020, /** * Color 030 coupon bg color. */ - COLOR030("#509FC9"), + Color030, /** * Color 040 coupon bg color. */ - COLOR040("#5885CF"), + Color040, /** * Color 050 coupon bg color. */ - COLOR050("#9062C0"), + Color050, /** * Color 060 coupon bg color. */ - COLOR060("#D09A45"), + Color060, /** * Color 070 coupon bg color. */ - COLOR070("#E4B138"), + Color070, /** * Color 080 coupon bg color. */ - COLOR080("#EE903C"), + Color080, /** * Color 090 coupon bg color. */ - COLOR090("#DD6549"), + Color090, /** * Color 100 coupon bg color. */ - COLOR100("#CC463D"); + Color100 - /** - * The Color. - */ - private final String color; - - /** - * Instantiates a new Coupon bg color. - * - * @param color the color - */ - CouponBgColor(String color) { - this.color = color; - } - - /** - * Color string. - * - * @return the string - */ - public String color() { - return this.color; - } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java index 270339d..9e12c19 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java @@ -24,9 +24,9 @@ import cn.felord.payment.wechat.v3.model.FundFlowBillParams; import cn.felord.payment.wechat.v3.model.TradeBillParams; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; @@ -88,10 +88,11 @@ public abstract class AbstractApi { * @param mapper the mapper */ private void applyObjectMapper(ObjectMapper mapper) { - mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - SimpleModule module = new JavaTimeModule(); - mapper.registerModule(module); + mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false) + .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true) + .setSerializationInclusion(JsonInclude.Include.NON_NULL) + .registerModule(new JavaTimeModule()); } @@ -185,10 +186,11 @@ public abstract class AbstractApi { return RequestEntity.get(uri).header("Pay-TenantId", tenantId) .build(); } + /** * 构建Get请求对象. * - * @param uri the uri + * @param uri the uri * @param httpHeaders the http headers * @return the request entity */ diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java index 989675a..77d41df 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java @@ -34,7 +34,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -72,11 +71,11 @@ public class WechatPayCallback { private final String tenantId; static { - MAPPER.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); - MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); - MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); - SimpleModule module = new JavaTimeModule(); - MAPPER.registerModule(module); + MAPPER.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE) + .setSerializationInclusion(JsonInclude.Include.NON_NULL) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false) + .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,true) + .registerModule(new JavaTimeModule()); } /** diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java index 57e0b02..2560165 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java @@ -49,7 +49,7 @@ public class BusiFavorReceiveConsumeData { /** * 发放时间 rfc 3339 yyyy-MM-ddTHH:mm:ss+TIMEZONE */ - @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "GMT+8") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8") private OffsetDateTime sendTime; /** * 微信用户在appid下的唯一标识。