From 4548c5045b3a5522ad14df7c939f0303c1e17587 Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Sat, 11 Oct 2025 19:07:29 +0800
Subject: [PATCH] 配送费
---
oying-system/src/main/java/com/oying/modules/hwc/utils/SignUtil.java | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/oying-system/src/main/java/com/oying/modules/hwc/utils/SignUtil.java b/oying-system/src/main/java/com/oying/modules/hwc/utils/SignUtil.java
index 1bb9545..5162317 100644
--- a/oying-system/src/main/java/com/oying/modules/hwc/utils/SignUtil.java
+++ b/oying-system/src/main/java/com/oying/modules/hwc/utils/SignUtil.java
@@ -32,6 +32,8 @@
return MD5.sign(preStr, "&key=" + properties.getKey(), "utf-8");
case HWC2:
return MD5.sign(preStr, "&key=" + properties.getKey2(), "utf-8");
+ case HWC3:
+ return MD5.sign(preStr, "&key=" + properties.getKey3(), "utf-8");
}
throw new BadRequestException("汇旺财类型错误");
}
@@ -40,7 +42,8 @@
/**
* 对返回参数的验证签名
*/
- public static boolean verifySign(String sign, String signType, Map<String, String> resultMap, SwiftPassProperties properties, PayTypeEnum status) throws Exception {
+ public static boolean verifySign(String sign, String signType, Map<String, String> resultMap,
+ SwiftPassProperties properties, PayTypeEnum status) {
if ("RSA_1_256".equals(signType)) {
Map<String, String> params = SignUtils.paraFilter(resultMap);
StringBuilder builder = new StringBuilder((params.size() + 1) * 10);
@@ -53,6 +56,8 @@
return !SignUtils.checkParam(resultMap, properties.getKey());
case HWC2:
return !SignUtils.checkParam(resultMap, properties.getKey2());
+ case HWC3:
+ return !SignUtils.checkParam(resultMap, properties.getKey3());
}
throw new BadRequestException("汇旺财类型错误");
}
@@ -62,7 +67,7 @@
/**
* RSA_1_256 验证签名
*/
- public static boolean verifySign(String preStr, String sign, String signType, String platPublicKey) throws Exception {
+ public static boolean verifySign(String preStr, String sign, String signType, String platPublicKey) {
// 调用这个函数前需要先判断是MD5还是RSA
// 商户的验签函数要同时支持MD5和RSA
RSAUtil.SignatureSuite suite;
@@ -71,7 +76,7 @@
} else if ("RSA_1_256".equals(signType)) {
suite = RSAUtil.SignatureSuite.SHA256;
} else {
- throw new Exception("不支持的签名方式");
+ throw new BadRequestException("不支持的签名方式");
}
return RSAUtil.verifySign(suite, preStr.getBytes(StandardCharsets.UTF_8), Base64.decodeBase64(sign.getBytes(StandardCharsets.UTF_8)),
platPublicKey);
@@ -80,14 +85,14 @@
/**
* RSA_1_256生成不同的sign
*/
- public static String sign(String preStr, String signType, String mchPrivateKey) throws Exception {
+ public static String sign(String preStr, String signType, String mchPrivateKey) {
RSAUtil.SignatureSuite suite;
if ("RSA_1_1".equals(signType)) {
suite = RSAUtil.SignatureSuite.SHA1;
} else if ("RSA_1_256".equals(signType)) {
suite = RSAUtil.SignatureSuite.SHA256;
} else {
- throw new Exception("不支持的签名方式");
+ throw new BadRequestException("不支持的签名方式");
}
byte[] signBuf = RSAUtil.sign(suite, preStr.getBytes(StandardCharsets.UTF_8),
mchPrivateKey);
--
Gitblit v1.9.3