|
@@ -798,5 +798,47 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
|
|
|
return emptyPage;
|
|
return emptyPage;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean disableSubAccount(Long id) {
|
|
|
|
|
+ if (id == null) {
|
|
|
|
|
+ log.error("子账号关联记录ID不能为空");
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 1. 先查询记录是否存在
|
|
|
|
|
+ StorePlatformUserRole userRole = storePlatformUserRoleMapper.selectById(id);
|
|
|
|
|
+ if (userRole == null) {
|
|
|
|
|
+ log.error("子账号关联记录不存在: id={}", id);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 检查当前状态
|
|
|
|
|
+ if (userRole.getStatus() != null && userRole.getStatus() == 1) {
|
|
|
|
|
+ log.warn("子账号已经是禁用状态: id={}", id);
|
|
|
|
|
+ return true; // 已经是禁用状态,返回成功
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 更新状态为禁用(1)
|
|
|
|
|
+ LambdaUpdateWrapper<StorePlatformUserRole> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.eq(StorePlatformUserRole::getId, id)
|
|
|
|
|
+ .eq(StorePlatformUserRole::getDeleteFlag, 0) // 只更新未删除的记录
|
|
|
|
|
+ .set(StorePlatformUserRole::getStatus, 1); // 1代表禁用
|
|
|
|
|
+
|
|
|
|
|
+ int updateResult = storePlatformUserRoleMapper.update(null, updateWrapper);
|
|
|
|
|
+ if (updateResult > 0) {
|
|
|
|
|
+ log.info("成功禁用子账号: id={}, userId={}, storeId={}, roleId={}",
|
|
|
|
|
+ id, userRole.getUserId(), userRole.getStoreId(), userRole.getRoleId());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("禁用子账号失败: id={}", id);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("禁用子账号异常: id={}", id, e);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|