From dd407141b03c102f1aaff878685a7ebd14271147 Mon Sep 17 00:00:00 2001
From: SynchPj <46849861+SynchPj@users.noreply.github.com>
Date: Mon, 7 Apr 2025 13:01:53 +0800
Subject: [PATCH 01/20] =?UTF-8?q?:art:=20#3530=20=E3=80=90=E5=BE=AE?=
=?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=E3=80=91=E4=BF=AE=E5=A4=8D=E6=9C=AA?=
=?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=B9=B3=E5=8F=B0=E8=AF=81=E4=B9=A6=E5=BC=95?=
=?UTF-8?q?=E8=B5=B7=E7=9A=84v3=E8=AF=B7=E6=B1=82=E6=9E=84=E9=80=A0?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../github/binarywang/wxpay/config/WxPayConfig.java | 12 ++++++++----
.../wxpay/v3/auth/PublicCertificateVerifier.java | 2 +-
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
index dedbc64137..7a14ea1523 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
@@ -347,10 +347,14 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
}
private Verifier getVerifier(PrivateKey merchantPrivateKey, WxPayHttpProxy wxPayHttpProxy, PublicKey publicKey) {
- Verifier certificatesVerifier = new AutoUpdateCertificatesVerifier(
- new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
- this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
- this.getPayBaseUrl(), wxPayHttpProxy);
+ Verifier certificatesVerifier = null;
+ // 如果配置了平台证书,则初始化验证器以备v2版本接口验签(公钥灰度实现)
+ if (this.getPrivateCertPath() != null && this.getPrivateKeyPath() != null) {
+ certificatesVerifier = new AutoUpdateCertificatesVerifier(
+ new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
+ this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
+ this.getPayBaseUrl(), wxPayHttpProxy);
+ }
if (publicKey != null) {
Verifier publicCertificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
publicCertificatesVerifier.setOtherVerifier(certificatesVerifier);
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PublicCertificateVerifier.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PublicCertificateVerifier.java
index 45f76818cd..8c9c4f3569 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PublicCertificateVerifier.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PublicCertificateVerifier.java
@@ -24,7 +24,7 @@ public void setOtherVerifier(Verifier verifier) {
@Override
public boolean verify(String serialNumber, byte[] message, String signature) {
- if (!serialNumber.contains("PUB_KEY_ID")) {
+ if (!serialNumber.contains("PUB_KEY_ID") && this.certificateVerifier != null) {
return this.certificateVerifier.verify(serialNumber, message, signature);
}
try {
From 3f0b8d4e2bf4fe2d355e412e074078f71eef261b Mon Sep 17 00:00:00 2001
From: cloudX
+ * 场景 + *
+ * 1. 老商户号,只有平台证书,未开通公钥 (已验证) + * 2. 新商户号,被强制开通公钥,没有平台证书 (已验证) + * 3. 老商户号,有平台证书,主动开通公钥 (未验证,具备条件的朋友,可以帮忙验证下) + * ... + *+ * + * @param certSerialNo c + * @param mchId m + * @param apiV3Key a + * @param merchantPrivateKey m + * @param wxPayHttpProxy w + * @param certAutoUpdateTime c + * @param payBaseUrl p + * @param publicKeyId p + * @param publicKey p + * @return v + * @throws WxPayException e + */ + @SuppressWarnings("java:S107") + static Verifier build( + // 平台证书 - 依赖参数 + String certSerialNo, + String mchId, + String apiV3Key, + PrivateKey merchantPrivateKey, + WxPayHttpProxy wxPayHttpProxy, + int certAutoUpdateTime, + String payBaseUrl, + // 公钥 - 依赖参数 + String publicKeyId, + PublicKey publicKey + ) throws WxPayException { + Verifier certificatesVerifier = null; + Exception ex = null; + + // 构建平台证书验证器 + // (沿用旧逻辑)优先构建平台证书验证器,因为公钥验证器需要平台证书验证器 (见以下 .setOtherVerifier ) + // 新商户号默认无平台证书,已确认无法构建平台证书验证器,会抛出异常;老商户号,有平台证书主动开通公钥的情况,待具备条件的朋友验证 + // 建议公钥模式稳定后,优先构建公钥验证器,以免每次都尝试构建平台证书验证器,且失败 {@link com.github.binarywang.wxpay.v3.auth.PublicCertificateVerifier.verify} + if (merchantPrivateKey != null && StringUtils.isNoneBlank(certSerialNo, apiV3Key)) { + try { + certificatesVerifier = getCertificatesVerifier( + certSerialNo, mchId, apiV3Key, merchantPrivateKey, wxPayHttpProxy, certAutoUpdateTime, payBaseUrl + ); + } catch (Exception e) { + ex = e; + } + } + + // 构建公钥验证器 + if (publicKey != null && StringUtils.isNotBlank(publicKeyId)) { + try { + certificatesVerifier = getPublicCertVerifier(publicKeyId, publicKey, certificatesVerifier); + } catch (Exception e) { + ex = e; + } + } + if (certificatesVerifier != null) { + return certificatesVerifier; + } + + // 有异常时抛出 + if (ex != null) { + throw new WxPayException(ex.getMessage(), ex); + } + + // 没有证书验证器时。不确定是否抛出异常,沿用之前逻辑,返回 null + return null; + } + + /** + * 获取证书验证器. + * + * @param certSerialNo certSerialNo + * @param mchId mchId + * @param apiV3Key apiV3Key + * @param merchantPrivateKey merchantPrivateKey + * @param wxPayHttpProxy wxPayHttpProxy + * @param certAutoUpdateTime certAutoUpdateTime + * @param payBaseUrl payBaseUrl + * @return verifier + */ + private static AutoUpdateCertificatesVerifier getCertificatesVerifier( + String certSerialNo, String mchId, String apiV3Key, PrivateKey merchantPrivateKey, + WxPayHttpProxy wxPayHttpProxy, int certAutoUpdateTime, String payBaseUrl + ) { + return new AutoUpdateCertificatesVerifier( + new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)), + apiV3Key.getBytes(StandardCharsets.UTF_8), certAutoUpdateTime, + payBaseUrl, wxPayHttpProxy); + } + + /** + * 获取公钥验证器. + * + * @param publicKeyId id + * @param publicKey key + * @param certificatesVerifier verifier + * @return verifier + */ + private static Verifier getPublicCertVerifier(String publicKeyId, PublicKey publicKey, Verifier certificatesVerifier) { + Verifier publicCertificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId); + publicCertificatesVerifier.setOtherVerifier(certificatesVerifier); + certificatesVerifier = publicCertificatesVerifier; + return certificatesVerifier; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java index 7a14ea1523..43f41e9639 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java @@ -4,7 +4,8 @@ import com.github.binarywang.wxpay.util.HttpProxyUtils; import com.github.binarywang.wxpay.util.ResourcesUtils; import com.github.binarywang.wxpay.v3.WxPayV3HttpClientBuilder; -import com.github.binarywang.wxpay.v3.auth.*; +import com.github.binarywang.wxpay.v3.auth.Verifier; +import com.github.binarywang.wxpay.v3.auth.WxPayValidator; import com.github.binarywang.wxpay.v3.util.PemUtils; import lombok.Data; import lombok.EqualsAndHashCode; @@ -19,7 +20,6 @@ import javax.net.ssl.SSLContext; import java.io.*; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.security.PrivateKey; import java.security.PublicKey; @@ -320,7 +320,12 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException { //构造Http Proxy正向代理 WxPayHttpProxy wxPayHttpProxy = getWxPayHttpProxy(); - Verifier certificatesVerifier = getVerifier(merchantPrivateKey, wxPayHttpProxy, publicKey); + // 构造证书验签器 + Verifier certificatesVerifier = VerifierBuilder.build( + this.getCertSerialNo(), this.getMchId(), this.getApiV3Key(), merchantPrivateKey, wxPayHttpProxy, + this.getCertAutoUpdateTime(), this.getPayBaseUrl(), + this.getPublicKeyId(), publicKey + ); WxPayV3HttpClientBuilder wxPayV3HttpClientBuilder = WxPayV3HttpClientBuilder.create() .withMerchant(mchId, certSerialNo, merchantPrivateKey) @@ -346,23 +351,6 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException { } } - private Verifier getVerifier(PrivateKey merchantPrivateKey, WxPayHttpProxy wxPayHttpProxy, PublicKey publicKey) { - Verifier certificatesVerifier = null; - // 如果配置了平台证书,则初始化验证器以备v2版本接口验签(公钥灰度实现) - if (this.getPrivateCertPath() != null && this.getPrivateKeyPath() != null) { - certificatesVerifier = new AutoUpdateCertificatesVerifier( - new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)), - this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(), - this.getPayBaseUrl(), wxPayHttpProxy); - } - if (publicKey != null) { - Verifier publicCertificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId); - publicCertificatesVerifier.setOtherVerifier(certificatesVerifier); - certificatesVerifier = publicCertificatesVerifier; - } - return certificatesVerifier; - } - /** * 初始化一个WxPayHttpProxy对象 * From e16e0e93735884472300c7e77df63e4d586ec11d Mon Sep 17 00:00:00 2001 From: HerveyHall
@@ -119,4 +129,20 @@ public String uploadImg(File file) throws WxErrorException { return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), url, file) .getUrl(); } + + @Override + public String uploadByUrl(MediaUploadByUrlReq req) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPLOAD_BY_URL); + String responseContent = this.mainService.post(url, req.toJson()); + return GsonHelper.getString(GsonParser.parse(responseContent), "jobid"); + } + + @Override + public MediaUploadByUrlResult uploadByUrl(String jobId) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_UPLOAD_BY_URL_RESULT); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("jobid", jobId); + String post = this.mainService.post(url, jsonObject.toString()); + return MediaUploadByUrlResult.fromJson(post); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlReq.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlReq.java new file mode 100644 index 0000000000..c5cb21bde5 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlReq.java @@ -0,0 +1,58 @@ +package me.chanjar.weixin.cp.bean.media; + +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 生成异步上传任务 + * @author imyzt + * @date 2025/04/27 + */ +@Data +public class MediaUploadByUrlReq { + + /** + * 场景值。1-客户联系入群欢迎语素材(目前仅支持1)。 注意:每个场景值有对应的使用范围,详见上面的「使用场景说明」 + */ + private Integer scene; + + /** + * 媒体文件类型。目前仅支持video-视频,file-普通文件 不超过32字节。 + */ + private String type; + + /** + * 文件名,标识文件展示的名称。比如,使用该media_id发消息时,展示的文件名由该字段控制。 不超过128字节。 + */ + private String filename; + + /** + * 文件cdn url。url要求支持Range分块下载 不超过1024字节。 如果为腾讯云cos链接,则需要设置为「公有读」权限。 + */ + private String url; + + /** + * 文件md5。对比从url下载下来的文件md5是否一致。 不超过32字节。 + */ + private String md5; + + /** + * From json wx cp base resp. + * + * @param json the json + * @return the wx cp base resp + */ + public static MediaUploadByUrlReq fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, MediaUploadByUrlReq.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlResult.java new file mode 100644 index 0000000000..cc931eed39 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/media/MediaUploadByUrlResult.java @@ -0,0 +1,82 @@ +package me.chanjar.weixin.cp.bean.media; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; + +/** + * 异步上传企微素材 + * @author imyzt + * @date 2025/4/27 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class MediaUploadByUrlResult extends WxCpBaseResp implements Serializable { + + private static final long serialVersionUID = 330834334738622341L; + + /** + * 任务状态。1-处理中,2-完成,3-异常失败 + */ + @SerializedName("status") + private Integer status; + + @SerializedName("detail") + private Detail detail; + + @Data + public static class Detail { + + /** + * 任务失败返回码。当status为3时返回非0,其他返回0 + * 830001 url非法 确认url是否支持Range分块下载 + * 830003 url下载数据失败 确认url本身是否能正常访问 + * 45001 文件大小超过限制 确认文件在5字节~200M范围内 + * 301019 文件MD5不匹配 确认url对应的文件内容md5,跟所填的md5参数是否一致 + * 注意: status=2时,此处微信并未返回任何值 + */ + @SerializedName("errcode") + private Integer errCode; + + /** + * 注意: status=2时,此处微信并未返回任何值 + */ + @SerializedName("errmsg") + private String errMsg; + + /** + * 媒体文件上传后获取的唯一标识,3天内有效。当status为2时返回。 + */ + @SerializedName("media_id") + private String mediaId; + + /** + * 媒体文件创建的时间戳。当status为2时返回。 + */ + @SerializedName("created_at") + private String createdAt; + } + + /** + * From json wx cp media upload by url result. + * + * @param json the json + * @return the wx cp media upload by url result + */ + public static MediaUploadByUrlResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, MediaUploadByUrlResult.class); + } + + /** + * To json string. + * + * @return the string + */ + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java index fb4213f504..81d09a11c6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java @@ -198,6 +198,13 @@ public class WxCpXmlMessage implements Serializable { @XStreamAlias("SelectedItems") private ListselectedItems; + /** + * 异步任务id + */ + @XStreamAlias("JobId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String jobId; + /** * 微信客服 * 调用拉取消息接口时,需要传此token,用于校验请求的合法性 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index d70f0ff4cc..093d386e6a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -238,6 +238,12 @@ interface Media { * The constant JSSDK_MEDIA_GET. */ String JSSDK_MEDIA_GET = "/cgi-bin/media/get/jssdk"; + + /** The constant GET_UPLOAD_BY_URL_RESULT. */ + String GET_UPLOAD_BY_URL_RESULT = "/cgi-bin/media/get_upload_by_url_result"; + + /** The constant UPLOAD_BY_URL. */ + String UPLOAD_BY_URL = "/cgi-bin/media/upload_by_url"; } /** diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java index 606dcea6d2..3d51c9e2c9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java @@ -219,6 +219,11 @@ public static class EventType { */ public static final String CUSTOMER_ACQUISITION = "customer_acquisition"; + /** + * 异步上传临时素材结果回调通知 + */ + public static final String UPLOAD_MEDIA_JOB_FINISH = "upload_media_job_finish"; + } /** diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java index b964aad513..381a4c1454 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java @@ -7,6 +7,8 @@ import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.TestConstants; import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.media.MediaUploadByUrlReq; +import me.chanjar.weixin.cp.bean.media.MediaUploadByUrlResult; import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -127,4 +129,38 @@ public void testGetJssdkFile() throws WxErrorException { assertThat(file).isNotNull(); System.out.println(file); } + + /** + * Test upload media by url. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testUploadMediaByUrl() throws WxErrorException { + MediaUploadByUrlReq req = new MediaUploadByUrlReq(); + req.setScene(1); + req.setType("video"); + req.setFilename("mov_bbb"); + req.setUrl("https://www.w3school.com.cn/example/html5/mov_bbb.mp4"); + req.setMd5("198918f40ecc7cab0fc4231adaf67c96"); + String jobId = this.wxService.getMediaService().uploadByUrl(req); + System.out.println(jobId); + } + + /** + * Test upload media by url. + * + * @throws WxErrorException the wx error exception + */ + @Test + public void testUploadMediaByUrlResult() throws WxErrorException, InterruptedException { + String jobId = "job1745801375_5GIKWuFF3M7hcIkeSNMqs_W26xy5VeSWjLaLFTEdSfQ"; + MediaUploadByUrlResult result = this.wxService.getMediaService().uploadByUrl(jobId); + System.out.println(result); + } + + @Test + public void testUploadMediaJobFinishEvent() throws WxErrorException { + File file = this.wxService.getMediaService().getJssdkFile("...."); + } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java index a760a17ff6..5bcfe9698a 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java @@ -6,6 +6,7 @@ import org.testng.annotations.Test; import static me.chanjar.weixin.cp.constant.WxCpConsts.EventType.TASKCARD_CLICK; +import static me.chanjar.weixin.cp.constant.WxCpConsts.EventType.UPLOAD_MEDIA_JOB_FINISH; import static org.assertj.core.api.Assertions.assertThat; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -421,4 +422,24 @@ public void testOpenApprovalChange() { assertThat(wxCpXmlMessage.getApprovalInfo().getApprovalNodes().get(0).getItems().get(0).getItemName()).isNotEmpty(); assertThat(wxCpXmlMessage.getApprovalInfo().getNotifyNodes().get(0).getItemName()).isNotEmpty(); } + + /** + * Test open approval change. + */ + public void testUploadMediaJobFinishEvent() { + String xml = " \n" + + "\t "; + + WxCpXmlMessage wxCpXmlMessage = WxCpXmlMessage.fromXml(xml); + assertThat(wxCpXmlMessage).isNotNull(); + assertThat(wxCpXmlMessage.getJobId()).isNotEmpty(); + assertThat(wxCpXmlMessage.getJobId()).isEqualTo("jobid_S0MrnndvRG5fadSlLwiBqiDDbM143UqTmKP3152FZk4"); + assertThat(wxCpXmlMessage.getEvent()).isEqualTo(UPLOAD_MEDIA_JOB_FINISH); + } } From 854b50bd5164f9cb6c77cd04e763b846ed1bf78f Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 29 Apr 2025 11:33:46 +0800 Subject: [PATCH 20/20] =?UTF-8?q?:art:=20=E4=BF=AE=E5=A4=8D=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BB=A3=E7=A0=81=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java | 2 ++ .../wxpay/service/impl/WxPayServiceApacheHttpImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java index c5bab01263..3a63f0d7fd 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java @@ -30,6 +30,7 @@ import com.google.gson.GsonBuilder; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxRuntimeException; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.ConstructorUtils; @@ -59,6 +60,7 @@ * * @author Binary Wang */ +@Slf4j public abstract class BaseWxPayServiceImpl implements WxPayService { private static final String TOTAL_FUND_COUNT = "资金流水总笔数"; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index e40c92a193..dcd70b5239 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -198,7 +198,7 @@ public String requestV3(String url, HttpRequestBase httpRequest) throws WxPayExc JsonObject jsonObject = GsonParser.parse(responseString); throw convertException(jsonObject); } catch (Exception e) { - this.log.error("\n【请求地址】:{}\n【异常信息】:{}", url, e.getMessage()); + log.error("\n【请求地址】:{}\n【异常信息】:{}", url, e.getMessage()); throw (e instanceof WxPayException) ? (WxPayException) e : new WxPayException(e.getMessage(), e); } finally { httpRequest.releaseConnection(); @@ -344,7 +344,7 @@ private void initSSLContext(HttpClientBuilder httpClientBuilder) throws WxPayExc } private WxPayException convertException(JsonObject jsonObject) { - //todo 这里考虑使用新的适用于V3的异常 + //TODO 这里考虑使用新的适用于V3的异常 JsonElement codeElement = jsonObject.get("code"); String code = codeElement == null ? null : codeElement.getAsString(); String message = jsonObject.get("message").getAsString();\n" + + "\t \n" + + "\t 1425284517 \n" + + "\t\n" + + "\t \n" + + "\t \n" + + "