<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Services\MiningService;

class ProcessMining extends Command
{
    protected $signature = 'mining:process';
    protected $description = 'Process all active mining sessions and calculate rewards';

    protected $miningService;

    public function __construct(MiningService $miningService)
    {
        parent::__construct();
        $this->miningService = $miningService;
    }

    public function handle()
    {
        $this->info('Processing mining sessions...');
        
        $result = $this->miningService->processAllActiveSessions();
        
        $this->info("Processed {$result['processed']} active sessions");
        $this->info("Expired {$result['expired']} sessions");
        $this->info("Total earnings distributed: {$result['total_earnings']} CBC");
        
        return 0;
    }
}