|
|
@ -391,11 +391,12 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
|
|
|
|
JSONObject wechatUserInfo = mpClientAppWechatApiProvider.getApi("merchant-app").appUserInfo(openId,user.getString("access_token"));
|
|
|
|
JSONObject wechatUserInfo = mpClientAppWechatApiProvider.getApi("merchant-app").appUserInfo(openId,user.getString("access_token"));
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
String nickName = wechatUserInfo.getString("nickname");
|
|
|
|
String nickName = wechatUserInfo.getString("nickname");
|
|
|
|
|
|
|
|
String unionId = wechatUserInfo.getString("unionid");
|
|
|
|
res.put("bind_status", false);
|
|
|
|
res.put("bind_status", false);
|
|
|
|
res.put("app_openid", openId);
|
|
|
|
res.put("app_openid", openId);
|
|
|
|
res.put("status", "success");
|
|
|
|
res.put("status", "success");
|
|
|
|
String expireMin = "5";
|
|
|
|
String expireMin = "5";
|
|
|
|
stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId,ip)).set(openId+"&"+nickName, Long.parseLong(expireMin), TimeUnit.MINUTES);
|
|
|
|
stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId,ip)).set(openId+"&"+nickName+"&"+unionId, Long.parseLong(expireMin), TimeUnit.MINUTES);
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String statusKey = newStatusKey();
|
|
|
|
String statusKey = newStatusKey();
|
|
|
@ -416,15 +417,19 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String verifyClientLoginWechatBindCode(String openId,String ip){
|
|
|
|
public JSONObject verifyClientLoginWechatBindCode(String openId,String ip){
|
|
|
|
String rediskey = getClientLoginWechatBindRedisKey(openId,ip);
|
|
|
|
String rediskey = getClientLoginWechatBindRedisKey(openId,ip);
|
|
|
|
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
|
|
|
|
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
|
|
|
|
if (codeValue == null || !codeValue.split("&")[0].equals(openId)) {
|
|
|
|
if (codeValue == null || !codeValue.split("&")[0].equals(openId)) {
|
|
|
|
throw new BadRequestException("The WeChat ID does not apply for binding");
|
|
|
|
throw new BadRequestException("The WeChat ID does not apply for binding");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String nickName = codeValue.split("&")[1];
|
|
|
|
String nickName = codeValue.split("&")[1];
|
|
|
|
|
|
|
|
String unionId = codeValue.split("&")[2];
|
|
|
|
stringRedisTemplate.delete(rediskey);
|
|
|
|
stringRedisTemplate.delete(rediskey);
|
|
|
|
return nickName;
|
|
|
|
return new JSONObject(){{
|
|
|
|
|
|
|
|
put("nick_name",nickName);
|
|
|
|
|
|
|
|
put("union_id",unionId);
|
|
|
|
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String getClientLoginPhoneBindRedisKey(String phone,String nationCode,String ip){
|
|
|
|
private String getClientLoginPhoneBindRedisKey(String phone,String nationCode,String ip){
|
|
|
|