解决生成订单时key不能为null错误

This commit is contained in:
2024-12-27 09:11:06 +08:00
parent 54ddf8ce5b
commit c60724520c
4 changed files with 36 additions and 23 deletions

View File

@ -167,7 +167,7 @@ public class UserRechargeCardsServiceImpl implements IUserRechargeCardsService
param.put("data",data);
try{
//pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(param));
pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(param));
}catch (Exception e)
{
throw new Exception("消息发布失败");

View File

@ -49,7 +49,7 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
//public static String publicKeyPath="fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem";
//public static String publicKeyPath="fastbee-common/src/main/java/com/fastbee/common/utils/pay/wechat_public_key.pem";
//支付结果回调地址
public static String notify_url="https://3e744f6.r3.cpolar.cn/pay/getresult";//https://3e744f6.r3.cpolar.cn
public static String notify_url="https://5f655ed0.r3.cpolar.cn/pay/getresult";//https://5f655ed0.r3.cpolar.cn
@Override
/**
* 创建订单获取prepay_id和paySign
@ -76,7 +76,7 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
reqdata.put("mchid",mchId);
reqdata.put("description",recharge.getCardnumber()+recharge.getAmount().toString());
reqdata.put("out_trade_no",recharge.getRechargeCode());
reqdata.put("notify_url","https://46b411f6.r3.cpolar.cn/pay/getresult");//"\t\n" +
reqdata.put("notify_url",notify_url);//"\t\n" +
reqdata.put("payer",payer);
//String Signature=getSign(reqdata);
Map<String,String> info=getSign(reqdata);
@ -215,13 +215,13 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
//String url = String.format("https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code", appId, appSecret, code);
//String url="https://api.weixin.qq.com/sns/oauth2/access_token?appid="+appId+"&secret="+appSecret+"&code="+code+"&grant_type=authorization_code";
String url="https://api.weixin.qq.com/sns/jscode2session?appid="+appId+"&secret="+appSecret+"&js_code="+code+"&grant_type=authorization_code";
RestTemplate restTemplate = new RestTemplate();
Map<String, String> response = restTemplate.getForObject(url, Map.class);
//RestTemplate restTemplate = new RestTemplate();
//Map<String, Object> response = restTemplate.getForObject(url, Map.class);
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet(url);
try (CloseableHttpResponse response2 = httpClient.execute(httpGet)) {
String responseString = EntityUtils.toString(response2.getEntity());
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
String responseString = EntityUtils.toString(response.getEntity());
Map<String, Object> responseMap = JSONUtil.toBean(responseString, Map.class);
//打印出返回前端的所有参数
// 获取键的集合