Account_list.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Support\Facades\DB;
  4. /**
  5. *
  6. */
  7. class Account_list extends BaseModel {
  8. protected $table = "account_list";
  9. public $timestamps = false;
  10. //由identity获取用户信息
  11. function getInfoBy($u_id) {
  12. $data = $this->where('account_identity', $u_id)->first();
  13. if (!$data) {
  14. return -5040012022;
  15. }
  16. return $data->toArray();
  17. }
  18. //统计在线用户
  19. function getOnlineUser(){
  20. $data=$this->select(DB::Raw('count(id) as value,last_url as name'))
  21. ->where('statuss',1)->whereNotNull('last_url')
  22. ->groupBy('last_url')
  23. ->get();
  24. if(!$data){
  25. return -2020032103;
  26. }
  27. return $data->toArray();
  28. }
  29. //获取一组用户的余额和id
  30. function getAccountCash($account_name_array){
  31. // DB::connection()->enableQueryLog();
  32. $data=$this->select('cash','account_identity','account as account_name')->whereIn('account',$account_name_array)->get();
  33. if(!$data){
  34. return -5040012022;
  35. }
  36. // $queries = DB::getQueryLog();
  37. // print_r($queries);
  38. return $data->toArray();
  39. }
  40. protected function getInfo($account_name){
  41. return $this->getMsg($account_name);
  42. }
  43. function getMsg($account_name){
  44. $data=$this->select('account as account_name','account_identity','register_ip','register_time','grade','last_time','cash','token')
  45. ->where('account',$account_name)
  46. ->first();
  47. if(!$data){
  48. return -4010100202;
  49. }
  50. return $data->toArray();
  51. }
  52. }
  53. ?>