<?php
/**
 * Created by PhpStorm.
 * User: sunil
 * Date: 9/29/18
 * Time: 4:30 PM
 */

namespace App\Console\Commands;


use App\Http\Controllers\Admin\ConsumerApplicationController;
use App\PaymentEmi;
use App\Services;
use App\Slack;
use Illuminate\Console\Command;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;

class PenaltyReminders extends Command
{

    protected $signature = 'penalty:emi_reminder';

    public function __construct(){
        parent::__construct();
    }

    public function handle(){
        $hour = date('H',time());
        //if($hour == 9) {
            $start_time = time();
            $paymentFile = new PaymentEmi();
            $serviceCount = $paymentFile->dailyReminder();

            if ($paymentFile->smsCount || $paymentFile->emailCount)
                (new Slack(new Request(['title'=>'Over Due Reminder Summary','fields'=>['Total Email Sent'=>$paymentFile->emailCount,'Total SMS Sent'=>$paymentFile->smsCount],'group' => 'payment_collection'])))->send();

            (new Services())->log($this->signature, ['status' => true, 'service_count' => $serviceCount, 'start_time' => $start_time]);
//        }else{
//            return true;
//        }
    }

}