diff --git a/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/dto/response/MemberInfoResponse.kt b/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/dto/response/MemberInfoResponse.kt index f67fed4e..9b6748f4 100644 --- a/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/dto/response/MemberInfoResponse.kt +++ b/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/dto/response/MemberInfoResponse.kt @@ -3,4 +3,13 @@ package org.fastcampus.applicationclient.member.dto.response data class MemberInfoResponse( val signname: String, val nickname: String, -) + val address: DefaultAddress?, +) { + data class DefaultAddress( + val roadAddress: String, + val jibunAddress: String, + val detailAddress: String, + val latitude: Double, + val longitude: Double, + ) +} diff --git a/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/service/MemberService.kt b/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/service/MemberService.kt index ee85bbd4..e03e3fee 100644 --- a/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/service/MemberService.kt +++ b/application-client/src/main/kotlin/org/fastcampus/applicationclient/member/service/MemberService.kt @@ -32,7 +32,21 @@ class MemberService( @MemberMetered fun info(authMember: AuthMember): MemberInfoResponse? { val findMember = memberRepository.findById(authMember.id) - return MemberInfoResponse(findMember.signname, findMember.nickname) + val defaultAddress = memberAddressRepository.findByUserIdAndIsDefault(authMember.id, true) + if (defaultAddress != null) { + return MemberInfoResponse( + findMember.signname, + findMember.nickname, + MemberInfoResponse.DefaultAddress( + roadAddress = defaultAddress.roadAddress, + jibunAddress = defaultAddress.jibunAddress, + detailAddress = defaultAddress.detailAddress ?: "", + latitude = defaultAddress.latitude, + longitude = defaultAddress.longitude, + ), + ) + } + return MemberInfoResponse(findMember.signname, findMember.nickname, null) } @Transactional diff --git a/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/controller/PaymentController.kt b/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/controller/PaymentController.kt index cb44bb00..c7da583c 100644 --- a/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/controller/PaymentController.kt +++ b/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/controller/PaymentController.kt @@ -24,6 +24,8 @@ class PaymentController( @RequestBody orderPaymentApproveRequest: OrderPaymentApproveRequest, @AuthenticationPrincipal authMember: AuthMember, ): APIResponseDTO { + // TODO 분산락으로 먼저 결제처리가 진행중이라면 튕겨야 함. + // 결제키를 먼저 저장 paymentService.savePaymentKey( userId = authMember.id, diff --git a/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/service/PaymentService.kt b/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/service/PaymentService.kt index 1a9f7c5e..bf16de5d 100644 --- a/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/service/PaymentService.kt +++ b/application-client/src/main/kotlin/org/fastcampus/applicationclient/payment/service/PaymentService.kt @@ -27,8 +27,9 @@ class PaymentService( fun savePaymentKey(userId: Long, orderId: String, paymentKey: String) { val order = findOrder(userId, orderId) val payment = findPayment(order.paymentId) - // PG 키가 없을때만 업데이트 - TODO 동시에 UPDATE 일어날 수 있지만,, 일단 구현 + // PG 키가 없을때만 업데이트 if (!StringUtils.hasText(payment.pgKey)) { + // TODO 동시에 UPDATE 일어날 수도 있다. paymentRepository.save(payment.copy(pgKey = paymentKey)) } } @@ -51,7 +52,7 @@ class PaymentService( val payment = findPayment(order.paymentId) - // PG 결제승인 요청 + // PG 결제승인 요청 - TODO 현재 트랜잭션 내에서 결제승인 동기처리. 비동기 처리는 어떻게 해야할까 / 결제 승인후 커밋 실패시 취소 처리도 되어야 함. val paymentGateway = paymentGatewayFactory.getPaymentGateway(payment.type) val result = paymentGateway.approve( paymentKey = payment.pgKey ?: throw PaymentException.PgKeyNotExists(payment.id.toString()), @@ -59,7 +60,7 @@ class PaymentService( amount = order.paymentPrice, ) - // 결제승인이 실패시 예외 - TODO 결제 상태를 새로운 트랜잭션으로 FAILED(결제실패) 상태로 바꿔야 할지? 초기 WAIT(결제대기) 상태로 남길지? + // 결제승인이 실패시 예외 if (result.status != PaymentGatewayResponse.Status.DONE) { throw PaymentException.PGFailed(payment.id.toString(), result.message) } @@ -76,6 +77,7 @@ class PaymentService( // 점주에게 주문 알림 - 트랜잭션 커밋이후 비동기 전송 eventPublisher.publishEvent(OrderNotificationEvent(updatedOrder)) + // 주문 Document 주문상태 변경 eventPublisher.publishEvent(OrderDetailStatusEvent(updatedOrder.id, updatedOrder.status)) }