diff --git a/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/ConsoleAccountStatusEnum.java b/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/ConsoleAccountStatusEnum.java index 829e7184..31ed4ea2 100644 --- a/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/ConsoleAccountStatusEnum.java +++ b/rc-common-business/common-business-dto/src/main/java/com/red/circle/common/business/enums/ConsoleAccountStatusEnum.java @@ -39,7 +39,7 @@ public enum ConsoleAccountStatusEnum { /** * 账号解封. */ - UNTIE_ACOOUNT("UNTIE_DEVICE", "账号解封"), + UNTIE_ACOOUNT("UNTIE_ACOOUNT", "账号解封"), /** * 设备+账户解封. diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/user/UserAccountCommon.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/user/UserAccountCommon.java index 396bb907..323e7794 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/user/UserAccountCommon.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/user/UserAccountCommon.java @@ -246,10 +246,10 @@ public class UserAccountCommon { * 解封账号. */ public void unblock(UnblockAccountCmd cmd) { - userProfileGateway.removeCacheAll(cmd.getBeOptUserId()); if (!baseInfoService.updateAccountStatus(cmd.getBeOptUserId(), AccountStatusEnum.NORMAL)) { return; } + userProfileGateway.removeCacheAll(cmd.getBeOptUserId()); // 记录日志 approvalUserAccountStatusLogService.save(new ApprovalUserAccountStatusLog() diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserAccountClientServiceImpl.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserAccountClientServiceImpl.java index f4000c75..74eaf52f 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserAccountClientServiceImpl.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/user/user/impl/UserAccountClientServiceImpl.java @@ -263,17 +263,29 @@ public class UserAccountClientServiceImpl implements UserAccountClientService { @Override public boolean updateAccountFreeze(Long userId, Integer days) { - return baseInfoService.updateAccountFreeze(userId, days); + boolean updated = baseInfoService.updateAccountFreeze(userId, days); + if (updated) { + userProfileGateway.removeCacheAll(userId); + } + return updated; } @Override public boolean updateAccountStatus(Long userId, AccountStatusEnum accountStatus) { - return baseInfoService.updateAccountStatus(userId, accountStatus); + boolean updated = baseInfoService.updateAccountStatus(userId, accountStatus); + if (updated) { + userProfileGateway.removeCacheAll(userId); + } + return updated; } @Override public boolean updateAccountStatusDays(Long userId, AccountStatusEnum accountStatus, Integer days) { - return baseInfoService.updateAccountStatusDays(userId, accountStatus, days); + boolean updated = baseInfoService.updateAccountStatusDays(userId, accountStatus, days); + if (updated) { + userProfileGateway.removeCacheAll(userId); + } + return updated; } @Override @@ -388,9 +400,12 @@ public class UserAccountClientServiceImpl implements UserAccountClientService { public UserAccountDTO createUserAccountDTO(Long userId, String imei, VoidConsumer voidConsumer) { - UserProfile userProfile = userProfileGateway.getByUserId(userId); - userProfile.setFamilyId(Optional.ofNullable(familyMemberInfoService.getFamilyMemberByUserId(userId)).map(FamilyMemberInfo::getFamilyId).orElse(null)); + UserProfile userProfile = refreshStaleAccountStatus(userId, + userProfileGateway.getByUserId(userId)); ResponseAssert.notNull(CommonErrorCode.DATA_ERROR, userProfile); + userProfile.setFamilyId(Optional.ofNullable(familyMemberInfoService.getFamilyMemberByUserId(userId)) + .map(FamilyMemberInfo::getFamilyId) + .orElse(null)); // 注册黑名单 if (Objects.equals(userProfile.getDel(), Boolean.TRUE)) { @@ -431,6 +446,22 @@ public class UserAccountClientServiceImpl implements UserAccountClientService { return errorCode.getMessage() + "[ ID:" + userProfile.getAccount() + "]"; } + private UserProfile refreshStaleAccountStatus(Long userId, UserProfile userProfile) { + if (Objects.isNull(userProfile) || userProfile.checkAccountAvailable()) { + return userProfile; + } + + BaseInfo baseInfo = baseInfoService.getById(userId); + if (Objects.isNull(baseInfo) + || (Objects.equals(baseInfo.getAccountStatus(), userProfile.getAccountStatus()) + && Objects.equals(baseInfo.getFreezingTime(), userProfile.getFreezingTime()))) { + return userProfile; + } + + userProfileGateway.removeCacheAll(userId); + return userProfileGateway.getByUserId(userId); + } + private void sendLoginMessage(AuthTypeEnum authTypeEnum, AppExtCommand cmd) { userMqMessageService.loginLogger(Objects.toString(cmd.requiredReqUserId()), userProfileInnerConvertor.toLoginLoggerEventLogin(authTypeEnum, cmd));