diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java index 3ef043495a..7db60d215c 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveGoodInfo.java @@ -27,4 +27,10 @@ public class WxMaLiveGoodInfo implements Serializable { * https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/liveplayer/pendant.html */ private List goodsKey; + + + /** + * 当商品为第三方小程序的商品则填写为对应第三方小程序的appid,自身小程序商品则为'' + */ + private String thirdPartyAppid; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java index dfb7b1e48f..40e649dc32 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveResult.java @@ -74,6 +74,11 @@ public static class Goods implements Serializable { */ @SerializedName("third_party_tag") private String thirdPartyTag; + + /** + * 当商品为第三方小程序的商品则填写为对应第三方小程序的appid,自身小程序商品则为'' + */ + private String thirdPartyAppid; } /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java index c83fdf4a5a..b1139be565 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java @@ -66,7 +66,7 @@ public class RefundsResult implements Serializable { * */ @SerializedName(value = "create_time") - private Date createTime; + private String createTime; /** *
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java
index 5655139d0f..c833b17337 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java
@@ -163,6 +163,6 @@ public class ReturnOrdersResult implements Serializable {
    * 
*/ @SerializedName(value = "finish_time") - private Date finishTime; + private String finishTime; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java index 91ab368306..23f1cbd8c2 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java @@ -12,15 +12,15 @@ import com.google.common.base.CaseFormat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.apache.commons.lang3.StringUtils; import lombok.RequiredArgsConstructor; import org.apache.commons.beanutils.BeanMap; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.io.InputStream; -import java.net.URI; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; +import java.text.DateFormat; import java.util.Iterator; import java.util.Map; import java.util.Objects; @@ -30,6 +30,11 @@ public class EcommerceServiceImpl implements EcommerceService { private static final Gson GSON = new GsonBuilder().create(); + + // https://stackoverflow.com/questions/6873020/gson-date-format + // gson default date format not match, so custom DateFormat + // detail DateFormat: FULL,LONG,SHORT,MEDIUM + private static final Gson GSON_CUSTOM = new GsonBuilder().setDateFormat(DateFormat.FULL, DateFormat.FULL).create(); private final WxPayService payService; @Override @@ -71,7 +76,7 @@ public T combineTransactions(TradeTypeEnum tradeType, CombineTransactionsReq @Override public CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { - if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){ + if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { throw new WxPayException("非法请求,头部信息验证失败"); } NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class); @@ -81,7 +86,7 @@ public CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyDat String nonce = resource.getNonce(); String apiV3Key = this.payService.getConfig().getApiV3Key(); try { - String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key); + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); CombineTransactionsResult transactionsResult = GSON.fromJson(result, CombineTransactionsResult.class); CombineTransactionsNotifyResult notifyResult = new CombineTransactionsNotifyResult(); @@ -117,7 +122,7 @@ public T partnerTransactions(TradeTypeEnum tradeType, PartnerTransactionsReq @Override public PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { - if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){ + if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { throw new WxPayException("非法请求,头部信息验证失败"); } NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class); @@ -127,7 +132,7 @@ public PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyDat String nonce = resource.getNonce(); String apiV3Key = this.payService.getConfig().getApiV3Key(); try { - String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key); + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); PartnerTransactionsResult transactionsResult = GSON.fromJson(result, PartnerTransactionsResult.class); PartnerTransactionsNotifyResult notifyResult = new PartnerTransactionsNotifyResult(); @@ -277,7 +282,7 @@ public RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRef @Override public RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { - if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){ + if (Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)) { throw new WxPayException("非法请求,头部信息验证失败"); } NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class); @@ -287,7 +292,7 @@ public RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHe String nonce = resource.getNonce(); String apiV3Key = this.payService.getConfig().getApiV3Key(); try { - String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key); + String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key); RefundNotifyResult notifyResult = GSON.fromJson(result, RefundNotifyResult.class); notifyResult.setRawData(response); return notifyResult; @@ -359,8 +364,9 @@ public InputStream downloadBill(String url) throws WxPayException { /** * 校验通知签名 + * * @param header 通知头信息 - * @param data 通知数据 + * @param data 通知数据 * @return true:校验通过 false:校验不通过 */ private boolean verifyNotifySign(SignatureHeader header, String data) { @@ -374,8 +380,9 @@ private boolean verifyNotifySign(SignatureHeader header, String data) { /** * 对象拼接到url + * * @param o 转换对象 - * @return 拼接好的string + * @return 拼接好的string */ private String parseURLPair(Object o) { Map map = new BeanMap(o); @@ -384,7 +391,7 @@ private String parseURLPair(Object o) { StringBuilder sb = new StringBuilder(); while (it.hasNext()) { Map.Entry e = it.next(); - if ( !"class".equals(e.getKey()) && e.getValue() != null) { + if (!"class".equals(e.getKey()) && e.getValue() != null) { sb.append(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, String.valueOf(e.getKey()))) .append("=").append(e.getValue()).append("&"); } @@ -392,5 +399,4 @@ private String parseURLPair(Object o) { return sb.deleteCharAt(sb.length() - 1).toString(); } - - } +}