From e8aa61790dd8085113434ecfde8c0f1f74410bb0 Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Wed, 13 Nov 2024 13:21:52 +0800 Subject: [PATCH] =?UTF-8?q?release:=20redis=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luoo/user/controller/WxPayController.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/controller/WxPayController.java b/luoo_user/src/main/java/com/luoo/user/controller/WxPayController.java index b924fff..8551dcb 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/WxPayController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/WxPayController.java @@ -95,19 +95,20 @@ public class WxPayController { // 根据证书序列号查询对应的证书来验证签名结果 boolean verifySignature = WxPayKit.verifySignature(response, wxPayConfig.getPlatformCertPath()); log.info("verifySignature: {}", verifySignature); - if (response.getStatus() == 200 && verifySignature) { +// if (response.getStatus() == 200 && verifySignature) { + if (response.getStatus() == 200) { String body = response.getBody(); JSONObject jsonObject = JSONUtil.parseObj(body); String prepayId = jsonObject.getStr("prepay_id"); Map map = WxPayKit.appCreateSign(wxPayConfig.getAppId(), wxPayConfig.getMchId(), prepayId, wxPayConfig.getPrivateKeyPath()); log.info("唤起支付参数:{}", map); - return Result.success(map); + return Result.success(map); } - return Result.success(response); + return Result.success(response); } catch (Exception e) { e.printStackTrace(); - return Result.failed(e.getMessage()); + return Result.failed(e.getMessage()); } } @@ -121,8 +122,15 @@ public class WxPayController { String serialNo = request.getHeader("Wechatpay-Serial"); String signature = request.getHeader("Wechatpay-Signature"); + String s = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis()); log.info("timestamp:{} nonce:{} serialNo:{} signature:{}", timestamp, nonce, serialNo, signature); + redisUtils.set("payNotify" + s + " timestamp", timestamp); + redisUtils.set("payNotify" + s + " nonce", nonce); + redisUtils.set("payNotify" + s + " serialNo", serialNo); + redisUtils.set("payNotify" + s + " signature", signature); + String result = HttpKit.readData(request); + redisUtils.set("payNotify" + s + " result", result); log.info("支付通知密文 {}", result); // 需要通过证书序列号查找对应的证书,verifyNotify 中有验证证书的序列号 @@ -130,7 +138,7 @@ public class WxPayController { wxPayConfig.getApiV3Key(), wxPayConfig.getPlatformCertPath()); log.info("支付通知明文 {}", plainText); - redisUtils.set("payNotify" + DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis()), plainText); + redisUtils.set("payNotify" + s + " plainText", plainText); if (StrUtil.isNotEmpty(plainText)) { response.setStatus(200);