|
@@ -311,8 +311,8 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
|
|
|
return CommonResult.fail("请传入code");
|
|
return CommonResult.fail("请传入code");
|
|
|
}
|
|
}
|
|
|
String url = "https://api.weixin.qq.com/sns/jscode2session?" +
|
|
String url = "https://api.weixin.qq.com/sns/jscode2session?" +
|
|
|
- "appid=" + PropertiesUtil.getValue(HttpParame.APPID) +
|
|
|
|
|
- "&secret=" + PropertiesUtil.getValue(HttpParame.SECRET) +
|
|
|
|
|
|
|
+ "appid=" + PropertiesUtil.getValue(HttpParame.APPIDX) +
|
|
|
|
|
+ "&secret=" + PropertiesUtil.getValue(HttpParame.SECRETX) +
|
|
|
"&js_code=" + code +
|
|
"&js_code=" + code +
|
|
|
"&grant_type=authorization_code";
|
|
"&grant_type=authorization_code";
|
|
|
|
|
|
|
@@ -325,11 +325,15 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
return CommonResult.fail("code异常");
|
|
return CommonResult.fail("code异常");
|
|
|
}
|
|
}
|
|
|
- SmartUser user = wechatScanLoginService.selectByOpenid(openid);
|
|
|
|
|
- if (user==null){
|
|
|
|
|
|
|
+ QueryWrapper<SmartUser> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper1.eq("deleted", 0);
|
|
|
|
|
+ queryWrapper1.eq("is_cancel",0);
|
|
|
|
|
+ queryWrapper1.eq("x_open_id", openid);
|
|
|
|
|
+ List<SmartUser> user = smartUserService.list(queryWrapper1);
|
|
|
|
|
+ if (user.isEmpty()){
|
|
|
return CommonResult.fail("请绑定后再进入");
|
|
return CommonResult.fail("请绑定后再进入");
|
|
|
}
|
|
}
|
|
|
- String token = JWTUtil.getToken(user);
|
|
|
|
|
|
|
+ String token = JWTUtil.getToken(user.get(0));
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("token", token);
|
|
jsonObject.put("token", token);
|
|
|
jsonObject.put("user", user);
|
|
jsonObject.put("user", user);
|
|
@@ -392,19 +396,20 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
|
|
|
return CommonResult.fail("请传入wxcode");
|
|
return CommonResult.fail("请传入wxcode");
|
|
|
}
|
|
}
|
|
|
String url = "https://api.weixin.qq.com/sns/jscode2session?" +
|
|
String url = "https://api.weixin.qq.com/sns/jscode2session?" +
|
|
|
- "appid=" + PropertiesUtil.getValue(HttpParame.APPID) +
|
|
|
|
|
- "&secret=" + PropertiesUtil.getValue(HttpParame.SECRET) +
|
|
|
|
|
|
|
+ "appid=" + PropertiesUtil.getValue(HttpParame.APPIDX) +
|
|
|
|
|
+ "&secret=" + PropertiesUtil.getValue(HttpParame.SECRETX) +
|
|
|
"&js_code=" + wxcode +
|
|
"&js_code=" + wxcode +
|
|
|
"&grant_type=authorization_code";
|
|
"&grant_type=authorization_code";
|
|
|
|
|
|
|
|
String json = HttpClientUtils.getInstance().sendHttpGet(url);
|
|
String json = HttpClientUtils.getInstance().sendHttpGet(url);
|
|
|
|
|
+ System.out.println(json);
|
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
|
HashMap<String, String> userMap = gson.fromJson(json.toString(), new TypeToken<HashMap<String, String>>() {}.getType());
|
|
HashMap<String, String> userMap = gson.fromJson(json.toString(), new TypeToken<HashMap<String, String>>() {}.getType());
|
|
|
String openid = "";
|
|
String openid = "";
|
|
|
try {
|
|
try {
|
|
|
openid = userMap.get("openid").toString();
|
|
openid = userMap.get("openid").toString();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- return CommonResult.fail("code异常");
|
|
|
|
|
|
|
+ return CommonResult.fail("wxcode异常");
|
|
|
}
|
|
}
|
|
|
QueryWrapper<SmartUser> queryWrapper2 = new QueryWrapper<>();
|
|
QueryWrapper<SmartUser> queryWrapper2 = new QueryWrapper<>();
|
|
|
queryWrapper2.eq("deleted", 0);
|
|
queryWrapper2.eq("deleted", 0);
|
|
@@ -413,7 +418,7 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
|
|
|
if (user.isEmpty()){
|
|
if (user.isEmpty()){
|
|
|
return CommonResult.fail("该用户不存在");
|
|
return CommonResult.fail("该用户不存在");
|
|
|
}
|
|
}
|
|
|
- user.get(0).setOpenId(openid);
|
|
|
|
|
|
|
+ user.get(0).setXOpenId(openid);
|
|
|
smartUserService.updateSmartUser(user.get(0));
|
|
smartUserService.updateSmartUser(user.get(0));
|
|
|
String token = JWTUtil.getToken(user.get(0));
|
|
String token = JWTUtil.getToken(user.get(0));
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|