From 04fadf6f71da2eb65e8ce1c1ca731d67381c509e Mon Sep 17 00:00:00 2001 From: guicw Date: Sun, 10 Jan 2021 23:21:19 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20#1959=20=E3=80=90=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E3=80=91=E7=94=B5=E5=95=86=E6=94=B6=E4=BB=98?= =?UTF-8?q?=E9=80=9A=E4=BF=AE=E5=A4=8D=E8=AF=B7=E6=B1=82=E5=88=86=E8=B4=A6?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: aha --- .../bean/ecommerce/ProfitSharingRequest.java | 6 +++++- .../wxpay/service/impl/EcommerceServiceImpl.java | 3 ++- .../binarywang/wxpay/v3/util/RsaCryptoUtil.java | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java index aaec33bd07..ab83cab033 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingRequest.java @@ -1,10 +1,12 @@ package com.github.binarywang.wxpay.bean.ecommerce; +import com.github.binarywang.wxpay.v3.SpecEncrypt; import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; +import java.util.List; /** * 请求分账 对象 @@ -86,7 +88,8 @@ public class ProfitSharingRequest implements Serializable { * */ @SerializedName(value = "receivers") - private Receiver[] receivers; + @SpecEncrypt + private List receivers; /** *
@@ -186,6 +189,7 @@ public static class Receiver implements Serializable {
      * 
*/ @SerializedName(value = "receiver_name") + @SpecEncrypt private String receiverName; } 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 4feaaab01f..169f593717 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 @@ -190,7 +190,8 @@ public FundBalanceResult subDayEndBalance(String subMchid, String date) throws W @Override public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException { String url = String.format("%s/v3/ecommerce/profitsharing/orders", this.payService.getPayBaseUrl()); - String response = this.payService.postV3(url, GSON.toJson(request)); + RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate()); + String response = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request)); return GSON.fromJson(response, ProfitSharingResult.class); } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java index 287ac11fcf..2953037403 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java @@ -15,6 +15,7 @@ import java.security.PrivateKey; import java.security.cert.X509Certificate; import java.util.Base64; +import java.util.Collection; /** * 微信支付敏感信息加密 @@ -53,8 +54,18 @@ private static void encryptField(Object encryptObject, X509Certificate certifica } else { field.setAccessible(true); Object obj = field.get(encryptObject); - if (obj != null) { - encryptField(field.get(encryptObject), certificate); + if (obj == null) { + continue; + } + if (obj instanceof Collection) { + Collection collection = (Collection) obj; + for (Object o : collection) { + if (o != null) { + encryptField(o, certificate); + } + } + } else { + encryptField(obj, certificate); } } }