From 73e49f2736f90491df4a851ab3addcf1fa897648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 23 Jan 2026 10:14:35 +0900 Subject: [PATCH] =?UTF-8?q?fix(API):=20FCM=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EC=B1=84=EB=84=90=20=EB=A7=A4=ED=95=91=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TodayIssue IMPORTANT_NOTIFICATIONS에서 deposit, withdrawal 제거 - notification_type별 채널 매핑 메서드 추가 - new_vendor → push_urgent (긴급/신규업체) - approval_request → push_payment (결재) - sales_order → push_sales_order (수주) - purchase_order → push_purchase_order (발주) - contract → push_contract (계약) - 나머지 → push_default (일반) Co-Authored-By: Claude --- app/Models/Tenants/TodayIssue.php | 5 ++-- app/Services/TodayIssueObserverService.php | 27 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) 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', // 일반 (입금, 출금, 카드 등) + }; + } }