Skip to content

Commit

Permalink
Merge pull request #219 from 9oormthon-univ/fix/wallet
Browse files Browse the repository at this point in the history
Fix/wallet
  • Loading branch information
HyunWoo9930 authored Dec 7, 2024
2 parents b4d2a3f + 2abcb3d commit 8de02ab
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -179,17 +180,21 @@ public WalletResponse getMyWallet(String userId) {
List<PointTransaction> transactions = pointTransactionRepository.findByUser(user);

List<PurchaseHistory> 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();

return new WalletResponse(user.getPoint(), purchaseHistories);
}


public UserHomeResponse getUserHome(String userId) {
User user = userRepository.findByProviderId(userId)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));
Expand Down

0 comments on commit 8de02ab

Please sign in to comment.