Skip to content

Commit

Permalink
Merge pull request #47 from lotteon2/hotfix/settlement-noti
Browse files Browse the repository at this point in the history
fix: 정산 알림 수정
  • Loading branch information
nowgnas authored Jan 19, 2024
2 parents c418f09 + ac59e06 commit 97c0ae3
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import bloomingblooms.domain.notification.Role;
import bloomingblooms.domain.resale.ResaleNotificationList;
import java.util.List;
import java.util.stream.Collectors;
import kr.bb.notification.domain.notification.entity.MemberNotification;
import kr.bb.notification.domain.notification.entity.Notification;
import kr.bb.notification.domain.notification.mapper.MemberNotificationCommand;
Expand Down Expand Up @@ -49,4 +50,18 @@ public void saveSingleNotification(PublishNotificationInformation publishInforma
public void updateNotificationIsRead(List<Long> notificationId, Long userId, Role role) {
memberNotificationJpaRepository.updateNotificationIsRead(notificationId, userId, role);
}

public void saveMultipleNotification(
PublishNotificationInformation publishInformation, List<Long> storeIdList) {
Notification notification = NotificationCommand.toEntity(publishInformation);
List<MemberNotification> memberNotifications =
storeIdList.stream()
.map(
item ->
MemberNotificationCommand.toEntity(
1L, publishInformation.getRole(), notification))
.collect(Collectors.toList());
notification.setMemberNotifications(memberNotifications);
notificationJpaRepository.save(notification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,147 +25,141 @@
@RequiredArgsConstructor
public class NotificationActionHelper {

private final SendSMS sms;
private final SendSSE sse;
private final NotificationCommandService notificationCommandService;

public void publishResaleNotification(NotificationData<ResaleNotificationList> notification) {
List<NotificationInformation> data =
NotificationInformation.getResaleNotificationData(notification);
data.forEach(
item -> {
sms.publish(item);
sse.publish(item);
});

// save notification
notificationCommandService.saveResaleNotification(notification);
}

public void publishQuestionRegisterNotification(
NotificationData<QuestionRegister> notification) {
NotificationInformation sseNotification =
NotificationInformation.getSSEData(
notification.getPublishInformation(),
notification.getWhoToNotify().getStoreId());
sse.publish(sseNotification);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}

public void publishNewComerNotification(NotificationData<Void> notification) {
NotificationInformation sseNotification =
NotificationInformation.getSSEData(notification.getPublishInformation(), 100L);
sse.publish(sseNotification);

// save notification
notificationCommandService.saveSingleNotification(notification.getPublishInformation(),
100L);
}

public void publishNewOrderNotification(NotificationData<NewOrderEventItem> notification) {
NotificationInformation sseNotification =
NotificationInformation.getSSEData(
notification.getPublishInformation(),
notification.getWhoToNotify().getStoreId());
sse.publish(sseNotification);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}

@OutOfStockNotificationDuplicateCheck
public void publishOutOfStockNotification(
NotificationData<OutOfStockNotification> outOfStockNotification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
outOfStockNotification.getPublishInformation(),
outOfStockNotification.getWhoToNotify().getStoreId());
sse.publish(sseData);

notificationCommandService.saveSingleNotification(
outOfStockNotification.getPublishInformation(),
outOfStockNotification.getWhoToNotify().getStoreId());
}

public void publishDeliveryStartNotification(
NotificationData<DeliveryNotification> notificationData) {
NotificationInformation notifyData =
NotificationInformation.getDeliveryNotificationData(notificationData);
sse.publish(notifyData);
sms.publish(notifyData);

// save notification
notificationCommandService.saveSingleNotification(
notificationData.getPublishInformation(),
notificationData.getWhoToNotify().getUserId());
}

public void publishSettlementNotification(
NotificationData<SettlementNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(),
notification.getWhoToNotify().getStoreId());
sse.publish(sseData);

notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}

public void publishOrderCancelNotification(
NotificationData<OrderCancelNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(),
notification.getWhoToNotify().getStoreId());
sse.publish(sseData);

notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}

/**
* 문의 답변 등록 알림
*
* @param notification
*/
public void publishInqueryResponseNotification(
NotificationData<InqueryResponseNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(),
notification.getWhoToNotify().getUserId());
NotificationInformation smsData = NotificationInformation.getSMSData(notification);
sse.publish(sseData);
sms.publish(smsData);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getUserId());
}

