merge
This commit is contained in:
@@ -3,8 +3,8 @@ package com.xwbing.service.other;
|
||||
import com.xwbing.domain.entity.wxpay.*;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.exception.PayException;
|
||||
import com.xwbing.util.RandomUtil;
|
||||
import com.xwbing.util.payWxpay.ClientCustomSSL;
|
||||
import com.xwbing.util.payWxpay.RandomKit;
|
||||
import com.xwbing.util.payWxpay.WxSignKit;
|
||||
import com.xwbing.util.payWxpay.XmlUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -369,7 +369,7 @@ public class WxPayService {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("appid", appId);
|
||||
params.put("mch_id", mchId);
|
||||
String nonce_str = RandomUtil.buildRandom(32);
|
||||
String nonce_str = RandomKit.buildRandom(32);
|
||||
params.put("nonce_str", nonce_str);
|
||||
params.put("body", param.getBody());
|
||||
params.put("out_trade_no", param.getOutTradeNo());
|
||||
@@ -401,7 +401,7 @@ public class WxPayService {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("appid", appId);
|
||||
params.put("mch_id", mchId);
|
||||
String nonce_str = RandomUtil.buildRandom(32);
|
||||
String nonce_str = RandomKit.buildRandom(32);
|
||||
params.put("nonce_str", nonce_str);
|
||||
if (StringUtils.isEmpty(param.getTransactionId()) && StringUtils.isEmpty(param.getOutTradeNo())) {
|
||||
throw new PayException("商户订单号和微信订单号不能同时为空!");
|
||||
@@ -450,7 +450,7 @@ public class WxPayService {
|
||||
if (StringUtils.isNotEmpty(outTradeNo)) {
|
||||
params.put("out_trade_no", outTradeNo);
|
||||
}
|
||||
String nonce_str = RandomUtil.buildRandom(32);
|
||||
String nonce_str = RandomKit.buildRandom(32);
|
||||
params.put("nonce_str", nonce_str);
|
||||
//签名放最后的
|
||||
String sign = WxSignKit.buildSign(params, apiKey);
|
||||
@@ -494,7 +494,7 @@ public class WxPayService {
|
||||
if (StringUtils.isNotEmpty(refundid)) {
|
||||
params.put("refund_id", refundid);
|
||||
}
|
||||
String nonce_str = RandomUtil.buildRandom(32);
|
||||
String nonce_str = RandomKit.buildRandom(32);
|
||||
params.put("nonce_str", nonce_str);
|
||||
//签名放最后的
|
||||
String sign = WxSignKit.buildSign(params, apiKey);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PassWordUtil {
|
||||
public static String[] getUserSecret(String password, String pwdSalt) {
|
||||
String[] str = new String[3];
|
||||
if (StringUtils.isEmpty(password)) {
|
||||
password = RandomUtil.buildRandom(PWD_LENGTH);
|
||||
password = RadomUtil.buildRandom(PWD_LENGTH);
|
||||
}
|
||||
// 密码盐值
|
||||
byte[] salt;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.Random;
|
||||
* 说明:生成随机码
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class RandomUtil {
|
||||
public class RadomUtil {
|
||||
public static String buildRandom(int length) {
|
||||
if (length < 1) {
|
||||
throw new UtilException("参数异常!!!");
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xwbing.util.payWxpay;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by drore-wzm on 2015/11/23.
|
||||
*/
|
||||
public class RandomKit {
|
||||
static String[] la_arrs={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","S","X","Y","Z","0","1","2","3","4","5","6","7","8","9"};
|
||||
|
||||
/****
|
||||
* 生成len个长度的随机字符
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
public static synchronized String buildRandom(int len){
|
||||
if (len<=0) {
|
||||
throw new RuntimeException("参数异常!!!");
|
||||
}
|
||||
StringBuffer random=new StringBuffer();
|
||||
for (int i = 0; i < len; i++) {
|
||||
random.append(la_arrs[new Random().nextInt(la_arrs.length)]);
|
||||
}
|
||||
return random.toString();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
System.out.println(buildRandom(32));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user