Stwqresult.php 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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',$this->table.'.manual_result','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',$this->table.'.manual_result','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',$this->table.'.manual_result','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',$this->table.'.manual_result','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. $data[$i]->manual_result = json_decode($data[$i]->manual_result,true);
  46. }
  47. return $data->toArray ();
  48. }
  49. //查询赛事
  50. function matchjg($match_id){
  51. $data = $this->where('match_id',$match_id)->select('id','home_team','guest_team')->first();
  52. if (!$data) {
  53. return -5040000102; //无相关信息
  54. }
  55. return $data->toArray();
  56. }
  57. //更新状态
  58. function updatestatus($field,$where,$data){
  59. $res=$this->where($field,$where)->update($data);
  60. if(!$res) {
  61. return -7020050022;//更新失败
  62. }
  63. return 1;
  64. }
  65. }
  66. ?>