From 1cf48f7c53561b38e2098c6342ee7612de360cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sat, 21 Feb 2026 10:47:51 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20[barobill]=20chandj=20=EB=A0=88?= =?UTF-8?q?=EA=B1=B0=EC=8B=9C=20DB=20=EC=BB=A4=EB=84=A5=EC=85=98=20?= =?UTF-8?q?=EB=B0=8F=20=EB=8F=99=EA=B8=B0=ED=99=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - config/database.php에서 chandj 커넥션 정의 제거 - BarobillConfigController에서 syncCompanies(), getCompanies() 메서드 제거 - api.php에서 barobill/companies 동기화 라우트 제거 - 로컬/서버 .env에서 CHANDJ_DB_* 환경변수 제거 --- .../Barobill/BarobillConfigController.php | 95 ------------------- config/database.php | 16 ---- routes/api.php | 6 -- 3 files changed, 117 deletions(-) diff --git a/app/Http/Controllers/Api/Admin/Barobill/BarobillConfigController.php b/app/Http/Controllers/Api/Admin/Barobill/BarobillConfigController.php index 690639d7..f002493f 100644 --- a/app/Http/Controllers/Api/Admin/Barobill/BarobillConfigController.php +++ b/app/Http/Controllers/Api/Admin/Barobill/BarobillConfigController.php @@ -4,7 +4,6 @@ use App\Http\Controllers\Controller; use App\Models\Barobill\BarobillConfig; -use App\Models\Barobill\BarobillMember; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -233,98 +232,4 @@ public function toggleActive(int $id): JsonResponse } } - /** - * barobill_companies에서 barobill_members로 동기화 - * chandj DB(sales 레거시)에서 데이터를 가져와 samdb(MNG)로 동기화 - */ - public function syncCompanies(): JsonResponse - { - DB::beginTransaction(); - try { - // chandj DB의 barobill_companies 테이블에서 데이터 조회 - $companies = DB::connection('chandj') - ->table('barobill_companies') - ->where('is_active', 1) - ->whereNotNull('barobill_user_id') - ->get(); - - $synced = 0; - $skipped = 0; - $errors = []; - - foreach ($companies as $company) { - // 이미 존재하는지 확인 (사업자번호 기준) - $existing = BarobillMember::where('biz_no', $company->corp_num)->first(); - - if ($existing) { - // 기존 데이터 업데이트 (비밀번호 제외) - $existing->update([ - 'corp_name' => $company->company_name, - 'ceo_name' => $company->ceo_name ?? $existing->ceo_name, - 'barobill_id' => $company->barobill_user_id, - ]); - $skipped++; - } else { - // 새로 생성 - BarobillMember::create([ - 'tenant_id' => 1, // 기본 테넌트 - 'biz_no' => $company->corp_num, - 'corp_name' => $company->company_name, - 'ceo_name' => $company->ceo_name ?? '', - 'barobill_id' => $company->barobill_user_id, - 'barobill_pwd' => '', // 비밀번호는 별도로 입력 필요 - 'status' => 'active', - ]); - $synced++; - } - } - - DB::commit(); - - return response()->json([ - 'success' => true, - 'message' => "동기화 완료: 신규 {$synced}건, 업데이트 {$skipped}건", - 'data' => [ - 'synced' => $synced, - 'updated' => $skipped, - 'total' => $companies->count(), - ], - ]); - } catch (\Exception $e) { - DB::rollBack(); - Log::error('바로빌 회원사 동기화 실패', ['error' => $e->getMessage()]); - - return response()->json([ - 'success' => false, - 'message' => '동기화 중 오류가 발생했습니다: ' . $e->getMessage(), - ], 500); - } - } - - /** - * barobill_companies 목록 조회 (chandj DB) - */ - public function getCompanies(): JsonResponse - { - try { - $companies = DB::connection('chandj') - ->table('barobill_companies') - ->select('id', 'company_name', 'corp_num', 'barobill_user_id', 'ceo_name', 'is_active', 'memo', 'created_at') - ->orderBy('id') - ->get(); - - return response()->json([ - 'success' => true, - 'data' => $companies, - ]); - } catch (\Exception $e) { - Log::error('chandj DB 연결 실패', ['error' => $e->getMessage()]); - - return response()->json([ - 'success' => false, - 'message' => 'chandj DB 연결에 실패했습니다: ' . $e->getMessage(), - 'data' => [], - ]); - } - } } diff --git a/config/database.php b/config/database.php index 523f69e8..6da81efc 100644 --- a/config/database.php +++ b/config/database.php @@ -83,22 +83,6 @@ ]) : [], ], - // sales 레거시 시스템 DB (chandj) - 'chandj' => [ - 'driver' => 'mysql', - 'host' => env('CHANDJ_DB_HOST', 'sam-mysql-1'), - 'port' => env('CHANDJ_DB_PORT', '3306'), - 'database' => env('CHANDJ_DB_DATABASE', 'chandj'), - 'username' => env('CHANDJ_DB_USERNAME', 'root'), - 'password' => env('CHANDJ_DB_PASSWORD', 'root'), - 'unix_socket' => '', - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'prefix_indexes' => true, - 'strict' => false, - 'engine' => null, - ], 'mariadb' => [ 'driver' => 'mariadb', diff --git a/routes/api.php b/routes/api.php index 3ebb658a..87105a16 100644 --- a/routes/api.php +++ b/routes/api.php @@ -100,12 +100,6 @@ Route::post('/{id}/toggle-active', [\App\Http\Controllers\Api\Admin\Barobill\BarobillConfigController::class, 'toggleActive'])->name('toggle-active'); }); - // 바로빌 테넌트(회원사) 동기화 API - Route::prefix('barobill/companies')->name('barobill.companies.')->group(function () { - Route::get('/', [\App\Http\Controllers\Api\Admin\Barobill\BarobillConfigController::class, 'getCompanies'])->name('index'); - Route::post('/sync', [\App\Http\Controllers\Api\Admin\Barobill\BarobillConfigController::class, 'syncCompanies'])->name('sync'); - }); - // 바로빌 설정 API (회원사용) Route::prefix('barobill/settings')->name('barobill.settings.')->group(function () { Route::get('/', [\App\Http\Controllers\Api\Admin\Barobill\BarobillSettingController::class, 'show'])->name('show');