-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature : 주문 관련, 호스트 초대 이메일 알림 전송 (#297)
* feat : footer 추가 * feat : 레이아웃 추가 * feat : 회원가입 포맷 만들기 * refactor : fragments 리팩터링 * refactor : mailFormat 리팩터링 * refactor : 마진값 조정 * feat : 타이틀 컴포넌트 생성 * refactor : 구조 잡기 * feat : 주문 승인 요청 메일 폼 * feat : 주문 승인 요청 알림 * feat : 승인 주문 생성시 이메일 알림 * style : spotless * feat : 주문관련, 호스트 초대이메일 알림 포맷 완료 * feat : 각 도메인 이벤트 핸들링 * feat : 호스트 초대 이메일 알림 * style : spotless * fix : 필터 순서 재조정
- Loading branch information
Showing
41 changed files
with
1,821 additions
and
2,456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
DuDoong-Api/src/main/java/band/gosrock/api/email/dto/OrderMailDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package band.gosrock.api.email.dto; | ||
|
||
|
||
import band.gosrock.infrastructure.config.mail.dto.EmailEventInfo; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailOrderInfo; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class OrderMailDto { | ||
private final EmailUserInfo userInfo; | ||
private final EmailOrderInfo orderInfo; | ||
private final EmailEventInfo eventInfo; | ||
} |
38 changes: 38 additions & 0 deletions
38
DuDoong-Api/src/main/java/band/gosrock/api/email/handler/CreateOrderEventEmailHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package band.gosrock.api.email.handler; | ||
|
||
|
||
import band.gosrock.api.email.service.OrderApproveRequestEmailService; | ||
import band.gosrock.api.email.service.OrderMailInfoHelper; | ||
import band.gosrock.domain.common.events.order.CreateOrderEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class CreateOrderEventEmailHandler { | ||
|
||
private final OrderApproveRequestEmailService orderApproveRequestEmailService; | ||
|
||
private final OrderMailInfoHelper orderMailInfoHelper; | ||
|
||
@Async | ||
@TransactionalEventListener( | ||
classes = CreateOrderEvent.class, | ||
phase = TransactionPhase.AFTER_COMMIT) | ||
public void handleDoneOrderFailEvent(CreateOrderEvent createOrderEvent) { | ||
log.info(createOrderEvent.getOrderUuid() + "주문 생성 이메일 요청"); | ||
|
||
// 승인 주문만 생성시에 이메일을 보낸다. | ||
if (createOrderEvent.getOrderMethod().isPayment()) { | ||
return; | ||
} | ||
|
||
orderApproveRequestEmailService.execute( | ||
orderMailInfoHelper.execute(createOrderEvent.getOrderUuid())); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
DuDoong-Api/src/main/java/band/gosrock/api/email/handler/DoneOrderEventEmailHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package band.gosrock.api.email.handler; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.api.email.service.OrderApproveConfirmEmailService; | ||
import band.gosrock.api.email.service.OrderMailInfoHelper; | ||
import band.gosrock.api.email.service.OrderPaymentDoneEmailService; | ||
import band.gosrock.domain.common.events.order.DoneOrderEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class DoneOrderEventEmailHandler { | ||
|
||
private final OrderMailInfoHelper orderMailInfoHelper; | ||
|
||
private final OrderApproveConfirmEmailService orderApproveConfirmEmailService; | ||
private final OrderPaymentDoneEmailService orderPaymentDoneEmailService; | ||
|
||
@Async | ||
@TransactionalEventListener( | ||
classes = DoneOrderEvent.class, | ||
phase = TransactionPhase.AFTER_COMMIT) | ||
public void handleDoneOrderEvent(DoneOrderEvent doneOrderEvent) { | ||
log.info(doneOrderEvent.getOrderUuid() + "주문 상태 완료, 이메일 보내기"); | ||
OrderMailDto orderMailDto = orderMailInfoHelper.execute(doneOrderEvent.getOrderUuid()); | ||
|
||
// 결제용 | ||
if (doneOrderEvent.getOrderMethod().isPayment()) { | ||
orderPaymentDoneEmailService.execute(orderMailDto); | ||
return; | ||
} | ||
// 승인용 | ||
orderApproveConfirmEmailService.execute(orderMailDto); | ||
log.info(doneOrderEvent.getOrderUuid() + "주문 상태 완료, 이메일 보내기 완료"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
DuDoong-Api/src/main/java/band/gosrock/api/email/handler/WithDrawOrderEventEmailHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package band.gosrock.api.email.handler; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.api.email.service.OrderMailInfoHelper; | ||
import band.gosrock.api.email.service.OrderWithDrawCancelEmailService; | ||
import band.gosrock.api.email.service.OrderWithDrawRefundEmailService; | ||
import band.gosrock.domain.common.events.order.WithDrawOrderEvent; | ||
import band.gosrock.domain.domains.order.domain.OrderStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class WithDrawOrderEventEmailHandler { | ||
|
||
private final OrderWithDrawRefundEmailService orderWithDrawRefundEmailService; | ||
private final OrderWithDrawCancelEmailService orderWithDrawCancelEmailService; | ||
private final OrderMailInfoHelper orderMailInfoHelper; | ||
|
||
@Async | ||
@TransactionalEventListener( | ||
classes = WithDrawOrderEvent.class, | ||
phase = TransactionPhase.AFTER_COMMIT) | ||
public void handleWithDrawOrderEvent(WithDrawOrderEvent withDrawOrderEvent) { | ||
OrderStatus orderStatus = withDrawOrderEvent.getOrderStatus(); | ||
OrderMailDto orderMailDto = orderMailInfoHelper.execute(withDrawOrderEvent.getOrderUuid()); | ||
|
||
// 관리자에 의한 취소 | ||
if (orderStatus == OrderStatus.CANCELED) { | ||
orderWithDrawCancelEmailService.execute(orderMailDto); | ||
return; | ||
} | ||
// 구매자에의한 환불 요청 | ||
orderWithDrawRefundEmailService.execute(orderMailDto); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
DuDoong-Api/src/main/java/band/gosrock/api/email/service/HostInviteEmailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.domain.domains.host.domain.HostRole; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class HostInviteEmailService { | ||
private final AwsSesUtils awsSesUtils; | ||
|
||
public void execute(EmailUserInfo userInfo, String hostName, HostRole hostRole) { | ||
Context context = new Context(); | ||
context.setVariable("userInfo", userInfo); | ||
context.setVariable("hostName", hostName); | ||
context.setVariable("role", hostRole.getValue()); | ||
awsSesUtils.singleEmailRequest( | ||
userInfo.getEmail(), "두둥" + hostName + " 호스트 초대 알림 드립니다.", "hostInvite", context); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ong-Api/src/main/java/band/gosrock/api/email/service/OrderApproveConfirmEmailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class OrderApproveConfirmEmailService { | ||
private final AwsSesUtils awsSesUtils; | ||
|
||
public void execute(OrderMailDto orderMailDto) { | ||
Context context = new Context(); | ||
EmailUserInfo userInfo = orderMailDto.getUserInfo(); | ||
context.setVariable("userInfo", userInfo); | ||
context.setVariable("orderInfo", orderMailDto.getOrderInfo()); | ||
context.setVariable("eventInfo", orderMailDto.getEventInfo()); | ||
awsSesUtils.singleEmailRequest( | ||
userInfo.getEmail(), "두둥 주문승인 완료 알림드립니다.", "orderApproveConfirm", context); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ong-Api/src/main/java/band/gosrock/api/email/service/OrderApproveRequestEmailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class OrderApproveRequestEmailService { | ||
private final AwsSesUtils awsSesUtils; | ||
|
||
public void execute(OrderMailDto orderMailDto) { | ||
Context context = new Context(); | ||
EmailUserInfo userInfo = orderMailDto.getUserInfo(); | ||
context.setVariable("userInfo", userInfo); | ||
context.setVariable("orderInfo", orderMailDto.getOrderInfo()); | ||
context.setVariable("eventInfo", orderMailDto.getEventInfo()); | ||
awsSesUtils.singleEmailRequest( | ||
userInfo.getEmail(), "두둥 주문승인 요청 알림드립니다.", "orderApproveRequest", context); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
DuDoong-Api/src/main/java/band/gosrock/api/email/service/OrderMailInfoHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.common.annotation.Helper; | ||
import band.gosrock.domain.domains.event.adaptor.EventAdaptor; | ||
import band.gosrock.domain.domains.event.domain.Event; | ||
import band.gosrock.domain.domains.host.adaptor.HostAdaptor; | ||
import band.gosrock.domain.domains.host.domain.Host; | ||
import band.gosrock.domain.domains.order.adaptor.OrderAdaptor; | ||
import band.gosrock.domain.domains.order.domain.Order; | ||
import band.gosrock.domain.domains.user.adaptor.UserAdaptor; | ||
import band.gosrock.domain.domains.user.domain.User; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailEventInfo; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Helper | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class OrderMailInfoHelper { | ||
private final OrderAdaptor orderAdaptor; | ||
private final UserAdaptor userAdaptor; | ||
private final EventAdaptor eventAdaptor; | ||
private final HostAdaptor hostAdaptor; | ||
|
||
public OrderMailDto execute(String orderUuid) { | ||
Order order = orderAdaptor.find(orderUuid); | ||
User user = userAdaptor.queryUser(order.getUserId()); | ||
Event event = eventAdaptor.findById(order.getEventId()); | ||
Host host = hostAdaptor.findById(event.getHostId()); | ||
return new OrderMailDto( | ||
user.toEmailUserInfo(), order.toEmailOrderInfo(), getEventInfo(event, host)); | ||
} | ||
|
||
private EmailEventInfo getEventInfo(Event event, Host host) { | ||
return new EmailEventInfo(host.getProfile().getName(), event.getEventBasic().getName()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
DuDoong-Api/src/main/java/band/gosrock/api/email/service/OrderPaymentDoneEmailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class OrderPaymentDoneEmailService { | ||
private final AwsSesUtils awsSesUtils; | ||
|
||
public void execute(OrderMailDto orderMailDto) { | ||
Context context = new Context(); | ||
EmailUserInfo userInfo = orderMailDto.getUserInfo(); | ||
context.setVariable("userInfo", userInfo); | ||
context.setVariable("orderInfo", orderMailDto.getOrderInfo()); | ||
context.setVariable("eventInfo", orderMailDto.getEventInfo()); | ||
awsSesUtils.singleEmailRequest( | ||
userInfo.getEmail(), "두둥 주문 완료 알림드립니다.", "orderPaymentDone", context); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ong-Api/src/main/java/band/gosrock/api/email/service/OrderWithDrawCancelEmailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class OrderWithDrawCancelEmailService { | ||
private final AwsSesUtils awsSesUtils; | ||
|
||
public void execute(OrderMailDto orderMailDto) { | ||
Context context = new Context(); | ||
EmailUserInfo userInfo = orderMailDto.getUserInfo(); | ||
context.setVariable("userInfo", userInfo); | ||
context.setVariable("orderInfo", orderMailDto.getOrderInfo()); | ||
context.setVariable("eventInfo", orderMailDto.getEventInfo()); | ||
awsSesUtils.singleEmailRequest( | ||
userInfo.getEmail(), "두둥 주문 철회 알림 드립니다.", "orderWithdrawCancel", context); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ong-Api/src/main/java/band/gosrock/api/email/service/OrderWithDrawRefundEmailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package band.gosrock.api.email.service; | ||
|
||
|
||
import band.gosrock.api.email.dto.OrderMailDto; | ||
import band.gosrock.infrastructure.config.mail.dto.EmailUserInfo; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class OrderWithDrawRefundEmailService { | ||
private final AwsSesUtils awsSesUtils; | ||
|
||
public void execute(OrderMailDto orderMailDto) { | ||
Context context = new Context(); | ||
EmailUserInfo userInfo = orderMailDto.getUserInfo(); | ||
context.setVariable("userInfo", userInfo); | ||
context.setVariable("orderInfo", orderMailDto.getOrderInfo()); | ||
context.setVariable("eventInfo", orderMailDto.getEventInfo()); | ||
awsSesUtils.singleEmailRequest( | ||
userInfo.getEmail(), "두둥 주문 철회 알림 드립니다.", "orderWithdrawRefund", context); | ||
} | ||
} |
Oops, something went wrong.