Skip to content

Commit

Permalink
Merge branch '9oormthon-univ:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEJaeHyeok97 authored Dec 7, 2024
2 parents 4add58f + f8ef18e commit 64b8aef
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

import com.jangburich.domain.payment.domain.repository.TeamChargeHistoryRepository;
import com.jangburich.domain.payment.dto.request.PayRequest;
import com.jangburich.domain.payment.dto.response.ApproveResponse;
import com.jangburich.domain.payment.dto.response.ReadyResponse;
Expand Down Expand Up @@ -82,14 +81,6 @@ public ReadyResponse payReady(String userId, PayRequest payRequest) {

readyResponseResponseEntity = template.postForEntity(url, requestEntity, ReadyResponse.class);

PointTransaction pointTransaction = PointTransaction.builder()
.user(user)
.transactionedPoint(Integer.valueOf(payRequest.totalAmount()))
.transactionType(TransactionType.POINT_PURCHASE)
.build();

pointTransactionRepository.save(pointTransaction);

return readyResponseResponseEntity.getBody();
}

Expand All @@ -112,7 +103,15 @@ public ApproveResponse payApprove(String pgToken) {

User user = userRepository.findByProviderId(userId)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));
user.setPoint(user.getPoint() + Integer.valueOf(payRequest.totalAmount()));
user.setPoint(user.getPoint() + Integer.parseInt(payRequest.totalAmount()));

PointTransaction pointTransaction = PointTransaction.builder()
.user(user)
.transactionedPoint(Integer.valueOf(payRequest.totalAmount()))
.transactionType(TransactionType.POINT_PURCHASE)
.build();

pointTransactionRepository.save(pointTransaction);

return approveResponse;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class PrepaymentInfoResponse {
private Long minPrepayAmount;
private Integer wallet;
private Integer remainPrepay;
private String category;
private String storeName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public PrepaymentInfoResponse getPrepayInfo(String userId, Long storeId, Long te
}
prepaymentInfoResponse.setMinPrepayAmount(store.getMinPrepayment());
prepaymentInfoResponse.setWallet(user.getPoint());
prepaymentInfoResponse.setCategory(store.getCategory().getDisplayName());
prepaymentInfoResponse.setStoreName(store.getName());
return prepaymentInfoResponse;
}
}
25 changes: 15 additions & 10 deletions src/main/java/com/jangburich/domain/store/service/StoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,17 @@ public PaymentGroupDetailResponse getPaymentGroupDetail(String userId, Long team

List<Orders> orders = ordersRepository.findAllByTeam(team);

List<OrderResponse> orderResponse = orders.stream().map(order -> {
int price = 0;
for (Cart cart : cartRepository.findAllByOrders(order)) {
price += cart.getMenu().getPrice();
}
return new OrderResponse(order.getId(), order.getUser().getName(), order.getUpdatedAt(),
String.valueOf(price));
}).toList();
List<OrderResponse> orderResponse = orders.stream()
.map(order -> {
int price = 0;
for (Cart cart : cartRepository.findAllByOrders(order)) {
price += cart.getMenu().getPrice();
}
return new OrderResponse(order.getId(), order.getUser().getName(), order.getUpdatedAt(),
String.valueOf(price));
})
.sorted(Comparator.comparing(OrderResponse::getDate).reversed())
.toList();

return PaymentGroupDetailResponse.create(team, storeTeam.getPoint(), storeTeam.getRemainPoint(),
teamLeader, orderResponse);
Expand All @@ -316,7 +319,9 @@ public List<StoreChargeHistoryResponse> getPaymentHistory(String userId) {
Store store = storeRepository.findByOwner(owner)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));

return pointTransactionRepository.findAllByStore(store);
return pointTransactionRepository.findAllByStore(store).stream()
.sorted(Comparator.comparing(StoreChargeHistoryResponse::createdAt).reversed()) // ์ตœ์‹ ์ˆœ ์ •๋ ฌ
.toList();
}

public List<OrdersGetResponse> getOrdersLast(String userId) {
Expand Down Expand Up @@ -461,7 +466,7 @@ public byte[] createExcel(String userId, Integer period) {
Row headerRow = sheet.createRow(0);

// ํ—ค๋” ์Šคํƒ€์ผ ์ƒ์„ฑ
XSSFCellStyle headerStyle = (XSSFCellStyle) sheet.getWorkbook().createCellStyle();
XSSFCellStyle headerStyle = (XSSFCellStyle)sheet.getWorkbook().createCellStyle();

// ํ—ฅ์‚ฌ ์ƒ‰์ƒ ์„ค์ •
XSSFColor customColor = new XSSFColor(Color.decode("#FF7048"), null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jangburich.domain.user.service;

import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -178,12 +179,14 @@ public WalletResponse getMyWallet(String userId) {
List<PointTransaction> transactions = pointTransactionRepository.findByUser(user);

List<PurchaseHistory> purchaseHistories = transactions.stream()
.sorted(Comparator.comparing(PointTransaction::getCreatedAt).reversed())
.map(transaction -> new PurchaseHistory(
transaction.getCreatedAt().format(DateTimeFormatter.ofPattern("MM.dd")),
transaction.getTransactionedPoint(),
transaction.getStore() != null ? transaction.getStore().getName() : "์•Œ ์ˆ˜ ์—†์Œ",
transaction.getStore() != null ? transaction.getStore().getName() : "์žฅ๋ถ€๋ฆฌ์น˜ ์ง€๊ฐ‘",
transaction.getTransactionType().getDisplayName()))
.toList();

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

Expand Down

0 comments on commit 64b8aef

Please sign in to comment.