|
@@ -1733,9 +1733,9 @@ public class HouseOrderController implements HouseOrderAPI {
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public CommonResult pay(WxPayDto wpd, BindingResult bindingResult, HttpServletRequest request) throws Exception {
|
|
public CommonResult pay(WxPayDto wpd, BindingResult bindingResult, HttpServletRequest request) throws Exception {
|
|
|
System.out.println(TimeExchange.getTime() + "微信支付参数====:" + JSON.toJSON(wpd));
|
|
System.out.println(TimeExchange.getTime() + "微信支付参数====:" + JSON.toJSON(wpd));
|
|
|
- String wxCode = request.getHeader("wxcode");
|
|
|
|
|
|
|
+ String wxCode = request.getHeader("openId");
|
|
|
if (wxCode == null || wxCode == "") {
|
|
if (wxCode == null || wxCode == "") {
|
|
|
- return CommonResult.fail("wxcode不能为空");
|
|
|
|
|
|
|
+ return CommonResult.fail("openId不能为空");
|
|
|
}
|
|
}
|
|
|
if (bindingResult.hasErrors()) {
|
|
if (bindingResult.hasErrors()) {
|
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
@@ -1842,18 +1842,19 @@ public class HouseOrderController implements HouseOrderAPI {
|
|
|
|
|
|
|
|
// jsapi支付
|
|
// jsapi支付
|
|
|
//获取openid
|
|
//获取openid
|
|
|
- String tokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token";
|
|
|
|
|
- tokenUrl = tokenUrl + "?code=" + wxCode + "&appid=" + wxPayV3Config.getAppId() + "&secret=" + wxPayV3Config.getSecret() + "&grant_type=authorization_code";
|
|
|
|
|
- RestTemplate client = new RestTemplate();
|
|
|
|
|
- String tokenResponse = client.postForObject(tokenUrl, null, String.class);
|
|
|
|
|
- log.info("获取openid结果" + tokenResponse);
|
|
|
|
|
- JSONObject jsonObject1 = JSONObject.parseObject(tokenResponse);
|
|
|
|
|
- String openId = (String) jsonObject1.getString("openid");
|
|
|
|
|
- if (openId == null || openId == "") {
|
|
|
|
|
- return CommonResult.fail("openid查询失败");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// String tokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token";
|
|
|
|
|
+// tokenUrl = tokenUrl + "?code=" + wxCode + "&appid=" + wxPayV3Config.getAppId() + "&secret=" + wxPayV3Config.getSecret() + "&grant_type=authorization_code";
|
|
|
|
|
+// RestTemplate client = new RestTemplate();
|
|
|
|
|
+// String tokenResponse = client.postForObject(tokenUrl, null, String.class);
|
|
|
|
|
+// log.info("获取openid结果" + tokenResponse);
|
|
|
|
|
+// JSONObject jsonObject1 = JSONObject.parseObject(tokenResponse);
|
|
|
|
|
+// String openId = (String) jsonObject1.getString("openid");
|
|
|
|
|
+// if (openId == null || openId == "") {
|
|
|
|
|
+// return CommonResult.fail("openid查询失败");
|
|
|
|
|
+// }
|
|
|
// String openId = "okdUu5xZ2ICm3RuMUHbpJi4DUyzw";
|
|
// String openId = "okdUu5xZ2ICm3RuMUHbpJi4DUyzw";
|
|
|
-// String openId = wxCode;
|
|
|
|
|
|
|
+ //改为直接传openId
|
|
|
|
|
+ String openId = wxCode;
|
|
|
PrepayRequest requestpay = new PrepayRequest();
|
|
PrepayRequest requestpay = new PrepayRequest();
|
|
|
requestpay.setAppid(wxPayV3Config.getAppId());
|
|
requestpay.setAppid(wxPayV3Config.getAppId());
|
|
|
requestpay.setMchid(wxPayV3Config.getMchId());
|
|
requestpay.setMchid(wxPayV3Config.getMchId());
|
|
@@ -3020,6 +3021,21 @@ public class HouseOrderController implements HouseOrderAPI {
|
|
|
return CommonResult.ok(reserveDayVos);
|
|
return CommonResult.ok(reserveDayVos);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CommonResult getPayOpenId(String wxcode) throws Exception {
|
|
|
|
|
+ String tokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token";
|
|
|
|
|
+ tokenUrl = tokenUrl + "?code=" + wxcode + "&appid=" + wxPayV3Config.getAppId() + "&secret=" + wxPayV3Config.getSecret() + "&grant_type=authorization_code";
|
|
|
|
|
+ RestTemplate client = new RestTemplate();
|
|
|
|
|
+ String tokenResponse = client.postForObject(tokenUrl, null, String.class);
|
|
|
|
|
+ log.info("获取openid结果" + tokenResponse);
|
|
|
|
|
+ JSONObject jsonObject1 = JSONObject.parseObject(tokenResponse);
|
|
|
|
|
+ String openId = (String) jsonObject1.getString("openid");
|
|
|
|
|
+ if (openId == null || openId == "") {
|
|
|
|
|
+ return CommonResult.fail("openid查询失败:"+tokenResponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonResult.ok(openId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
public static void main(String[] args) throws Exception {
|
|
|
// 获取签名
|
|
// 获取签名
|