|
|
@ -342,8 +342,8 @@ public class UserController { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定过微信"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定过微信"); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("appid", "wxa075e8509802f826"); |
|
|
|
params.put("appid", "wxadc7c8cd025639c6"); |
|
|
|
params.put("secret", "0e606fc1378d35e359fcf3f15570b2c5"); |
|
|
|
params.put("secret", "3b11012a83de870c2a81fb52d6427fce"); |
|
|
|
params.put("code", body.getString("code")); |
|
|
|
params.put("code", body.getString("code")); |
|
|
|
params.put("grant_type", "authorization_code"); |
|
|
|
params.put("grant_type", "authorization_code"); |
|
|
|
JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params); |
|
|
|
JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params); |
|
|
@ -358,6 +358,9 @@ public class UserController { |
|
|
|
if (userinfo == null || StringUtils.isBlank(userinfo.getString("openid"))) { |
|
|
|
if (userinfo == null || StringUtils.isBlank(userinfo.getString("openid"))) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取用户信息失败"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取用户信息失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (userService.getUserByWechatOpenId(userinfo.getString("openid")) != null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "微信已被绑定,无法重复绑定"); |
|
|
|
|
|
|
|
} |
|
|
|
BsUser user = userSession.getUser(); |
|
|
|
BsUser user = userSession.getUser(); |
|
|
|
user.setWechatOpenId(userinfo.getString("openid")); |
|
|
|
user.setWechatOpenId(userinfo.getString("openid")); |
|
|
|
user.setWechatUnionid(userinfo.getString("unionid")); |
|
|
|
user.setWechatUnionid(userinfo.getString("unionid")); |
|
|
|