refactor: [barobill] chandj 레거시 DB 커넥션 및 동기화 기능 제거

- config/database.php에서 chandj 커넥션 정의 제거
- BarobillConfigController에서 syncCompanies(), getCompanies() 메서드 제거
- api.php에서 barobill/companies 동기화 라우트 제거
- 로컬/서버 .env에서 CHANDJ_DB_* 환경변수 제거
This commit is contained in:
김보곤
2026-02-21 10:47:51 +09:00
parent 06de27c570
commit 1cf48f7c53
3 changed files with 0 additions and 117 deletions

View File

@@ -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' => [],
]);
}
}
}

View File

@@ -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',

View File

@@ -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');