<?php

namespace App\Console\Commands\Payouts;

use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Yajny\EventsYj\Events\RecalculateBalance;
use Yajny\MailYj\Mails\NewContactEmail;
use Yajny\MailYj\Mails\PayoutsValidationStep1;
use Yajny\MailYj\Mails\PayoutsValidationStep2;
use Yajny\Member\Models\BalanceTransaction;
use Yajny\Member\Models\Sale;
use Yajny\Member\Models\UserNewBonus;
use Yajny\Member\Models\UserPayouts;
use Yajny\Member\Models\UserSales;

class unprocessedPayouts extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'payouts:check';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'send email to operation team to unprocessed payouts';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle() {
            $payouts = UserPayouts::where('status', 'processing')
                ->where('api_response','')
                ->orWhere('api_response',null)
                ->get();
            foreach ($payouts as $payout){
                $this->output->write($payout->id,true);

            }
            Mail::to(["adnen.ettayeb@yajny.com","karimabbas@yajny.com"])->locale("en")->queue(new \Yajny\MailYj\Mails\unprocessedPayouts($payouts));


    }
}
