diff --git a/app/Models/Tenants/TodayIssue.php b/app/Models/Tenants/TodayIssue.php index bf6ee33..4aa2165 100644 --- a/app/Models/Tenants/TodayIssue.php +++ b/app/Models/Tenants/TodayIssue.php @@ -93,13 +93,12 @@ class TodayIssue extends Model self::BADGE_WITHDRAWAL => 'withdrawal', ]; - // 중요 알림 (푸시 알림음) - 수주등록, 신규거래처, 결재요청, 입금, 출금 + // 중요 알림 (긴급 푸시) - 수주등록, 신규거래처, 결재요청 + // 입금, 출금, 카드 등은 일반 푸시(push_default)로 발송 public const IMPORTANT_NOTIFICATIONS = [ 'sales_order', 'new_vendor', 'approval_request', - 'deposit', - 'withdrawal', ]; /** diff --git a/app/Services/TodayIssueObserverService.php b/app/Services/TodayIssueObserverService.php index 4ab08f4..0033b2a 100644 --- a/app/Services/TodayIssueObserverService.php +++ b/app/Services/TodayIssueObserverService.php @@ -441,8 +441,8 @@ public function sendFcmNotification(TodayIssue $issue): void return; } - // 중요 알림 여부에 따른 채널 결정 - $channelId = $issue->isImportantNotification() ? 'push_urgent' : 'push_default'; + // 알림 타입에 따른 채널 결정 + $channelId = $this->getChannelForNotificationType($issue->notification_type); $result = $this->fcmSender->sendToMany( $tokens, @@ -555,4 +555,27 @@ public function createIssueWithFcm( return $issue; } + + /** + * 알림 타입에 따른 FCM 채널 ID 반환 + * + * 채널별 알림음: + * - push_urgent: 긴급(신규업체) + * - push_payment: 결재 + * - push_sales_order: 수주 + * - push_purchase_order: 발주 + * - push_contract: 계약 + * - push_default: 일반 (입금, 출금, 카드 등) + */ + private function getChannelForNotificationType(?string $notificationType): string + { + return match ($notificationType) { + 'new_vendor' => 'push_urgent', // 긴급(신규업체) + 'approval_request' => 'push_payment', // 결재 + 'sales_order' => 'push_sales_order', // 수주 + 'purchase_order' => 'push_purchase_order', // 발주 + 'contract' => 'push_contract', // 계약 + default => 'push_default', // 일반 (입금, 출금, 카드 등) + }; + } }