SportsSoccer.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/3/29
  6. * Time: 9:28
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. class SportsSoccer extends BaseModel {
  11. protected $table = "st_zq_competition";
  12. public $timestamps = false;
  13. function getinfo($list = 10, $page, $where = '',$orwhere = '')
  14. {
  15. // $source = \App\Models\Setinfo::where('id','1000')->first();
  16. // if($source->infocontent != '混合数据'){
  17. // $where[] = array('st_zq_local_match.source', '=', $source->infocontent);
  18. // $where[] = array('st_zq_local_league.source', '=', $source->infocontent);
  19. // }
  20. // if (is_array ($where) && count ($where) > 0) {
  21. // $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.id')
  22. // ->join('st_zq_local_match','st_zq_competition.id','=','st_zq_local_match.match_id')
  23. // ->join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')
  24. // ->select('st_zq_competition.id','st_zq_local_match.match_id','st_zq_local_league.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend')
  25. // ->orderby('st_zq_competition.match_date','desc')
  26. // ->orderby('st_zq_competition.match_time','desc')
  27. // ->where($where)
  28. // ->orwhere($orwhere)
  29. // ->paginate ($list);
  30. // } else {
  31. // $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.id')
  32. // ->join('st_zq_local_match','st_zq_competition.id','=','st_zq_local_match.match_id')
  33. // ->join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')
  34. // ->select('st_zq_competition.id','st_zq_local_match.match_id','st_zq_local_league.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend')
  35. // ->orderby('st_zq_competition.match_date','desc')
  36. // ->orderby('st_zq_competition.match_time','desc')
  37. // ->paginate ($list);
  38. // }
  39. if (is_array ($where) && count ($where) > 0) {
  40. $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.lg_id')
  41. ->select('st_zq_competition.id','st_zq_competition.match_id','st_zq_competition.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend')
  42. ->orderby('st_zq_competition.match_date','desc')
  43. ->orderby('st_zq_competition.match_time','desc')
  44. ->where($where)
  45. ->orwhere($orwhere)
  46. ->paginate ($list);
  47. } else {
  48. $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.lg_id')
  49. ->select('st_zq_competition.id','st_zq_competition.match_id','st_zq_competition.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend')
  50. ->orderby('st_zq_competition.match_date','desc')
  51. ->orderby('st_zq_competition.match_time','desc')
  52. ->paginate ($list);
  53. }
  54. if (!$data < 0) {
  55. return -2021052003; //
  56. }
  57. //赛事结果处理状态查询
  58. $result = \App\Models\Comendnotice::where('game_code','zq')->get();
  59. for($i=0;$i<count($data);$i++){
  60. if($data[$i]->match_date == '' && $data[$i]->last_time != ''){
  61. $datetime = explode(' ',$data[$i]->last_time);
  62. $data[$i]->match_date = $datetime[0];
  63. $data[$i]->match_time = $datetime[1];
  64. }
  65. if($data[$i]->status==0){
  66. $data[$i]->status = '未开始';
  67. }else if($data[$i]->status==1){
  68. $data[$i]->status = '正在进行';
  69. }else if($data[$i]->status==2){
  70. $data[$i]->status = '已结束';
  71. }
  72. if($data[$i]->guest_team == ''){
  73. $data[$i]->home_guest = $data[$i]->home_team;
  74. }else{
  75. $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
  76. }
  77. $result = \App\Models\Comendnotice::where('game_code','zq')->where('match_id',$data[$i]->match_id)->first();
  78. if(!empty($result)){
  79. if($result->status == '0'){
  80. $data[$i]->result = '<a class="layui-btn layui-btn-sm dealwith" lay-event="detail" pid="id" uri="/admin/SportsSoccer/dealwith/?id=" href="javascript:dealwith(\'/admin/SportsSoccer/dealwith/?id='.$result->id.'\');" style="background-color: #FF5722;"> 处理 </a>';
  81. }else{
  82. $data[$i]->result = '<a class="layui-btn layui-btn-sm dealwith" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: #FFAF60;"> 已处理 </a>';
  83. }
  84. }else{
  85. $data[$i]->result = '<a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 处理 </a>';
  86. }
  87. //赛事结果状态
  88. // if(!empty($result)){
  89. // for($j=0;$j<count($result);$j++){
  90. // if($data[$i]->match_id == $result[$j]->match_id){
  91. // $data[$i]->result_status = $result[$j]->status;
  92. // }else{
  93. // $data[$i]->result_status = null;
  94. // }
  95. // }
  96. // }else{
  97. // $data[$i]->result_status = null;
  98. // }
  99. // if($data[$i]->result_status != null){
  100. // if($data[$i]->result_status == '0'){
  101. // $data[$i]->result = '<a class="layui-btn layui-btn-sm dealwith" lay-event="detail" pid="id" uri="/admin/SportsSoccer/dealwith/?id=" href="javascript:dealwith(\'/admin/SportsSoccer/dealwith/?id='.$result->id.'\');" style="background-color: #FF5722;"> 处理 </a>';
  102. // }else{
  103. // $data[$i]->result = '<a class="layui-btn layui-btn-sm dealwith" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已处理 </a>';
  104. // }
  105. // }else{
  106. // $data[$i]->result = '<a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 处理 </a>';
  107. // }
  108. }
  109. return $data->toArray();
  110. }
  111. //更新设置
  112. function updateInfos($data,$id){
  113. $res=$this->where('id',$id)->update($data);
  114. if(!$res) {
  115. return -7020050022;//更新失败
  116. }
  117. return 1;
  118. }
  119. function getmatchid($id){
  120. $res=$this->where('id',$id)->first();
  121. if(!$res){
  122. return -2021052003;
  123. }
  124. return $res->match_id;
  125. }
  126. }