Tayl0r 7 years ago
parent 02e3d58be7
commit e5c48fad29

@ -12,6 +12,7 @@ import au.com.royalpay.payment.tools.utils.QRCodeUtils;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -264,6 +265,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
JSONObject res = new JSONObject();
res.put("code_id", codeId);
res.put("code_img", QRCodeUtils.qrcodeImageCode(PlatformEnvironment.getEnv().concatUrl("/global/userstatus/partner_signin_wechat_qrcode/" + codeId), 300,false));
lockRandomCodeId(codeId);
return res;
}
@ -273,11 +275,13 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
JSONObject res = new JSONObject();
res.put("code_id", codeId);
res.put("code_img", QRCodeUtils.qrcodeImageCode(PlatformEnvironment.getEnv().concatUrl("/global/userstatus/partner_signin_qrcode/verify/" + codeId), 300,false));
lockRandomCodeId(codeId);
return res;
}
@Override
public void clientQRCodeAppSignIn(JSONObject device,String codeId) {
getlockRandomCodeId(codeId);
String statusKey = newStatusKey();
JSONObject account = new JSONObject();
if (device != null && device.size() > 0) {
@ -292,6 +296,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
@Override
public void clientQRCodeWechatSignIn(JSONObject wxUser,String codeId) {
getlockRandomCodeId(codeId);
String statusKey = newStatusKey();
JSONObject account = new JSONObject();
if (wxUser != null && wxUser.size() > 0) {
@ -314,4 +319,16 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
return statusKey;
}
private void lockRandomCodeId(String codeId) {
stringRedisTemplate.boundValueOps(redisPrefix + "partner_signin" + codeId).set(codeId, 30, TimeUnit.SECONDS);
}
private void getlockRandomCodeId(String codeId) {
String existId = stringRedisTemplate.boundValueOps(redisPrefix + "partner_signin" + codeId).get();
if (StringUtils.isEmpty(existId)) {
throw new ForbiddenException("该二维码已过期,请重新获取");
}
}
}

Loading…
Cancel
Save