<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Carbon;

class UserTags extends Model
{
    const TABLE = 'QPAccountsDB.dbo.AccountsTabExplain';
    protected $table = self::TABLE;

    public $timestamps = false;
    protected $guarded = [];

    //protected $fillable = ['UserID', 'SpreaderID', 'GameID', 'NickName', 'MemberOrder', 'MemberOverDate','Nullity','IsAndroid','Channel','RegisterDate'];


    public static function list()
    {

        // 所有VIP
        $allVip = self::whereBetween('TabID', [302, 309])->sum('TotalCount');


        // 所有对局过的用户
        $allMatchUp = self::whereBetween('TabID', [402, 405])->sum('TotalCount');

        // 所有提现成功用户
        $allCash = self::whereBetween('TabID', [502, 508])->sum('TotalCount');

        // 所有代理
        $allAgent = self::whereBetween('TabID', [602, 607])->sum('TotalCount');

        // 所有TP对局过的玩家
        $allTp = self::whereBetween('TabID', [1002, 1006])->sum('TotalCount');

        // 所有RM对局过的玩家
        $allRm = self::whereBetween('TabID', [1102, 1106])->sum('TotalCount');



        $type1 = self::select('TabID', 'TypeName', 'TotalCount')->where('TabID',101)->orderBy('TabID', 'asc')->get()->toArray();
        $type2 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [201, 204])->orderBy('TabID', 'asc')->get()->toArray();
        $type3 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [301, 309])->orderBy('TabID', 'asc')->get()->toArray();
        $type4 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [401, 405])->orderBy('TabID', 'asc')->get()->toArray();
        $type5 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [501, 508])->orderBy('TabID', 'asc')->get()->toArray();
        $type6 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [601, 607])->orderBy('TabID', 'asc')->get()->toArray();
        $type7 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [701, 702])->orderBy('TabID', 'asc')->get()->toArray();
        $type8 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [801, 802])->orderBy('TabID', 'asc')->get()->toArray();
        $type9 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [901, 903])->orderBy('TabID', 'asc')->get()->toArray();
        $type10 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [1001, 1006])->orderBy('TabID', 'asc')->get()->toArray();
        $type11 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [1101, 1106])->orderBy('TabID', 'asc')->get()->toArray();
        $type12 = self::select('TabID', 'TypeName', 'TotalCount')->whereBetween('TabID', [1301, 1310])->orderBy('TabID', 'asc')->get()->toArray();



        //$type3[]['all'] = $allVip;

        $compact = compact('allVip','allAgent','allCash','allMatchUp','allTp','allRm','type1','type2','type3','type4','type5','type6','type7','type8','type9','type10','type11','type12');

        return $compact;
    }


}
