-
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.
Api-v1.0.4
- Loading branch information
Showing
28 changed files
with
522 additions
and
443 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
26 changes: 26 additions & 0 deletions
26
DuDoong-Api/src/main/java/band/gosrock/api/order/service/RefuseOrderUseCase.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,26 @@ | ||
package band.gosrock.api.order.service; | ||
|
||
import static band.gosrock.api.common.aop.hostRole.FindHostFrom.EVENT_ID; | ||
import static band.gosrock.api.common.aop.hostRole.HostQualification.MANAGER; | ||
|
||
import band.gosrock.api.common.aop.hostRole.HostRolesAllowed; | ||
import band.gosrock.api.order.model.dto.response.OrderResponse; | ||
import band.gosrock.api.order.model.mapper.OrderMapper; | ||
import band.gosrock.common.annotation.UseCase; | ||
import band.gosrock.domain.domains.order.service.WithdrawOrderService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class RefuseOrderUseCase { | ||
|
||
private final WithdrawOrderService withdrawOrderService; | ||
|
||
private final OrderMapper orderMapper; | ||
|
||
@HostRolesAllowed(role = MANAGER, findHostFrom = EVENT_ID, applyTransaction = false) | ||
public OrderResponse execute(Long eventId, String orderUuid) { | ||
withdrawOrderService.refuseOrder(orderUuid); | ||
return orderMapper.toOrderResponse(orderUuid); | ||
} | ||
} |
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
120 changes: 0 additions & 120 deletions
120
DuDoong-Batch/src/main/java/band/gosrock/excel/ExcelOrderHelper.java
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
DuDoong-Batch/src/main/java/band/gosrock/helper/SettlementEmailHelper.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,64 @@ | ||
package band.gosrock.helper; | ||
|
||
|
||
import band.gosrock.common.annotation.Helper; | ||
import band.gosrock.domain.domains.event.domain.Event; | ||
import band.gosrock.infrastructure.config.s3.S3PrivateFileService; | ||
import band.gosrock.infrastructure.config.ses.AwsSesUtils; | ||
import band.gosrock.infrastructure.config.ses.RawEmailAttachmentDto; | ||
import band.gosrock.infrastructure.config.ses.SendRawEmailDto; | ||
import javax.mail.MessagingException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.thymeleaf.context.Context; | ||
import org.thymeleaf.spring5.SpringTemplateEngine; | ||
|
||
@Helper | ||
@RequiredArgsConstructor | ||
public class SettlementEmailHelper { | ||
private final SpringTemplateEngine templateEngine; | ||
|
||
private final S3PrivateFileService s3PrivateFileService; | ||
private final AwsSesUtils awsSesUtils; | ||
|
||
private RawEmailAttachmentDto getSettlementPdfAttachment(Event event) { | ||
return RawEmailAttachmentDto.builder() | ||
.fileName(event.getEventName() + "_정산서.pdf") | ||
.fileBytes(s3PrivateFileService.downloadEventSettlementPdf(event.getId())) | ||
.type("application/pdf") | ||
.build(); | ||
} | ||
|
||
private RawEmailAttachmentDto getOrderListExcelAttachment(Event event) { | ||
return RawEmailAttachmentDto.builder() | ||
.fileName(event.getEventName() + "_주문목록.xlsx") | ||
.fileBytes(s3PrivateFileService.downloadEventOrdersExcel(event.getId())) | ||
.type("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") | ||
.build(); | ||
} | ||
|
||
public void sendToAdmin(Event event) throws MessagingException { | ||
SendRawEmailDto sendRawEmailDto = | ||
SendRawEmailDto.builder() | ||
.bodyHtml(templateEngine.process("eventSettlement", new Context())) | ||
.recipient("[email protected]") | ||
.subject(event.getEventName() + "공연 정산서 어드민 발송 ( 관리자용 )") | ||
.build(); | ||
|
||
sendRawEmailDto.addEmailAttachments(getSettlementPdfAttachment(event)); | ||
sendRawEmailDto.addEmailAttachments(getOrderListExcelAttachment(event)); | ||
awsSesUtils.sendRawEmails(sendRawEmailDto); | ||
} | ||
|
||
public void sendToHost(Event event, String hostUserEmail) throws MessagingException { | ||
SendRawEmailDto sendRawEmailDto = | ||
SendRawEmailDto.builder() | ||
.bodyHtml(templateEngine.process("eventSettlement", new Context())) | ||
.recipient(hostUserEmail) | ||
.subject(event.getEventName() + "공연 정산관련 안내") | ||
.build(); | ||
|
||
sendRawEmailDto.addEmailAttachments(getSettlementPdfAttachment(event)); | ||
sendRawEmailDto.addEmailAttachments(getOrderListExcelAttachment(event)); | ||
awsSesUtils.sendRawEmails(sendRawEmailDto); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
DuDoong-Batch/src/main/java/band/gosrock/helper/SettlementPdfHelper.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,69 @@ | ||
package band.gosrock.helper; | ||
|
||
|
||
import band.gosrock.common.annotation.Helper; | ||
import band.gosrock.domain.common.vo.Money; | ||
import band.gosrock.domain.domains.event.domain.Event; | ||
import band.gosrock.domain.domains.settlement.domain.EventSettlement; | ||
import band.gosrock.domain.domains.user.domain.User; | ||
import band.gosrock.dto.SettlementPDFDto; | ||
import band.gosrock.infrastructure.config.pdf.PdfRender; | ||
import band.gosrock.infrastructure.config.s3.S3PrivateFileService; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.lowagie.text.DocumentException; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.time.LocalDateTime; | ||
import java.util.Map; | ||
import lombok.RequiredArgsConstructor; | ||
import org.thymeleaf.context.Context; | ||
import org.thymeleaf.spring5.SpringTemplateEngine; | ||
|
||
@Helper | ||
@RequiredArgsConstructor | ||
public class SettlementPdfHelper { | ||
private final PdfRender pdfRender; | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
private final SpringTemplateEngine templateEngine; | ||
|
||
private final S3PrivateFileService s3PrivateFileUploadService; | ||
|
||
public void uploadPdfToS3(Event event, EventSettlement eventSettlement, User masterUser) | ||
throws DocumentException, IOException { | ||
SettlementPDFDto settlementPDFDto = getSettlementPDFDto(event, masterUser, eventSettlement); | ||
// 정산 관련 타임리프 파일. | ||
String html = templateEngine.process("settlement", getPdfHtmlContext(settlementPDFDto)); | ||
ByteArrayOutputStream outputStream = pdfRender.generatePdfFromHtml(html); | ||
s3PrivateFileUploadService.eventSettlementPdfUpload(event.getId(), outputStream); | ||
} | ||
|
||
private Context getPdfHtmlContext(SettlementPDFDto settlementPDFDto) { | ||
Map result = objectMapper.convertValue(settlementPDFDto, Map.class); | ||
|
||
Context context = new Context(null, result); | ||
context.setVariable("settlementAt", settlementPDFDto.getSettlementAt()); | ||
context.setVariable("now", settlementPDFDto.getNow()); | ||
return context; | ||
} | ||
|
||
private SettlementPDFDto getSettlementPDFDto( | ||
Event event, User masterUser, EventSettlement eventSettlement) { | ||
return SettlementPDFDto.builder() | ||
.eventTitle(event.getEventBasic().getName()) | ||
.hostName(masterUser.getProfile().getName()) | ||
.settlementAt(event.getEndAt().plusDays(6L)) | ||
.dudoongTicketAmount(eventSettlement.getDudoongAmount().toString()) | ||
.pgTicketAmount(eventSettlement.getPaymentAmount().toString()) | ||
.totalAmount(eventSettlement.getTotalSalesAmount().toString()) | ||
// 초기 두둥 자체 수수료 없음. | ||
.dudoongFee(Money.ZERO.toString()) | ||
.pgFee(eventSettlement.getPgFee().toString()) | ||
.totalFee(eventSettlement.getPgFee().toString()) | ||
.totalFeeVat(eventSettlement.getPgFeeVat().toString()) | ||
.totalSettlement(eventSettlement.getTotalAmount().toString()) | ||
.now(LocalDateTime.now()) | ||
.build(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ava/band/gosrock/excel/ExcelOrderDto.java → ...d/gosrock/helper/excel/ExcelOrderDto.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package band.gosrock.excel; | ||
package band.gosrock.helper.excel; | ||
|
||
|
||
import band.gosrock.domain.common.vo.Money; | ||
|
Oops, something went wrong.