Stwqresult.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Stwqresult extends Model
  5. {
  6. protected $table = 'st_wq_result';
  7. public $timestamps = false;
  8. function resultlist($list = 10, $page, $where = '', $orwhere = '',$if_order)
  9. {
  10. $match_ids = \App\Models\MoneyBuyMatch::select('match_id')->where('game_code','wq')->get()->toArray();
  11. $match_ids = array_column($match_ids,'match_id');
  12. //去重
  13. $match_ids = array_unique($match_ids);
  14. if($if_order == 1){
  15. if (is_array ($where) && count ($where) > 0) {
  16. $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->where($where)->wherein('st_wq_competition.id',$match_ids)->paginate ($list);
  17. } else {
  18. $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->wherein('st_wq_competition.id',$match_ids)->paginate ($list);
  19. }
  20. }else{
  21. if (is_array ($where) && count ($where) > 0) {
  22. $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->where($where)->paginate ($list);
  23. } else {
  24. $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->paginate ($list);
  25. }
  26. }
  27. $newsim = new \App\Models\SportsNoteList();
  28. $simplex = $newsim->getsim('wq');
  29. $newstr = new \App\Models\MoneyBuyStr();
  30. $str = $newstr->strmatchs('wq');
  31. //print_r($str);exit;
  32. for ($i=0; $i < count($data); $i++) {
  33. $data[$i]->numsim = 0;
  34. for ($j=0; $j < count($simplex); $j++) {
  35. if($simplex[$j]['match_id'] == $data[$i]->match_id){
  36. $data[$i]->numsim = $data[$i]->numsim+1;
  37. }
  38. }
  39. $data[$i]->numstr = 0;
  40. for ($a=0; $a < count($str); $a++) {
  41. if(in_array($data[$i]->match_id,$str[$a]['match_ids'])){
  42. $data[$i]->numstr = $data[$i]->numstr+1;
  43. }
  44. }
  45. }
  46. return $data->toArray ();
  47. }
  48. //查询赛事
  49. function matchjg($match_id){
  50. $data = $this->where('match_id',$match_id)->select('id','home_team','guest_team')->first();
  51. if (!$data) {
  52. return -5040000102; //无相关信息
  53. }
  54. return $data->toArray();
  55. }
  56. //更新状态
  57. function updatestatus($field,$where,$data){
  58. $res=$this->where($field,$where)->update($data);
  59. if(!$res) {
  60. return -7020050022;//更新失败
  61. }
  62. return 1;
  63. }
  64. }
  65. ?>