-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: 포인트 결제 관련 core payment 로직 추가 #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
e06f825
6e6baca
07e7b7e
e4f7a68
879daa7
4745174
4a26a4d
87b6d58
7dbbb34
f8f2e63
dba1d0c
6a815c0
378e341
ea77043
f5b4c66
9f770c8
a735944
ec76dc6
c632395
3e57857
39aa1dc
27089d4
90773b9
bd0e761
a6e895d
517339a
8c3a5a2
8b099cc
aee4c35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,18 @@ | ||
| package com.fisa.core_payment_service.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Positive; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public record AmountRequestDto(String userUuid, BigDecimal amount) { | ||
| public record AmountRequestDto( | ||
|
|
||
| @NotBlank(message = "사용자 UUID는 필수입니다.") | ||
| String userUuid, | ||
|
|
||
| @NotNull(message = "금액은 필수입니다.") | ||
| @Positive(message = "금액은 0보다 커야 합니다.") | ||
| BigDecimal amount | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||||||||||
| package com.fisa.core_payment_service.dto; | ||||||||||||||
|
|
||||||||||||||
| import lombok.AllArgsConstructor; | ||||||||||||||
| import lombok.Getter; | ||||||||||||||
| import lombok.NoArgsConstructor; | ||||||||||||||
| import lombok.ToString; | ||||||||||||||
|
|
||||||||||||||
| @Getter | ||||||||||||||
| @NoArgsConstructor | ||||||||||||||
| @AllArgsConstructor | ||||||||||||||
| @ToString | ||||||||||||||
| public class CashRequestDTO { | ||||||||||||||
| private String orderId; // 트랜잭션 ID (Saga 추적용) | ||||||||||||||
| private String loginId; // 사용자 식별자 (userUuid) | ||||||||||||||
| private Long amount; // 출금액 | ||||||||||||||
|
||||||||||||||
| private String orderId; // 트랜잭션 ID (Saga 추적용) | |
| private String loginId; // 사용자 식별자 (userUuid) | |
| private Long amount; // 출금액 | |
| private String orderId; // 트랜잭션 ID (Saga 추적용) | |
| private String userUuid; // 사용자 식별자 | |
| private Long amount; // 출금액 |
🤖 Prompt for AI Agents
In
`@on-premise/core-payment-service/src/main/java/com/fisa/core_payment_service/dto/CashRequestDTO.java`
around lines 13 - 15, Rename the misleading field loginId in CashRequestDTO to
userUuid and update all references/usages accordingly: change the field and its
getter/setter in class CashRequestDTO (previously loginId) to userUuid, update
any code calling requestDto.getLoginId()/setLoginId(...) to
getUserUuid()/setUserUuid(...), update mappings to CashResponseDTO so its
userUuid receives the same value, and adjust service/repository calls such as
accountRepository.findByUserUuid(requestDto.getLoginId()) to use
requestDto.getUserUuid(); ensure compilation and API contract tests across
msa-point-service and core-payment-service are updated to reflect the new name.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.fisa.core_payment_service.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.ToString; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @ToString | ||
| public class CashResponseDTO { | ||
| private String orderId; | ||
| private String userUuid; | ||
| private String status; // "SUCCESS" or "FAIL" | ||
| private String message; | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,21 +2,28 @@ | |||||||||
|
|
||||||||||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||||||||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||||||||
| import com.fisa.core_payment_service.domain.Account; | ||||||||||
| import com.fisa.core_payment_service.dto.CashRequestDTO; | ||||||||||
| import com.fisa.core_payment_service.dto.CashResponseDTO; | ||||||||||
| import com.fisa.core_payment_service.dto.CouponIssueMessage; | ||||||||||
| import com.fisa.core_payment_service.dto.DepositMessage; | ||||||||||
| import com.fisa.core_payment_service.repository.AccountRepository; | ||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||
| import lombok.extern.slf4j.Slf4j; | ||||||||||
| import org.springframework.kafka.annotation.KafkaListener; | ||||||||||
| import org.springframework.stereotype.Service; | ||||||||||
|
|
||||||||||
| import java.math.BigDecimal; | ||||||||||
|
|
||||||||||
| @Slf4j | ||||||||||
| @Service | ||||||||||
| @RequiredArgsConstructor | ||||||||||
| public class KafkaConsumerService { | ||||||||||
|
|
||||||||||
| private final PaymentService paymentService; | ||||||||||
| private final CouponManageService couponService; | ||||||||||
| private final ObjectMapper objectMapper; | ||||||||||
| private final AccountRepository accountRepository; | ||||||||||
| private final KafkaProducerService kafkaProducerService; | ||||||||||
|
|
||||||||||
| // 1. 입금 처리 | ||||||||||
| @KafkaListener(topics = "bank_deposit", groupId = "core-group") | ||||||||||
|
|
@@ -25,7 +32,7 @@ public void consumeDeposit(String message) { | |||||||||
| DepositMessage depositDto = objectMapper.readValue(message, DepositMessage.class); | ||||||||||
|
|
||||||||||
| paymentService.deposit( | ||||||||||
| depositDto.getAccountNo(), | ||||||||||
| depositDto.getAccountNo(), // ★ 수정됨 (getAccountNumber() -> getAccountNo()) | ||||||||||
| depositDto.getUserUuid(), | ||||||||||
| depositDto.getAmount() | ||||||||||
| ); | ||||||||||
|
|
@@ -39,14 +46,58 @@ public void consumeDeposit(String message) { | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // 2. 쿠폰 처리 | ||||||||||
| @KafkaListener(topics = "coupon_issue", groupId = "core-group") | ||||||||||
| public void consumeCouponIssue(String message) { | ||||||||||
|
|
||||||||||
| // 2. 현금 출금 처리 (PointService와 연결) | ||||||||||
| @KafkaListener(topics = "core-withdraw-request", groupId = "core-group") | ||||||||||
| public void consumeWithdraw(String message) { | ||||||||||
|
|
||||||||||
| CashRequestDTO requestDto = null; | ||||||||||
|
|
||||||||||
| try { | ||||||||||
| CouponIssueMessage couponDto = objectMapper.readValue(message, CouponIssueMessage.class); | ||||||||||
| couponService.issueCoupon(couponDto); | ||||||||||
| // (1) 메시지 파싱 | ||||||||||
| requestDto = objectMapper.readValue(message, CashRequestDTO.class); | ||||||||||
| log.info("📉 [Core] 출금 요청 수신: {}", requestDto); | ||||||||||
|
|
||||||||||
|
Comment on lines
+58
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, find the file structure to locate the relevant files
find . -name "KafkaConsumerService.java" -type fRepository: FISA-Team-CE/tech-semina-msa Length of output: 183 🏁 Script executed: # Find the CashRequestDTO class
find . -name "CashRequestDTO.java" -type fRepository: FISA-Team-CE/tech-semina-msa Length of output: 278 🏁 Script executed: # Look for the directory structure of the payment service
find . -path "*core-payment-service*" -type d | head -20Repository: FISA-Team-CE/tech-semina-msa Length of output: 1280 🏁 Script executed: # Read the KafkaConsumerService.java file around lines 58-60
cat -n ./on-premise/core-payment-service/src/main/java/com/fisa/core_payment_service/service/KafkaConsumerService.java | sed -n '50,70p'Repository: FISA-Team-CE/tech-semina-msa Length of output: 1044 🏁 Script executed: # Read the entire CashRequestDTO class to see all fields
cat -n ./on-premise/core-payment-service/src/main/java/com/fisa/core_payment_service/dto/CashRequestDTO.javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 565 출금 요청 로그에서 민감정보 노출 방지 필요 라인 59에서 🔒 제안 변경- log.info("📉 [Core] 출금 요청 수신: {}", requestDto);
+ log.info("📉 [Core] 출금 요청 수신: orderId={}", requestDto.getOrderId());📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| // (2) 계좌 조회 | ||||||||||
| Account account = accountRepository.findByUserUuid(requestDto.getLoginId()) | ||||||||||
| .orElseThrow(() -> new IllegalArgumentException("계좌를 찾을 수 없습니다.")); | ||||||||||
|
|
||||||||||
| // (3) 출금 비즈니스 로직 | ||||||||||
| paymentService.withdraw( | ||||||||||
| account.getAccountNo(), | ||||||||||
| requestDto.getLoginId(), | ||||||||||
| BigDecimal.valueOf(requestDto.getAmount()) | ||||||||||
| ); | ||||||||||
|
Comment on lines
56
to
+70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# PaymentService 클래스 찾기
find . -type f -name "*.java" | xargs grep -l "class PaymentService" | head -5Repository: FISA-Team-CE/tech-semina-msa Length of output: 286 🏁 Script executed: #!/bin/bash
# withdraw 메서드 구현 확인
rg -A 20 "public.*withdraw\(" --type=javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 8013 🏁 Script executed: #!/bin/bash
# CashRequestDTO 클래스 구조 확인
rg -A 10 "class CashRequestDTO\|record CashRequestDTO" --type=javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 54 🏁 Script executed: #!/bin/bash
# CashRequestDTO 찾기 (여러 패턴)
rg -l "CashRequestDTO" --type=javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 597 🏁 Script executed: #!/bin/bash
# KafkaConsumerService 파일 위치와 전체 내용 확인
find . -type f -name "*KafkaConsumerService*" -o -name "*KafkaConsumer*" | grep -i javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 406 🏁 Script executed: #!/bin/bash
# 파일 크기 확인 후 내용 조회
wc -l ./on-premise/core-payment-service/src/main/java/com/fisa/core_payment_service/service/KafkaConsumerService.javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 187 🏁 Script executed: #!/bin/bash
# KafkaConsumerService 전체 내용 확인
cat -n ./on-premise/core-payment-service/src/main/java/com/fisa/core_payment_service/service/KafkaConsumerService.javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 4703 🏁 Script executed: #!/bin/bash
# CashRequestDTO 내용 확인
cat -n ./on-premise/core-payment-service/src/main/java/com/fisa/core_payment_service/dto/CashRequestDTO.javaRepository: FISA-Team-CE/tech-semina-msa Length of output: 565 출금 요청의 amount null 검증을 추가해주세요 현재 추가로 ✅ 제안 변경 requestDto = objectMapper.readValue(message, CashRequestDTO.class);
log.info("📉 [Core] 출금 요청 수신: {}", requestDto);
+
+ if (requestDto.getLoginId() == null || requestDto.getLoginId().isBlank()
+ || requestDto.getAmount() == null || requestDto.getAmount() <= 0) {
+ throw new IllegalArgumentException("유효하지 않은 출금 요청입니다.");
+ }
// (2) 계좌 조회
Account account = accountRepository.findByUserUuid(requestDto.getLoginId())🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| // (4) 성공 이벤트 발행 -> PointService의 토픽 이름인 "core-result"로 변경 | ||||||||||
| CashResponseDTO successResponse = new CashResponseDTO( | ||||||||||
| requestDto.getOrderId(), | ||||||||||
| requestDto.getLoginId(), // ★ userUuid 추가 (PointService 환불용) | ||||||||||
| "SUCCESS", | ||||||||||
| "정상 출금 완료" | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| // ★ 토픽 이름 변경: core-withdraw-result -> core-result | ||||||||||
| kafkaProducerService.send("core-result", successResponse); | ||||||||||
| log.info("✅ [Core] 출금 성공 -> Point Service로 전송: {}", successResponse); | ||||||||||
|
|
||||||||||
| } catch (JsonProcessingException e) { | ||||||||||
| log.error("❌ JSON 파싱 에러: {}", message, e); | ||||||||||
| log.error("❌ JSON 파싱 에러 (Withdraw): {}", message, e); | ||||||||||
| } catch (Exception e) { | ||||||||||
| log.error("❌ 출금 처리 실패: {}", e.getMessage()); | ||||||||||
|
|
||||||||||
| if (requestDto != null) { | ||||||||||
| // (5) 실패 이벤트 발행 | ||||||||||
| CashResponseDTO failResponse = new CashResponseDTO( | ||||||||||
| requestDto.getOrderId(), | ||||||||||
| requestDto.getLoginId(), // ★ userUuid 추가 | ||||||||||
| "FAIL", | ||||||||||
| e.getMessage() | ||||||||||
| ); | ||||||||||
| // ★ 토픽 이름 변경 | ||||||||||
| kafkaProducerService.send("core-result", failResponse); | ||||||||||
| log.info("⚠️ [Core] 출금 실패 -> Point Service로 전송: {}", failResponse); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.fisa.core_payment_service.service; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.kafka.core.KafkaTemplate; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class KafkaProducerService { | ||
|
|
||
| private final KafkaTemplate<String, String> kafkaTemplate; | ||
| private final ObjectMapper objectMapper; | ||
|
|
||
| public void send(String topic, Object payload) { | ||
| try { | ||
| String jsonMessage = objectMapper.writeValueAsString(payload); | ||
| kafkaTemplate.send(topic, jsonMessage); | ||
| log.info("🚀 [Core-Producer] Sent to {}: {}", topic, jsonMessage); | ||
| } catch (JsonProcessingException e) { | ||
| log.error("❌ [Core-Producer] Serialization failed: {}", payload, e); | ||
| throw new RuntimeException("Kafka message serialization failed", e); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,27 +1,48 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package com.fisa.core_payment_service.service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.fisa.core_payment_service.domain.Account; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.fisa.core_payment_service.dto.CouponIssueMessage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.fisa.core_payment_service.repository.AccountRepository; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import lombok.extern.slf4j.Slf4j; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.transaction.annotation.Transactional; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.math.BigDecimal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Slf4j | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Transactional(readOnly = true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public class PaymentService { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AccountRepository accountRepository; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final KafkaProducerService kafkaProducerService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 계좌 개설 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Transactional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void createAccount(String accountNo, String userUuid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (accountRepository.existsById(accountNo)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new IllegalArgumentException("이미 존재하는 계좌입니다."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 1. 계좌 저장 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| accountRepository.save(Account.create(accountNo, userUuid)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.info("✅ 계좌 개설 완료: accountNo={}, user={}", accountNo, userUuid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 2. 쿠폰 발급 요청 보내기 (Producer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CouponIssueMessage couponEvent = new CouponIssueMessage( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userUuid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "WELCOME_COUPON", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "계좌 개설 축하 쿠폰" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // coupon-service가 듣고 있는 "coupon_issue" 토픽으로 쏜다 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kafkaProducerService.send("coupon_issue", couponEvent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.error("⚠️ 계좌는 생성되었으나 쿠폰 발급 요청 실패: {}", e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 입금 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -31,8 +52,8 @@ public BigDecimal deposit(String accountNo, String userUuid, BigDecimal amount) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| .orElseThrow(() -> new IllegalArgumentException("계좌가 없습니다.")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| account.validateOwner(userUuid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| account.deposit(amount); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return account.getBalance(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -43,11 +64,23 @@ public BigDecimal withdraw(String accountNo, String userUuid, BigDecimal amount) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| .orElseThrow(() -> new IllegalArgumentException("계좌가 없습니다.")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| account.validateOwner(userUuid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| account.withdraw(amount); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return account.getBalance(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // [Saga용] 계좌번호 없이 ID로 출금 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Transactional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void withdrawByLoginId(String loginId, Long amount) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Account account = accountRepository.findByUserUuid(loginId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .orElseThrow(() -> new IllegalArgumentException("해당 유저의 계좌가 존재하지 않습니다.")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Long -> BigDecimal 변환 후 출금 처리 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| account.withdraw(BigDecimal.valueOf(amount)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.info("📉 [Saga] 출금 처리 완료: user={}, amount={}", loginId, amount); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+72
to
+82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 파라미터 네이밍 불일치: 메서드 파라미터명이 또한, 🛠️ 수정 제안 // [Saga용] 계좌번호 없이 ID로 출금
`@Transactional`
-public void withdrawByLoginId(String loginId, Long amount) {
- Account account = accountRepository.findByUserUuid(loginId)
+public void withdrawByLoginId(String userUuid, Long amount) {
+ if (amount == null || amount <= 0) {
+ throw new IllegalArgumentException("출금 금액은 0보다 커야 합니다.");
+ }
+
+ Account account = accountRepository.findByUserUuid(userUuid)
.orElseThrow(() -> new IllegalArgumentException("해당 유저의 계좌가 존재하지 않습니다."));
// Long -> BigDecimal 변환 후 출금 처리
account.withdraw(BigDecimal.valueOf(amount));
- log.info("📉 [Saga] 출금 처리 완료: user={}, amount={}", loginId, amount);
+ log.info("📉 [Saga] 출금 처리 완료: user={}, amount={}", userUuid, amount);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 잔액 조회 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public BigDecimal getBalance(String accountNo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return accountRepository.findById(accountNo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.