|
|
@@ -630,14 +630,27 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
// 转跳参数
|
|
|
String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
|
+ String loginPhone = re.getLp();
|
|
|
+ String loginEmail = re.getLe();
|
|
|
+ String bindAccount = StrUtil.blankToDefault(loginPhone, loginEmail);
|
|
|
+ if (StrUtil.isNotBlank(bindAccount)) {
|
|
|
+ UserBindDetail bindDetail = getWxBindDetail(loginPhone, loginEmail);
|
|
|
+ if (bindDetail != null && bindDetail.getUserId() != null) {
|
|
|
+ return redisService.getStr(re.getMappingId().toString());
|
|
|
+ }
|
|
|
+ if (!redisService.setNx(RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getName() + bindAccount, bindAccount, RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getTimeout())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("account binding, please retry later");
|
|
|
+ }
|
|
|
+ bindDetail = getWxBindDetail(loginPhone, loginEmail);
|
|
|
+ if (bindDetail != null && bindDetail.getUserId() != null) {
|
|
|
+ return redisService.getStr(re.getMappingId().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
//保存用户信息
|
|
|
User user = saveAuth(userinfo, re, User.RegisterEnv.pc);
|
|
|
if (user == null) {
|
|
|
throw BusinessRuntimeException.getInstance("系统错误,请重新授权");
|
|
|
}
|
|
|
- String loginPhone = re.getLp();
|
|
|
- String loginEmail = re.getLe();
|
|
|
-
|
|
|
if (StrUtil.isNotBlank(loginPhone)) {
|
|
|
log.info("手机号phone:{}登录用户,微信扫描网页授权二维码进行用户信息绑定", loginPhone);
|
|
|
try {
|
|
|
@@ -658,6 +671,25 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
return redisService.getStr(re.getMappingId().toString());
|
|
|
}
|
|
|
|
|
|
+ private UserBindDetail getWxBindDetail(String loginPhone, String loginEmail) {
|
|
|
+ if (StrUtil.isNotBlank(loginPhone)) {
|
|
|
+ UserBindDetail bindDetail = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
|
+ .eq(UserBindDetail::getPhone, loginPhone)
|
|
|
+ .isNotNull(UserBindDetail::getUserId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (bindDetail != null) {
|
|
|
+ return bindDetail;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(loginEmail)) {
|
|
|
+ return userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
|
+ .eq(UserBindDetail::getEmail, loginEmail)
|
|
|
+ .isNotNull(UserBindDetail::getUserId)
|
|
|
+ .last("limit 1"));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public void receiveGiftCardByRc(Long userId, String code, Long relationId) {
|