修复问题

This commit is contained in:
2026-03-01 20:44:29 +08:00
parent 00d60b78c4
commit be427ca931
6 changed files with 123 additions and 13 deletions

View File

@@ -124,10 +124,8 @@ public class MemberUserProfileServiceImpl implements MemberUserProfileService {
@Override
public void validateStorage(String userId, long fileSizeBytes) {
MemberUserProfileDO profile = memberUserProfileMapper.selectByUserId(userId);
if (profile == null) {
throw exception(new ErrorCode(1004, "会员用户档案不存在"));
}
// 档案不存在时自动创建(兼容旧用户)
MemberUserProfileDO profile = createIfAbsent(Long.parseLong(userId));
// 将剩余存储空间GB转换为字节进行比较
BigDecimal remainingBytes = profile.getRemainingStorage().multiply(GB_TO_BYTES);
@@ -138,6 +136,9 @@ public class MemberUserProfileServiceImpl implements MemberUserProfileService {
@Override
public boolean increaseUsedStorage(String userId, long fileSizeBytes) {
// 确保档案存在(兼容旧用户)
createIfAbsent(Long.parseLong(userId));
// 将字节转换为GB保留6位小数
BigDecimal storageGb = new BigDecimal(fileSizeBytes).divide(GB_TO_BYTES, 6, RoundingMode.HALF_UP);
String storageGbStr = storageGb.toPlainString();
@@ -148,6 +149,9 @@ public class MemberUserProfileServiceImpl implements MemberUserProfileService {
@Override
public boolean decreaseUsedStorage(String userId, long fileSizeBytes) {
// 确保档案存在(兼容旧用户)
createIfAbsent(Long.parseLong(userId));
// 将字节转换为GB保留6位小数
BigDecimal storageGb = new BigDecimal(fileSizeBytes).divide(GB_TO_BYTES, 6, RoundingMode.HALF_UP);
String storageGbStr = storageGb.toPlainString();