|
|
|
@ -391,11 +391,12 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
|
|
|
|
|
JSONObject wechatUserInfo = mpClientAppWechatApiProvider.getApi("merchant-app").appUserInfo(openId,user.getString("access_token"));
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
String nickName = wechatUserInfo.getString("nickname");
|
|
|
|
|
String unionId = wechatUserInfo.getString("unionid");
|
|
|
|
|
res.put("bind_status", false);
|
|
|
|
|
res.put("app_openid", openId);
|
|
|
|
|
res.put("status", "success");
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
String statusKey = newStatusKey();
|
|
|
|
@ -416,15 +417,19 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String verifyClientLoginWechatBindCode(String openId,String ip){
|
|
|
|
|
public JSONObject verifyClientLoginWechatBindCode(String openId,String ip){
|
|
|
|
|
String rediskey = getClientLoginWechatBindRedisKey(openId,ip);
|
|
|
|
|
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
|
|
|
|
|
if (codeValue == null || !codeValue.split("&")[0].equals(openId)) {
|
|
|
|
|
throw new BadRequestException("The WeChat ID does not apply for binding");
|
|
|
|
|
}
|
|
|
|
|
String nickName = codeValue.split("&")[1];
|
|
|
|
|
String unionId = codeValue.split("&")[2];
|
|
|
|
|
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){
|
|
|
|
|