<?php

namespace App\Console\Commands\User;

use App\Services\Notice\UserNoticeService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;

class TestCommand extends Command
{
    protected $signature = "user:test";

    protected $description = "心动考验|发放内测资格";

    public function handle()
    {
        $istested = Redis::smembers("fpdx_supervip_test");
        $hide = implode(",", $istested);
        $time = mktime(18, 0, 0) - 86400;
        $users = DB::table("kdgx_fpdx_invitation_card")
            ->select("uid")
            ->where("created_at", ">", $time)
            ->whereNotIn("uid", $hide)
            ->distinct()
            ->count('uid');
        $noticeService = new UserNoticeService();
        foreach ($users as $user) {
            $noticeService->test($user->uid);
        }
    }
}
