Skip to content

Commit

Permalink
#156 [REFACTOR] 커스텀 도안 신청, 일반 상품 구매 시 디스코드 메시지 형식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
05AM committed Feb 21, 2024
1 parent 9d7b9bf commit e872168
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ResponseEntity<?> postCustom(
@RequestBody @Valid PostCustomReq request
) {
PostCustomRes response = PostCustomRes.from(
(customFacade.createCustom(request.getHaveDesign(), userId)));
customFacade.createCustom(request.getHaveDesign(), userId));
return BaseResponse.success(SuccessType.CREATE_CUSTOM_SUCCESS, response);
}

Expand All @@ -79,7 +79,10 @@ public ResponseEntity<?> patchCustom(
PatchCustomRes response =
PatchCustomRes.from(
customFacade.updateCustom(
customInfo.newUpdateCustomReq(userId, customImages, handDrawingImage)));
customInfo.newUpdateCustomReq(
userId,
customImages,
handDrawingImage)));

return BaseResponse.success(SuccessType.UPDATE_CUSTOM_SUCCESS, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,29 @@ public class CustomApplyDiscordMessage {
DiscordCustomImage image;

public static CustomApplyDiscordMessage from(User user, Custom custom) {
String title = "Custom Id : " + custom.getId();
String description;
String title = "커스텀 도안 번호 : " + custom.getId();
StringBuilder description = new StringBuilder();

description.append("\n\n### [유저 정보]")
.append("\n- 연락처: ").append(user.getPhoneNumber())
.append("\n- 이름: ").append(custom.getName())
.append("\n\n### [도안 신청 정보]")
.append("\n- 사이즈: ").append(custom.getSize().getSize())
.append("\n- 수량: ").append(custom.getCount());

if (custom.getHaveDesign()) {
description = "유저 전화번호 : " + user.getPhoneNumber()
+ "\n이름 : " + custom.getName()
+ "\n사이즈 : " + custom.getSize().getSize()
+ "\n추가 요청 사항 : " + custom.getDemand()
+ "\n수량 : " + custom.getCount()
+ "\n그려둔 도안 있음";
description.append("\n- 추가 요청 사항: ").append(custom.getDemand())
.append("\n- 도안: ").append("`있음`");
} else {
description = "유저 전화번호 : " + user.getPhoneNumber()
+ "이름 : " + custom.getName()
+ "\n사이즈 : " + custom.getSize().getSize()
+ "\n추가 요청 사항 : " + custom.getDemand()
+ "\n색상 : " + custom.getIsColored()
+ "\n주제 및 설명 : " + custom.getDescription()
+ "\n수량 : " + custom.getCount()
+ "\n그려둔 도안 없음";
description.append("\n- 색상: ").append(custom.getIsColored())
.append("\n- 주제 및 설명: \n").append(custom.getDescription())
.append("\n- 추가 요청 사항: ").append(custom.getDemand())
.append("\n- 도안: ").append("`없음`");
}

return new CustomApplyDiscordMessage(
title,
description,
description.toString(),
new DiscordCustomImage(custom.getMainImageUrl())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,28 @@ public static OrderStickerDiscordMessage from(
List<OrderedProduct> orderedProducts) {
String title = "주문 번호: " + orderHistory.getId();
StringBuilder description = new StringBuilder();

description.append("\n\n### [주문 정보]")
.append("\n유저 번호: ").append(orderHistory.getUser().getId())
.append("\n상품 금액: ").append(orderHistory.getProductAmount())
.append("\n 주문 금액: ").append(orderHistory.getTotalAmount());
.append("\n- 유저 번호: ").append(orderHistory.getUser().getId())
.append("\n- 상품 금액: ").append(orderHistory.getProductAmount())
.append("\n- 총 주문 금액: ").append(orderHistory.getTotalAmount());

description.append("\n\n### [주문 상품 내역]");
orderedProducts.forEach(product -> {
description.append("\n");
description.append("\n상품 번호: ").append(product.getSticker().getId());
description.append("\n상품명: ").append(product.getSticker().getName());
description.append("\n가격: ").append(product.getPrice());
description.append("\n수량: ").append(product.getCount());
description.append("\n- 상품 번호: ").append(product.getSticker().getId());
description.append("\n- 상품명: ").append(product.getSticker().getName());
description.append("\n- 가격: ").append(product.getPrice());
description.append("\n- 수량: ").append(product.getCount());
});

description.append("\n\n### [배송 정보]")
.append("\n수령인: ").append(orderHistory.getRecipientName())
.append("\n연락처: ").append(orderHistory.getContact())
.append("\n우편 번호: ").append(orderHistory.getMailingAddress())
.append("\n기본 주소: ").append(orderHistory.getBaseAddress())
.append("\n싱세 주소: ").append(orderHistory.getDetailAddress())
.append("\n배송비: ").append(orderHistory.getShippingFee());
.append("\n- 수령인: ").append(orderHistory.getRecipientName())
.append("\n- 연락처: ").append(orderHistory.getContact())
.append("\n- 우편 번호: ").append(orderHistory.getMailingAddress())
.append("\n- 기본 주소: ").append(orderHistory.getBaseAddress())
.append("\n- 싱세 주소: ").append(orderHistory.getDetailAddress())
.append("\n- 배송비: ").append(orderHistory.getShippingFee());

return new OrderStickerDiscordMessage(title, description.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ public class DiscordMessageService {

@Transactional
public void sendCustomApplyMessage(Custom custom) {
CustomApplyDiscordMessage payload = CustomApplyDiscordMessage.from(custom.getUser(),
custom);
sendDiscordMessage(customWebhookProperty.getClientId(), customWebhookProperty.getToken(),
custom.getUser(), "님이 커스텀 도안을 신청했습니다.", payload);
CustomApplyDiscordMessage payload =
CustomApplyDiscordMessage.from(custom.getUser(), custom);

sendDiscordMessage(customWebhookProperty.getClientId(),
customWebhookProperty.getToken(),
custom.getUser(),
"님이 커스텀 도안을 신청했습니다.",
payload);
}

@Transactional
public void sendOrderStickerMessage(OrderHistory orderHistory,
List<OrderedProduct> orderedProducts) {
OrderStickerDiscordMessage payload =
OrderStickerDiscordMessage.from(orderHistory, orderedProducts);

sendDiscordMessage(
orderWebhookProperty.getClientId(),
orderWebhookProperty.getToken(),
Expand Down

0 comments on commit e872168

Please sign in to comment.