SportsBasket.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 SportsBasket extends BaseModel {
  11. protected $table = "st_lq_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_lq_local_match.source', '=', $source->infocontent);
  18. // $where[] = array('st_lq_local_league.source', '=', $source->infocontent);
  19. // }
  20. //
  21. // if (is_array ($where) && count ($where) > 0) {
  22. // $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.id')
  23. // ->join('st_lq_local_match','st_lq_competition.id','=','st_lq_local_match.match_id')
  24. // ->join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')
  25. // ->select('st_lq_competition.id','st_lq_local_match.match_id','st_lq_local_league.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
  26. // ->orderby('st_lq_competition.match_date','desc')
  27. // ->orderby('st_lq_competition.match_time','desc')
  28. // ->where($where)
  29. // ->orwhere($orwhere)
  30. // ->paginate ($list);
  31. // } else {
  32. // $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.id')
  33. // ->join('st_lq_local_match','st_lq_competition.id','=','st_lq_local_match.match_id')
  34. // ->join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')
  35. // ->select('st_lq_competition.id','st_lq_local_match.match_id','st_lq_local_league.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
  36. // ->orderby('st_lq_competition.match_date','desc')
  37. // ->orderby('st_lq_competition.match_time','desc')
  38. // ->paginate ($list);
  39. // }
  40. if (is_array ($where) && count ($where) > 0) {
  41. $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.lg_id')
  42. ->select('st_lq_competition.id','st_lq_competition.match_id','st_lq_competition.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
  43. ->orderby('st_lq_competition.match_date','desc')
  44. ->orderby('st_lq_competition.match_time','desc')
  45. ->where($where)
  46. ->orwhere($orwhere)
  47. ->paginate ($list);
  48. } else {
  49. $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.lg_id')
  50. ->select('st_lq_competition.id','st_lq_competition.match_id','st_lq_competition.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
  51. ->orderby('st_lq_competition.match_date','desc')
  52. ->orderby('st_lq_competition.match_time','desc')
  53. ->paginate ($list);
  54. }
  55. if (!$data < 0) {
  56. return -2021052003; //
  57. }
  58. //赛事结果处理状态查询
  59. $result = \App\Models\Comendnotice::where('game_code','lq')->get();
  60. for($i=0;$i<count($data);$i++){
  61. if($data[$i]->match_date == '' && $data[$i]->last_time != ''){
  62. $datetime = explode(' ',$data[$i]->last_time);
  63. $data[$i]->match_date = $datetime[0];
  64. $data[$i]->match_time = $datetime[1];
  65. }
  66. if($data[$i]->status==0){
  67. $data[$i]->status = '未开始';
  68. }else if($data[$i]->status==1){
  69. $data[$i]->status = '正在进行';
  70. }else if($data[$i]->status==2){
  71. $data[$i]->status = '已结束';
  72. }
  73. if($data[$i]->guest_team == ''){
  74. $data[$i]->home_guest = $data[$i]->home_team;
  75. }else{
  76. $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
  77. }
  78. //赛事结果状态
  79. if(!empty($result)){
  80. for($j=0;$j<count($result);$j++){
  81. if($data[$i]->match_id == $result[$j]->match_id){
  82. $data[$i]->result_status = $result[$j]->status;
  83. }else{
  84. $data[$i]->result_status = null;
  85. }
  86. }
  87. }else{
  88. $data[$i]->result_status = null;
  89. }
  90. if($data[$i]->result_status != null){
  91. if($data[$i]->result_status == '0'){
  92. $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>';
  93. }else{
  94. $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>';
  95. }
  96. }else{
  97. $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>';
  98. }
  99. }
  100. return $data->toArray();
  101. }
  102. //更新设置
  103. function updateInfos($data,$id){
  104. $res=$this->where('id',$id)->update($data);
  105. if(!$res) {
  106. return -7020050022;//更新失败
  107. }
  108. return 1;
  109. }
  110. function getmatchid($id){
  111. $res=$this->where('id',$id)->first();
  112. if(!$res){
  113. return -2021052003;
  114. }
  115. return $res->match_id;
  116. }
  117. //篮球赛事联赛查询
  118. function allcompetition($lg_id){
  119. $data = $this->where('lg_id',$lg_id)->select('lg_id','home_team')->get();
  120. if (!$data) {
  121. return -5040000102; //无相关信息
  122. }
  123. return $data->toArray();
  124. }
  125. }