/**
* 주문 상태 알림
*
* @param notification
*/
public void publishNewOrderStatusNotification(
NotificationData<OrderStatusNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(),
notification.getWhoToNotify().getUserId());
NotificationInformation smsData = NotificationInformation.getNewOrderStatusData(
notification);
sse.publish(sseData);
sms.publish(smsData);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getUserId());
}
private final SendSMS sms;
private final SendSSE sse;
private final NotificationCommandService notificationCommandService;

public void publishResaleNotification(NotificationData<ResaleNotificationList> notification) {
List<NotificationInformation> data =
NotificationInformation.getResaleNotificationData(notification);
data.forEach(
item -> {
sms.publish(item);
sse.publish(item);
});

// save notification
notificationCommandService.saveResaleNotification(notification);
}

public void publishQuestionRegisterNotification(NotificationData<QuestionRegister> notification) {
NotificationInformation sseNotification =
NotificationInformation.getSSEData(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
sse.publish(sseNotification);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}

public void publishNewComerNotification(NotificationData<Void> notification) {
NotificationInformation sseNotification =
NotificationInformation.getSSEData(notification.getPublishInformation(), 100L);
sse.publish(sseNotification);

// save notification
notificationCommandService.saveSingleNotification(notification.getPublishInformation(), 100L);
}

public void publishNewOrderNotification(NotificationData<NewOrderEventItem> notification) {
NotificationInformation sseNotification =
NotificationInformation.getSSEData(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
sse.publish(sseNotification);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}

@OutOfStockNotificationDuplicateCheck
public void publishOutOfStockNotification(
NotificationData<OutOfStockNotification> outOfStockNotification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
outOfStockNotification.getPublishInformation(),
outOfStockNotification.getWhoToNotify().getStoreId());
sse.publish(sseData);

notificationCommandService.saveSingleNotification(
outOfStockNotification.getPublishInformation(),
outOfStockNotification.getWhoToNotify().getStoreId());
}

public void publishDeliveryStartNotification(
NotificationData<DeliveryNotification> notificationData) {
NotificationInformation notifyData =
NotificationInformation.getDeliveryNotificationData(notificationData);
sse.publish(notifyData);
sms.publish(notifyData);

// save notification
notificationCommandService.saveSingleNotification(
notificationData.getPublishInformation(), notificationData.getWhoToNotify().getUserId());
}

public void publishSettlementNotification(NotificationData<SettlementNotification> notification) {
notification
.getWhoToNotify()
.getStoreIdList()
.forEach(
item -> {
NotificationInformation sseData =
NotificationInformation.getSSEData(notification.getPublishInformation(), item);
sse.publish(sseData);
});

notificationCommandService.saveMultipleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreIdList());
}

public void publishOrderCancelNotification(
NotificationData<OrderCancelNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
sse.publish(sseData);

notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getStoreId());
}

/**
* 문의 답변 등록 알림
*
* @param notification
*/
public void publishInqueryResponseNotification(
NotificationData<InqueryResponseNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(), notification.getWhoToNotify().getUserId());
NotificationInformation smsData = NotificationInformation.getSMSData(notification);
sse.publish(sseData);
sms.publish(smsData);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getUserId());
}

/**
* 주문 상태 알림
*
* @param notification
*/
public void publishNewOrderStatusNotification(
NotificationData<OrderStatusNotification> notification) {
NotificationInformation sseData =
NotificationInformation.getSSEData(
notification.getPublishInformation(), notification.getWhoToNotify().getUserId());
NotificationInformation smsData = NotificationInformation.getNewOrderStatusData(notification);
sse.publish(sseData);
sms.publish(smsData);

// save notification
notificationCommandService.saveSingleNotification(
notification.getPublishInformation(), notification.getWhoToNotify().getUserId());
}
}

0 comments on commit 97c0ae3

Please sign in to comment.