profileRepository->getPreferredCurrency($userId); } /** * 사용자의 선호 통화를 저장합니다. * * @param int $userId 사용자 ID * @param string $currency 통화 코드 (ISO 4217, FormRequest 에서 등록 통화 검증 완료) * @return string 저장된 통화 코드 */ public function setPreferredCurrency(int $userId, string $currency): string { $this->profileRepository->setPreferredCurrency($userId, $currency); return $currency; } /** * 관리자가 특정 회원의 결제 통화를 변경합니다. (A3) * * 회원 존재 확인 → 통화 저장 → 활동 로그 훅 발화까지 한 도메인 단위로 처리합니다. * * @param int $userId 대상 회원 ID * @param string $currency 통화 코드 (ISO 4217, FormRequest 에서 등록 통화 검증 완료) * @return string 저장된 통화 코드 * * @throws ModelNotFoundException 회원 미존재 시 */ public function changeUserCurrencyByAdmin(int $userId, string $currency): string { $user = $this->userRepository->findById($userId); if ($user === null) { throw (new ModelNotFoundException) ->setModel(User::class, [$userId]); } $previous = $this->profileRepository->getPreferredCurrency($userId); $this->profileRepository->setPreferredCurrency($userId, $currency); // 활동 로그 훅 발화 (EcommerceAdminActivityLogListener 구독) HookManager::doAction('sirsoft-ecommerce.admin.user_currency.changed', $user, [ 'previous_currency' => $previous, 'new_currency' => $currency, ]); return $currency; } }