Skip to content

Commit

Permalink
Merge pull request #111 from ajy9851/feat/110/remindOrder
Browse files Browse the repository at this point in the history
[FEAT] 결제 μš”μ²­ 독촉 메세지
  • Loading branch information
rbm0524 authored Nov 14, 2024
2 parents f31b3dc + b631b9c commit 16db0ff
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ordertogether.team14_be.order.details.controller;

import com.ordertogether.team14_be.member.persistence.MemberRepository;
import com.ordertogether.team14_be.member.persistence.entity.Member;
import com.ordertogether.team14_be.member.presentation.LoginMember;
import com.ordertogether.team14_be.order.details.service.SmsService;
Expand All @@ -9,14 +10,22 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/spot/sms/{spotId}")
@RequestMapping("/api/v1")
public class SmsController {

private final SmsService smsService;
private final MemberRepository memberRepository;

@GetMapping
@GetMapping("/spot/sms/{spotId}")
public ResponseEntity<Void> getOrdersInfo(@LoginMember Member member, @PathVariable Long spotId) {
smsService.sendLinkToParticipant(member, spotId);
return ResponseEntity.ok().build();
}

@GetMapping("/orders/sms/{spotId}/{participantId}")
public ResponseEntity<Void> getOrdersInfo(
@LoginMember Member creator, @PathVariable Long spotId, @PathVariable Long participantId) {
smsService.remindToParticipant(participantId, spotId);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ordertogether.team14_be.order.details.service;

import com.ordertogether.team14_be.member.persistence.MemberRepository;
import com.ordertogether.team14_be.member.persistence.entity.Member;
import com.ordertogether.team14_be.order.details.util.SmsUtil;
import com.ordertogether.team14_be.spot.entity.Spot;
Expand All @@ -13,6 +14,7 @@
public class SmsService {
private final SmsUtil smsUtil;
private final SimpleSpotRepository simpleSpotRepository;
private final MemberRepository memberRepository;

public ResponseEntity<?> sendLinkToParticipant(Member member, Long spotId) {
// μˆ˜μ‹ λ²ˆν˜Έ ν˜•νƒœμ— 맞좰 "-"을 ""둜 λ³€ν™˜
Expand All @@ -28,4 +30,24 @@ public ResponseEntity<?> sendLinkToParticipant(Member member, Long spotId) {

return ResponseEntity.ok().build();
}

public ResponseEntity<?> remindToParticipant(Long spotId, Long participantId) {
// μˆ˜μ‹ λ²ˆν˜Έ ν˜•νƒœμ— 맞좰 "-"을 ""둜 λ³€ν™˜
Member participant =
memberRepository
.findById(participantId)
.orElseThrow(() -> new IllegalArgumentException("μ‚¬μš©μž 정보λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."));

String phoneNum = participant.getPhoneNumber().replaceAll("-", "");

Spot spot =
simpleSpotRepository
.findById(spotId)
.orElseThrow(() -> new IllegalArgumentException("슀팟 정보가 μ—†μŠ΅λ‹ˆλ‹€."));

String link = spot.getTogetherOrderLink();
smsUtil.remindOrder(phoneNum, link);

return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private void init() {
NurigoApp.INSTANCE.initialize(apiKey, apiSecretKey, "https://api.coolsms.co.kr");
}

// 단일 λ©”μ‹œμ§€ λ°œμ†‘ 예제
public SingleMessageSentResponse sendOne(String to, String link) {
Message message = new Message();
// λ°œμ‹ λ²ˆν˜Έ 및 μˆ˜μ‹ λ²ˆν˜ΈλŠ” λ°˜λ“œμ‹œ 01012345678 ν˜•νƒœλ‘œ μž…λ ₯λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.
Expand All @@ -38,4 +37,16 @@ public SingleMessageSentResponse sendOne(String to, String link) {
this.messageService.sendOne(new SingleMessageSendingRequest(message));
return response;
}

public SingleMessageSentResponse remindOrder(String to, String link) {
Message message = new Message();
// λ°œμ‹ λ²ˆν˜Έ 및 μˆ˜μ‹ λ²ˆν˜ΈλŠ” λ°˜λ“œμ‹œ 01012345678 ν˜•νƒœλ‘œ μž…λ ₯λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.
message.setFrom("01043064404");
message.setTo(to);
message.setText("[μ—¬κΈ°λ¨Ήλ•Œ] 아직 주문이 μ™„λ£Œλ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. 주문을 μ™„λ£Œν•΄μ£Όμ„Έμš”. \n" + link);

SingleMessageSentResponse response =
this.messageService.sendOne(new SingleMessageSendingRequest(message));
return response;
}
}

0 comments on commit 16db0ff

Please sign in to comment.