feat: [barobill] SOAP 동기화 서비스 신규 구축
- BarobillSoapService: PHP SoapClient 기반 SOAP 래퍼 (회원/계좌/카드/인증서) - BarobillBankSyncService: 은행 거래내역 SOAP 조회 → DB 캐시 동기화 - BarobillCardSyncService: 카드 거래내역 SOAP 조회 → DB 캐시 동기화 - HometaxSyncService: 홈택스 세금계산서 upsert 동기화 - BarobillSyncController: 동기화/회원/인증서/잔액 API 11개 엔드포인트 - SyncBarobillDataJob: 매일 06:00/06:30 자동 동기화 스케줄러 - BarobillController.status() 보강: 실제 계좌/카드 수 표시
This commit is contained in:
85
app/Jobs/Barobill/SyncBarobillDataJob.php
Normal file
85
app/Jobs/Barobill/SyncBarobillDataJob.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Barobill;
|
||||
|
||||
use App\Models\Barobill\BarobillMember;
|
||||
use App\Services\Barobill\BarobillBankSyncService;
|
||||
use App\Services\Barobill\BarobillCardSyncService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* 바로빌 데이터 자동 동기화 Job
|
||||
*
|
||||
* 스케줄러에서 매일 실행하여 활성 회원의 은행/카드 거래내역을 동기화한다.
|
||||
*/
|
||||
class SyncBarobillDataJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
public int $timeout = 300;
|
||||
|
||||
public function __construct(
|
||||
private string $syncType = 'all',
|
||||
) {}
|
||||
|
||||
public function handle(
|
||||
BarobillBankSyncService $bankSyncService,
|
||||
BarobillCardSyncService $cardSyncService,
|
||||
): void {
|
||||
$members = BarobillMember::withoutGlobalScopes()
|
||||
->where('status', 'active')
|
||||
->where('server_mode', 'production')
|
||||
->get();
|
||||
|
||||
if ($members->isEmpty()) {
|
||||
Log::info('[SyncBarobill] 활성 회원 없음, 스킵');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$yesterday = Carbon::yesterday()->format('Ymd');
|
||||
$today = Carbon::today()->format('Ymd');
|
||||
|
||||
foreach ($members as $member) {
|
||||
try {
|
||||
if (in_array($this->syncType, ['all', 'bank'])) {
|
||||
$result = $bankSyncService->syncIfNeeded(
|
||||
$member->tenant_id,
|
||||
$yesterday,
|
||||
$today
|
||||
);
|
||||
Log::info('[SyncBarobill] 은행 동기화 완료', [
|
||||
'tenant_id' => $member->tenant_id,
|
||||
'result' => $result,
|
||||
]);
|
||||
}
|
||||
|
||||
if (in_array($this->syncType, ['all', 'card'])) {
|
||||
$result = $cardSyncService->syncCardTransactions(
|
||||
$member->tenant_id,
|
||||
$yesterday,
|
||||
$today
|
||||
);
|
||||
Log::info('[SyncBarobill] 카드 동기화 완료', [
|
||||
'tenant_id' => $member->tenant_id,
|
||||
'result' => $result,
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('[SyncBarobill] 동기화 실패', [
|
||||
'tenant_id' => $member->tenant_id,
|
||||
'sync_type' => $this->syncType,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user