fix:바로빌 컨트롤러 테넌트별 서버 모드 적용

- EtaxController, EaccountController, EcardController, HometaxController에
  테넌트별 서버 모드(server_mode) 적용 로직 추가
- applyMemberServerMode() 메서드로 회원사별 테스트/운영 서버 전환
- 기존 전역 BarobillConfig 대신 BarobillMember.server_mode 우선 적용

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-03 07:53:36 +09:00
parent 425e0e79d6
commit 83b2c1d16c
4 changed files with 172 additions and 4 deletions

View File

@@ -107,16 +107,59 @@ public function index(Request $request): View|Response
// 해당 테넌트의 바로빌 회원사 정보
$barobillMember = BarobillMember::where('tenant_id', $tenantId)->first();
// 테넌트별 서버 모드 적용 (회원사 설정 우선)
$isTestMode = $barobillMember ? $barobillMember->isTestMode() : $this->isTestMode;
// 서버 모드에 따라 SOAP 설정 재초기화
if ($barobillMember && $barobillMember->server_mode) {
$this->applyMemberServerMode($barobillMember);
}
return view('barobill.eaccount.index', [
'certKey' => $this->certKey,
'corpNum' => $this->corpNum,
'isTestMode' => $this->isTestMode,
'isTestMode' => $isTestMode,
'hasSoapClient' => $this->soapClient !== null,
'currentTenant' => $currentTenant,
'barobillMember' => $barobillMember,
]);
}
/**
* 회원사 서버 모드에 따라 SOAP 설정 적용
*/
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
$this->soapUrl = $baseUrl . '/BANKACCOUNT.asmx?WSDL';
} else {
// 설정이 없으면 기본 URL 사용
$this->soapUrl = $memberTestMode
? 'https://testws.baroservice.com/BANKACCOUNT.asmx?WSDL'
: 'https://ws.baroservice.com/BANKACCOUNT.asmx?WSDL';
}
// SOAP 클라이언트 재초기화
$this->initSoapClient();
}
}
/**
* 등록된 계좌 목록 조회 (GetBankAccountEx)
*/

View File

@@ -107,16 +107,59 @@ public function index(Request $request): View|Response
// 해당 테넌트의 바로빌 회원사 정보
$barobillMember = BarobillMember::where('tenant_id', $tenantId)->first();
// 테넌트별 서버 모드 적용 (회원사 설정 우선)
$isTestMode = $barobillMember ? $barobillMember->isTestMode() : $this->isTestMode;
// 서버 모드에 따라 SOAP 설정 재초기화
if ($barobillMember && $barobillMember->server_mode) {
$this->applyMemberServerMode($barobillMember);
}
return view('barobill.ecard.index', [
'certKey' => $this->certKey,
'corpNum' => $this->corpNum,
'isTestMode' => $this->isTestMode,
'isTestMode' => $isTestMode,
'hasSoapClient' => $this->soapClient !== null,
'currentTenant' => $currentTenant,
'barobillMember' => $barobillMember,
]);
}
/**
* 회원사 서버 모드에 따라 SOAP 설정 적용
*/
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
$this->soapUrl = $baseUrl . '/CARD.asmx?WSDL';
} else {
// 설정이 없으면 기본 URL 사용
$this->soapUrl = $memberTestMode
? 'https://testws.baroservice.com/CARD.asmx?WSDL'
: 'https://ws.baroservice.com/CARD.asmx?WSDL';
}
// SOAP 클라이언트 재초기화
$this->initSoapClient();
}
}
/**
* 등록된 카드 목록 조회 (GetCardEx2)
* 레퍼런스: https://dev.barobill.co.kr/docs/references/카드조회-API#GetCardEx2

View File

@@ -99,16 +99,56 @@ public function index(Request $request): View|Response
? BarobillMember::where('tenant_id', $tenantId)->first()
: null;
// 테넌트별 서버 모드 적용 (회원사 설정 우선)
$isTestMode = $barobillMember ? $barobillMember->isTestMode() : $this->isTestMode;
// 서버 모드에 따라 SOAP 설정 재초기화
if ($barobillMember && $barobillMember->server_mode) {
$this->applyMemberServerMode($barobillMember);
}
return view('barobill.etax.index', [
'certKey' => $this->certKey,
'corpNum' => $this->corpNum,
'isTestMode' => $this->isTestMode,
'isTestMode' => $isTestMode,
'hasSoapClient' => $this->soapClient !== null,
'currentTenant' => $currentTenant,
'barobillMember' => $barobillMember,
]);
}
/**
* 회원사 서버 모드에 따라 SOAP 설정 적용
*/
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$this->soapUrl = $config->base_url . '/TI.asmx?WSDL';
} else {
// 설정이 없으면 기본 URL 사용
$this->soapUrl = $memberTestMode
? 'https://testws.baroservice.com/TI.asmx?WSDL'
: 'https://ws.baroservice.com/TI.asmx?WSDL';
}
// SOAP 클라이언트 재초기화
$this->initSoapClient();
}
}
// 바로빌 파트너사 (본사) 테넌트 ID
private const HEADQUARTERS_TENANT_ID = 1;

View File

@@ -107,10 +107,18 @@ public function index(Request $request): View|Response
// 해당 테넌트의 바로빌 회원사 정보
$barobillMember = BarobillMember::where('tenant_id', $tenantId)->first();
// 테넌트별 서버 모드 적용 (회원사 설정 우선)
$isTestMode = $barobillMember ? $barobillMember->isTestMode() : $this->isTestMode;
// 서버 모드에 따라 SOAP 설정 재초기화
if ($barobillMember && $barobillMember->server_mode) {
$this->applyMemberServerMode($barobillMember);
}
return view('barobill.hometax.index', [
'certKey' => $this->certKey,
'corpNum' => $this->corpNum,
'isTestMode' => $this->isTestMode,
'isTestMode' => $isTestMode,
'hasSoapClient' => $this->soapClient !== null,
'tenantId' => $tenantId,
'currentTenant' => $currentTenant,
@@ -118,6 +126,40 @@ public function index(Request $request): View|Response
]);
}
/**
* 회원사 서버 모드에 따라 SOAP 설정 적용
*/
private function applyMemberServerMode(BarobillMember $member): void
{
$memberTestMode = $member->isTestMode();
// 현재 모드와 다르면 재설정
if ($this->isTestMode !== $memberTestMode) {
$this->isTestMode = $memberTestMode;
// 해당 모드의 BarobillConfig 조회
$config = BarobillConfig::where('environment', $memberTestMode ? 'test' : 'production')
->where('is_active', true)
->first();
if ($config) {
$this->certKey = $config->cert_key;
$this->corpNum = $config->corp_num;
$this->baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
} else {
// 설정이 없으면 기본 URL 사용
$this->baseUrl = $memberTestMode
? 'https://testws.baroservice.com'
: 'https://ws.baroservice.com';
}
// SOAP 클라이언트 재초기화
$this->initSoapClient();
}
}
/**
* 매출 세금계산서 목록 조회 (GetPeriodTaxInvoiceSalesList)
*