解决多小程序微信登陆渠道相同openId不同问题

This commit is contained in:
aikai 2024-12-05 11:34:00 +08:00
parent 08df74e4d7
commit 2cc51d9b4b
2 changed files with 7 additions and 5 deletions

View File

@ -21,7 +21,7 @@ public interface AdminOauthUserOtherInfoService {
*/ */
void checkInsert(Long userId, String appId, String openId, Integer socialType); void checkInsert(Long userId, String appId, String openId, Integer socialType);
AdminOauthUserOtherInfoDO getByCondition(Long userId, String appId, String openId, Integer socialType); AdminOauthUserOtherInfoDO getByCondition(Long userId, Integer socialType);
/** /**
* 通过社交类型+用户状态获取用户社交信息 * 通过社交类型+用户状态获取用户社交信息

View File

@ -24,22 +24,24 @@ public class AdminOauthUserOtherInfoServiceImpl implements AdminOauthUserOtherIn
@Override @Override
public void checkInsert(Long userId, String appId, String openId, Integer socialType) { public void checkInsert(Long userId, String appId, String openId, Integer socialType) {
AdminOauthUserOtherInfoDO adminOauthUserOtherInfoDOS = this.getByCondition(userId, appId, openId, socialType); AdminOauthUserOtherInfoDO adminOauthUserOtherInfoDOS = this.getByCondition(userId, socialType);
if (adminOauthUserOtherInfoDOS == null) { if (adminOauthUserOtherInfoDOS == null) {
adminOauthUserOtherInfoMapper.insert(new AdminOauthUserOtherInfoDO() adminOauthUserOtherInfoMapper.insert(new AdminOauthUserOtherInfoDO()
.setUserId(userId) .setUserId(userId)
.setAppId(appId) .setAppId(appId)
.setOpenId(openId) .setOpenId(openId)
.setSocialType(socialType)); .setSocialType(socialType));
} else {
if (!adminOauthUserOtherInfoDOS.getOpenId().equals(openId)) {
adminOauthUserOtherInfoMapper.updateById(adminOauthUserOtherInfoDOS.setOpenId(openId));
}
} }
} }
@Override @Override
public AdminOauthUserOtherInfoDO getByCondition(Long userId, String appId, String openId, Integer socialType) { public AdminOauthUserOtherInfoDO getByCondition(Long userId, Integer socialType) {
return adminOauthUserOtherInfoMapper.selectOne(new LambdaQueryWrapper<AdminOauthUserOtherInfoDO>() return adminOauthUserOtherInfoMapper.selectOne(new LambdaQueryWrapper<AdminOauthUserOtherInfoDO>()
.eq(AdminOauthUserOtherInfoDO::getUserId, userId) .eq(AdminOauthUserOtherInfoDO::getUserId, userId)
.eq(AdminOauthUserOtherInfoDO::getAppId, appId)
.eq(AdminOauthUserOtherInfoDO::getOpenId, openId)
.eq(AdminOauthUserOtherInfoDO::getSocialType, socialType)); .eq(AdminOauthUserOtherInfoDO::getSocialType, socialType));
} }