From 1c3cb48c7c9eda6e29eb571b03b011685a72e066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 30 Jan 2026 18:07:44 +0900 Subject: [PATCH] =?UTF-8?q?feat(API):=20FCM=20=EC=B1=84=EB=84=90=EB=AA=85?= =?UTF-8?q?=20=EB=8F=99=EA=B8=B0=ED=99=94=20=EB=B0=8F=20config=20=EC=9D=BC?= =?UTF-8?q?=EC=9B=90=ED=99=94=20(7=EC=B1=84=EB=84=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - push_urgent → push_vendor_register (거래처등록) - push_payment → push_approval_request (결재요청) - push_income 신규 추가 (입금) - config/fcm.php에 전체 7개 채널 등록 (기존 2개→7개) - 서비스 파일 하드코딩을 config() 참조로 전환 Co-Authored-By: Claude Opus 4.5 --- app/Console/Commands/FcmSendCommand.php | 2 +- app/Console/Commands/FcmTestCommand.php | 4 ++-- app/Services/Fcm/FcmSender.php | 5 +++-- app/Services/PushNotificationService.php | 13 +++++++------ app/Services/TodayIssueObserverService.php | 20 +++++++++++--------- config/fcm.php | 9 +++++++-- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/app/Console/Commands/FcmSendCommand.php b/app/Console/Commands/FcmSendCommand.php index 9177da2..f999bce 100644 --- a/app/Console/Commands/FcmSendCommand.php +++ b/app/Console/Commands/FcmSendCommand.php @@ -12,7 +12,7 @@ class FcmSendCommand extends Command {--tenant= : 테넌트 ID (미지정 시 전체)} {--user= : 사용자 ID (미지정 시 전체)} {--platform= : 플랫폼 (android, ios, web)} - {--channel=push_default : 알림 채널 (push_default, push_urgent)} + {--channel=push_default : 알림 채널 (push_default, push_vendor_register, push_approval_request, push_income, push_sales_order, push_purchase_order, push_contract)} {--title= : 알림 제목 (필수)} {--body= : 알림 내용 (필수)} {--type= : 알림 타입 (invoice_failed 등)} diff --git a/app/Console/Commands/FcmTestCommand.php b/app/Console/Commands/FcmTestCommand.php index c8ae248..bc81f7e 100644 --- a/app/Console/Commands/FcmTestCommand.php +++ b/app/Console/Commands/FcmTestCommand.php @@ -14,7 +14,7 @@ class FcmTestCommand extends Command */ protected $signature = 'fcm:test {--token= : FCM 디바이스 토큰 (필수)} - {--channel=push_default : 알림 채널 ID (push_default, push_urgent)} + {--channel=push_default : 알림 채널 ID (push_default, push_vendor_register, push_approval_request, push_income, push_sales_order, push_purchase_order, push_contract)} {--title=테스트 알림 : 알림 제목} {--body=FCM 테스트 메시지입니다. : 알림 내용} {--data= : 추가 데이터 (JSON 형식)}'; @@ -38,7 +38,7 @@ public function handle(): int $this->line(''); $this->line('사용법:'); $this->line(' php artisan fcm:test --token=YOUR_FCM_TOKEN'); - $this->line(' php artisan fcm:test --token=YOUR_FCM_TOKEN --channel=push_urgent --title="긴급 알림"'); + $this->line(' php artisan fcm:test --token=YOUR_FCM_TOKEN --channel=push_vendor_register --title="신규업체 알림"'); return self::FAILURE; } diff --git a/app/Services/Fcm/FcmSender.php b/app/Services/Fcm/FcmSender.php index 852f576..163f230 100644 --- a/app/Services/Fcm/FcmSender.php +++ b/app/Services/Fcm/FcmSender.php @@ -277,11 +277,12 @@ private function logError(array $message, \Exception $e): void private function getSoundForChannel(string $channelId): string { return match ($channelId) { - 'push_payment' => 'push_payment', + 'push_vendor_register' => 'push_vendor_register', + 'push_approval_request' => 'push_approval_request', + 'push_income' => 'push_income', 'push_sales_order' => 'push_sales_order', 'push_purchase_order' => 'push_purchase_order', 'push_contract' => 'push_contract', - 'push_urgent' => 'push_urgent', default => 'push_default', }; } diff --git a/app/Services/PushNotificationService.php b/app/Services/PushNotificationService.php index d5f858a..8ad9453 100644 --- a/app/Services/PushNotificationService.php +++ b/app/Services/PushNotificationService.php @@ -396,12 +396,13 @@ public function notifyGeneral(string $title, string $body, array $data = [], ?in private function getChannelForEvent(string $event): string { return match ($event) { - 'new_client' => 'push_urgent', - 'payment' => 'push_payment', - 'sales_order' => 'push_sales_order', - 'purchase_order' => 'push_purchase_order', - 'contract' => 'push_contract', - default => 'push_default', + 'new_client' => config('fcm.channels.vendor_register'), + 'payment' => config('fcm.channels.approval_request'), + 'income' => config('fcm.channels.income'), + 'sales_order' => config('fcm.channels.sales_order'), + 'purchase_order' => config('fcm.channels.purchase_order'), + 'contract' => config('fcm.channels.contract'), + default => config('fcm.channels.default'), }; } } diff --git a/app/Services/TodayIssueObserverService.php b/app/Services/TodayIssueObserverService.php index 7f8bc4d..66ff42c 100644 --- a/app/Services/TodayIssueObserverService.php +++ b/app/Services/TodayIssueObserverService.php @@ -712,22 +712,24 @@ public function createIssueWithFcm( * 알림 타입에 따른 FCM 채널 ID 반환 * * 채널별 알림음: - * - push_urgent: 긴급(신규업체) - * - push_payment: 결재 + * - push_vendor_register: 거래처등록(신규업체) + * - push_approval_request: 결재요청 + * - push_income: 입금 * - push_sales_order: 수주 * - push_purchase_order: 발주 * - push_contract: 계약 - * - push_default: 일반 (입금, 출금, 카드 등) + * - 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', // 일반 (입금, 출금, 카드 등) + 'new_vendor' => config('fcm.channels.vendor_register'), // 거래처등록(신규업체) + 'approval_request' => config('fcm.channels.approval_request'), // 결재요청 + 'income' => config('fcm.channels.income'), // 입금 + 'sales_order' => config('fcm.channels.sales_order'), // 수주 + 'purchase_order' => config('fcm.channels.purchase_order'), // 발주 + 'contract' => config('fcm.channels.contract'), // 계약 + default => config('fcm.channels.default'), // 일반 (출금, 카드 등) }; } } diff --git a/config/fcm.php b/config/fcm.php index 4756e2d..2886ab2 100644 --- a/config/fcm.php +++ b/config/fcm.php @@ -38,8 +38,13 @@ | */ 'channels' => [ - 'default' => 'push_default', - 'urgent' => 'push_urgent', + 'default' => 'push_default', + 'vendor_register' => 'push_vendor_register', + 'approval_request' => 'push_approval_request', + 'income' => 'push_income', + 'sales_order' => 'push_sales_order', + 'purchase_order' => 'push_purchase_order', + 'contract' => 'push_contract', ], /*