Skip to content

Commit

Permalink
Api-v1.0.4
Browse files Browse the repository at this point in the history
Api-v1.0.4
  • Loading branch information
ImNM authored May 22, 2023
2 parents a99e4b5 + a1cbd70 commit 0b4ed84
Show file tree
Hide file tree
Showing 28 changed files with 522 additions and 443 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import band.gosrock.api.order.service.ApproveOrderUseCase;
import band.gosrock.api.order.service.CancelOrderUseCase;
import band.gosrock.api.order.service.ReadOrderUseCase;
import band.gosrock.api.order.service.RefuseOrderUseCase;
import band.gosrock.common.annotation.ApiErrorExceptionsExample;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
Expand All @@ -35,6 +36,8 @@ public class OrderAdminController {
private final ReadOrderUseCase readOrderUseCase;
private final CancelOrderUseCase cancelOrderUseCase;

private final RefuseOrderUseCase refuseOrderUseCase;

@Operation(summary = "어드민 목록 내 테이블 조회 OrderStage 는 꼭 보내주삼!")
@GetMapping
public PageResponse<OrderAdminTableElement> getEventOrders(
Expand All @@ -52,14 +55,21 @@ public OrderResponse cancelOrder(
return cancelOrderUseCase.execute(eventId, orderUuid);
}

@Operation(summary = "주문 승인하기 . 호스트 관리자가 티켓 주문을 승인합니다. ( 어드민 이벤트쪽으로 이동예정 )")
@Operation(summary = "주문 승인하기 . 호스트 관리자가 티켓 주문을 승인합니다.")
@ApiErrorExceptionsExample(ApproveOrderExceptionDocs.class)
@PostMapping("/{order_uuid}/approve")
public OrderResponse confirmOrder(
@PathVariable Long eventId, @PathVariable("order_uuid") String orderUuid) {
return approveOrderUseCase.execute(eventId, orderUuid);
}

@Operation(summary = "승인 주문 거절하기 . 호스트 관리자가 승인 대기중인 주문을 거절합니다.")
@PostMapping("/{order_uuid}/refuse")
public OrderResponse refuseOrder(
@PathVariable Long eventId, @PathVariable("order_uuid") String orderUuid) {
return refuseOrderUseCase.execute(eventId, orderUuid);
}

@Operation(summary = "주문관리 리스트 페이지에서 주문 상세정보 조회할때")
@GetMapping("/{order_uuid}")
public OrderResponse getEventOrderDetail(
Expand Down
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);
}
}
2 changes: 1 addition & 1 deletion DuDoong-Batch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ COPY ./build/libs/*.jar app.jar
ARG PROFILE=dev
ENV PROFILE=${PROFILE}

ENTRYPOINT ["java","-Dspring.profiles.active=${PROFILE}", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ENTRYPOINT ["java","-Dspring.profiles.active=${PROFILE}", "-Djava.security.egd=file:/dev/./urandom","-jar","-Duser.timezone=Asia/Seoul","/app.jar"]
120 changes: 0 additions & 120 deletions DuDoong-Batch/src/main/java/band/gosrock/excel/ExcelOrderHelper.java

This file was deleted.

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);
}
}
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();
}
}
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;
Expand Down
Loading

0 comments on commit 0b4ed84

Please sign in to comment.