barobillService->getSetting(); $member = BarobillMember::withoutGlobalScopes() ->where('tenant_id', $tenantId) ->first(); $accountCount = 0; $cardCount = 0; if ($member) { $accountCount = BarobillBankTransaction::withoutGlobalScopes() ->where('tenant_id', $tenantId) ->distinct('bank_account_num') ->count('bank_account_num'); $cardCount = BarobillCardTransaction::withoutGlobalScopes() ->where('tenant_id', $tenantId) ->distinct('card_num') ->count('card_num'); } return [ 'bank_service_count' => $accountCount, 'account_link_count' => $accountCount, 'card_count' => $cardCount, 'member' => $member ? [ 'barobill_id' => $member->barobill_id, 'biz_no' => $member->formatted_biz_no, 'corp_name' => $member->corp_name, 'status' => $member->status, 'server_mode' => $member->server_mode ?? 'test', ] : ($setting ? [ 'barobill_id' => $setting->barobill_id, 'biz_no' => $setting->corp_num, 'status' => $setting->isVerified() ? 'active' : 'inactive', 'server_mode' => $this->barobillService->isTestMode() ? 'test' : 'production', ] : null), ]; }, __('message.fetched')); } /** * 바로빌 로그인 정보 등록 */ public function login(Request $request) { $data = $request->validate([ 'barobill_id' => 'required|string', 'password' => 'required|string', ]); return ApiResponse::handle(function () use ($data) { return $this->barobillService->saveSetting([ 'barobill_id' => $data['barobill_id'], ]); }, __('message.saved')); } /** * 바로빌 회원가입 정보 등록 */ public function signup(Request $request) { $data = $request->validate([ 'business_number' => 'required|string|size:10', 'company_name' => 'required|string', 'ceo_name' => 'required|string', 'business_type' => 'nullable|string', 'business_category' => 'nullable|string', 'address' => 'nullable|string', 'barobill_id' => 'required|string', 'password' => 'required|string', 'manager_name' => 'nullable|string', 'manager_phone' => 'nullable|string', 'manager_email' => 'nullable|email', ]); return ApiResponse::handle(function () use ($data) { return $this->barobillService->saveSetting([ 'corp_num' => $data['business_number'], 'corp_name' => $data['company_name'], 'ceo_name' => $data['ceo_name'], 'biz_type' => $data['business_type'] ?? null, 'biz_class' => $data['business_category'] ?? null, 'addr' => $data['address'] ?? null, 'barobill_id' => $data['barobill_id'], 'contact_name' => $data['manager_name'] ?? null, 'contact_tel' => $data['manager_phone'] ?? null, 'contact_id' => $data['manager_email'] ?? null, ]); }, __('message.saved')); } /** * 바로빌 서비스 URL 조회 (공통) */ private function getServiceUrl(string $path): array { return ['url' => $this->barobillService->getBaseUrl().$path]; } /** * 은행 빠른조회 서비스 URL 조회 */ public function bankServiceUrl() { return ApiResponse::handle(function () { return $this->getServiceUrl('/BANKACCOUNT.asmx'); }, __('message.fetched')); } /** * 계좌 연동 등록 URL 조회 */ public function accountLinkUrl() { return ApiResponse::handle(function () { return $this->getServiceUrl('/BANKACCOUNT.asmx'); }, __('message.fetched')); } /** * 카드 연동 등록 URL 조회 */ public function cardLinkUrl() { return ApiResponse::handle(function () { return $this->getServiceUrl('/CARD.asmx'); }, __('message.fetched')); } /** * 공인인증서 등록 URL 조회 */ public function certificateUrl() { return ApiResponse::handle(function () { return $this->getServiceUrl('/CORPSTATE.asmx'); }, __('message.fetched')); } }