<?php

namespace App\Models;

use DB;

use App\Models\Stzqresult;
use App\Models\Stlqresult;
use App\Models\Stbqresult;
use App\Models\Stwqresult;

class MoneyBuySimplex extends BaseModel
{

    protected $table = "money_buy_simplex";
    public $timestamps = false;


    //单式订单数据及比赛结果数据
    public function OrderinfoResult($order_id)
    {
        $Ordermodel = $this->where('order_id', $order_id)->first();
        if (empty($Ordermodel)) {
            return false;
        }
        $game_code = $Ordermodel->game_code;
        $match_id = $Ordermodel->match_id;

        switch ($game_code) {
            case 'zq':
                $model = new Stzqresult();
                break;
            case 'lq':
                $model = new Stlqresult();
                break;
            case 'bq':
                $model = new Stbqresult();
                break;
            default;
                $model = new Stwqresult();
                break;
        }
        $resultModel = $model->where([['match_id', '=', $match_id]])->first();

        return [
            'order' => $Ordermodel,
            'result' => $resultModel,
        ];

    }

    //一段时间内的提现人数
    public function countUser($timearea)
    {
        $data = $this->select('account_identity')->where('money_buy_simplex.status', '<>', 4)->join('account','money_buy_simplex.account_identity', '=', 'account.identity')->where('account.status','<>','4')->where('account.user_type','1')->whereBetween('money_time', $timearea)->groupBy('account_identity')->get();

        $data = $data->toArray();
        return $data;
    }

}
