41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Console\Commands;
|
||
|
|
|
||
|
|
use App\Services\Barobill\BarobillCardSyncService;
|
||
|
|
use Illuminate\Console\Command;
|
||
|
|
|
||
|
|
class SyncBarobillCardTransactions extends Command
|
||
|
|
{
|
||
|
|
protected $signature = 'barobill:sync-cards
|
||
|
|
{--tenant= : 특정 테넌트만 동기화}
|
||
|
|
{--days=7 : 동기화 대상 일수 (기본 7일)}';
|
||
|
|
|
||
|
|
protected $description = '바로빌 카드 사용내역 자동 동기화 (전체 테넌트)';
|
||
|
|
|
||
|
|
public function handle(BarobillCardSyncService $service): int
|
||
|
|
{
|
||
|
|
$tenantId = $this->option('tenant');
|
||
|
|
$days = (int) $this->option('days');
|
||
|
|
|
||
|
|
if ($tenantId) {
|
||
|
|
$this->info("테넌트 {$tenantId} 카드 동기화 시작 (최근 {$days}일)");
|
||
|
|
$result = $service->syncTenant((int) $tenantId, $days);
|
||
|
|
$this->info("완료: 신규 {$result['created']}건, 갱신 {$result['updated']}건");
|
||
|
|
} else {
|
||
|
|
$this->info("전체 테넌트 카드 동기화 시작 (최근 {$days}일)");
|
||
|
|
$result = $service->syncAll($days);
|
||
|
|
$this->info("완료: {$result['synced']}개 테넌트, 신규 {$result['created']}건, 갱신 {$result['updated']}건");
|
||
|
|
|
||
|
|
if (! empty($result['errors'])) {
|
||
|
|
$this->warn('오류 발생:');
|
||
|
|
foreach ($result['errors'] as $error) {
|
||
|
|
$this->error(" - {$error}");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return self::SUCCESS;
|
||
|
|
}
|
||
|
|
}
|