fix(console): allow admin country changes
This commit is contained in:
parent
26d1c909f0
commit
305d511c19
@ -206,7 +206,7 @@ public class UserBaseInfoServiceImpl implements
|
||||
|
||||
boolean countryChanged = countryChanged(param, currentProfile);
|
||||
if (countryChanged) {
|
||||
fillCountryAndAssertAllowed(param, currentProfile);
|
||||
fillConsoleCountry(param, currentProfile);
|
||||
}
|
||||
|
||||
userProfileClient.updateSelectiveById(userAppConvertor.toUserBaseInfoCmd(param));
|
||||
@ -228,52 +228,20 @@ public class UserBaseInfoServiceImpl implements
|
||||
&& !Objects.equals(param.getCountryId(), currentProfile.getCountryId());
|
||||
}
|
||||
|
||||
private void fillCountryAndAssertAllowed(UserProfileUpdateCmd param,
|
||||
private void fillConsoleCountry(UserProfileUpdateCmd param,
|
||||
UserProfileDTO currentProfile) {
|
||||
SysCountryCodeDTO country = ResponseAssert.requiredSuccess(
|
||||
countryCodeClient.getById(param.getCountryId()));
|
||||
ResponseAssert.notNull(UserErrorCode.SYS_REGION_NOT_EXIST_ERROR, country);
|
||||
|
||||
boolean locked = hasCountryLockedIdentity(param.getId());
|
||||
log.warn("console country-change identity check userId={}, locked={}, currentCountryId={}, targetCountryId={}",
|
||||
param.getId(), locked, currentProfile.getCountryId(), param.getCountryId());
|
||||
// 国家变更只限制平台身份用户;普通用户允许后台多次调整并同步房间国家。
|
||||
ResponseAssert.isFalse(UserErrorCode.USER_COUNTRY_UPDATE_NOT_ALLOWED, locked);
|
||||
// 后台用户资料编辑是最高权限路径,只校验目标国家有效,不受主播/代理/BD 等用户身份限制。
|
||||
log.warn("console country-change userId={}, currentCountryId={}, targetCountryId={}",
|
||||
param.getId(), currentProfile.getCountryId(), param.getCountryId());
|
||||
|
||||
param.setCountryCode(country.getAlphaTwo());
|
||||
param.setCountryName(country.getCountryName());
|
||||
}
|
||||
|
||||
private boolean hasCountryLockedIdentity(Long userId) {
|
||||
TeamMemberDTO teamMember = getTeamMember(userId);
|
||||
boolean anchor = Objects.nonNull(teamMember);
|
||||
boolean agent = anchor && TeamMemberRole.OWN.eq(teamMember.getRole());
|
||||
boolean bd = checkBd(userId);
|
||||
boolean bdLeader = checkBdLeader(userId);
|
||||
log.warn("console country-change identity detail userId={}, anchor={}, agent={}, bd={}, bdLeader={}, teamMemberRole={}",
|
||||
userId, anchor, agent, bd, bdLeader,
|
||||
Objects.isNull(teamMember) ? null : teamMember.getRole());
|
||||
return anchor || agent || bd || bdLeader;
|
||||
}
|
||||
|
||||
private TeamMemberDTO getTeamMember(Long userId) {
|
||||
try {
|
||||
return ResponseAssert.requiredSuccess(teamProfileClient.getByMemberId(userId));
|
||||
} catch (Exception ex) {
|
||||
log.warn("console country-change team member check failed, treat as no team member, userId={}",
|
||||
userId, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkBd(Long userId) {
|
||||
return Boolean.TRUE.equals(ResponseAssert.requiredSuccess(bdTeamInfoClient.check(userId)));
|
||||
}
|
||||
|
||||
private boolean checkBdLeader(Long userId) {
|
||||
return Boolean.TRUE.equals(ResponseAssert.requiredSuccess(bdTeamLeaderClient.check(userId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVestUserInfo(UserBaseInfoCmd cmd) {
|
||||
cmd.setUpdateTime(TimestampUtils.now());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user