<?php

namespace App\Models;
use Illuminate\Support\Facades\DB;
/**
 *
 */
class Account_list extends BaseModel {
	protected $table = "account_list";
	public $timestamps = false;

    //由identity获取用户信息
    function getInfoBy($u_id) {
        $data = $this->where('account_identity', $u_id)->first();
        if (!$data) {
            return -5040012022;
        }
        return $data->toArray();
    }


    //统计在线用户
    function getOnlineUser(){
        $data=$this->select(DB::Raw('count(id) as value,last_url as name'))
            ->where('statuss',1)->whereNotNull('last_url')
            ->groupBy('last_url')
            ->get();
        if(!$data){
            return -2020032103;
        }
        return $data->toArray();
    }
    //获取一组用户的余额和id
   function getAccountCash($account_name_array){
//        DB::connection()->enableQueryLog();
        $data=$this->select('cash','account_identity','account as account_name')->whereIn('account',$account_name_array)->get();
        if(!$data){
            return -5040012022;
        }
//        $queries = DB::getQueryLog();
//        print_r($queries);
        return $data->toArray();
   }

       protected  function  getInfo($account_name){
           return $this->getMsg($account_name);
       }

    function getMsg($account_name){
        $data=$this->select('account as account_name','account_identity','register_ip','register_time','grade','last_time','cash','token')
            ->where('account',$account_name)
            ->first();
        if(!$data){
            return -4010100202;
        }
        return $data->toArray();
    }
}

?>