diff --git a/src/main/java/com/jangburich/domain/user/service/UserService.java b/src/main/java/com/jangburich/domain/user/service/UserService.java index 6a6a660..9e8a034 100644 --- a/src/main/java/com/jangburich/domain/user/service/UserService.java +++ b/src/main/java/com/jangburich/domain/user/service/UserService.java @@ -16,6 +16,7 @@ import com.jangburich.domain.owner.domain.Owner; import com.jangburich.domain.owner.domain.repository.OwnerRepository; import com.jangburich.domain.point.domain.PointTransaction; +import com.jangburich.domain.point.domain.TransactionType; import com.jangburich.domain.point.domain.repository.PointTransactionRepository; import com.jangburich.domain.store.domain.Store; import com.jangburich.domain.store.repository.StoreRepository; @@ -179,10 +180,13 @@ public WalletResponse getMyWallet(String userId) { List transactions = pointTransactionRepository.findByUser(user); List purchaseHistories = transactions.stream() + .filter(transaction -> transaction.getTransactionType() != TransactionType.FOOD_PURCHASE) .sorted(Comparator.comparing(PointTransaction::getCreatedAt).reversed()) .map(transaction -> new PurchaseHistory( transaction.getCreatedAt().format(DateTimeFormatter.ofPattern("MM.dd")), - transaction.getTransactionedPoint(), + transaction.getTransactionType() == TransactionType.PREPAY + ? -transaction.getTransactionedPoint() + : transaction.getTransactionedPoint(), transaction.getStore() != null ? transaction.getStore().getName() : "장부리치 지갑", transaction.getTransactionType().getDisplayName())) .toList(); @@ -190,6 +194,7 @@ public WalletResponse getMyWallet(String userId) { return new WalletResponse(user.getPoint(), purchaseHistories); } + public UserHomeResponse getUserHome(String userId) { User user = userRepository.findByProviderId(userId) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));