TennisLeague.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/3/29
  6. * Time: 9:27
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. class TennisLeague extends BaseModel {
  11. protected $table = "st_wq_league";
  12. public $timestamps = false;
  13. function getinfo($list = 10, $page, $where = '')
  14. {
  15. $source = \App\Models\Setinfo::where('id','1000')->first();
  16. if($source->infocontent != '混合数据'){
  17. $where[] = array('st_wq_local_league.source', '=', $source->infocontent);
  18. }
  19. if (is_array ($where) && count ($where) > 0){
  20. $data = $this
  21. ->join('st_wq_local_league','st_wq_league.id','=','st_wq_local_league.lg_id')
  22. ->select('st_wq_league.id','st_wq_league.name_chinese','st_wq_league.area_id','st_wq_league.country_id','st_wq_league.status','st_wq_league.utime')
  23. ->orderby('st_wq_league.utime','desc')
  24. ->where($where)
  25. //->distinct('st_wq_league.id')
  26. ->paginate ($list);
  27. }else{
  28. $data = $this
  29. ->select('st_wq_league.id','st_wq_league.name_chinese','st_wq_league.area_id','st_wq_league.country_id','st_wq_league.status','st_wq_league.utime')
  30. ->orderby('st_wq_league.utime','desc')
  31. ->orderby('utime','desc')
  32. //->distinct('st_wq_league.id')
  33. ->paginate ($list);
  34. }
  35. if (!$data) {
  36. return -5040000102; //无相关信息
  37. }
  38. //地区
  39. $area = \App\Models\StAreaCountry::where('pid','0')->get();
  40. // $str = '';
  41. // for($a=0;$a<count($area);$a++){
  42. // $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
  43. // }
  44. //国家
  45. $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
  46. for($i=0;$i<count($data);$i++){
  47. //$data[$i]->id = $data[$i]->lg_id;
  48. if($data[$i]->status == '-1'){
  49. $data[$i]->league_status = '未启用';
  50. }
  51. if($data[$i]->status == '1'){
  52. $data[$i]->league_status = '启用';
  53. }
  54. // $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
  55. // $data[$i]->country = '<select name="country" id="country"></select>';
  56. $str = 0;
  57. $str1 = 0;
  58. if($data[$i]->area_id == '0'){
  59. $data[$i]->area = '无';
  60. }else{
  61. for($b=0;$b<count($area);$b++){
  62. if($area[$b]->id == $data[$i]->area_id){
  63. $str = 1;
  64. $data[$i]->area = $area[$b]->name;
  65. }
  66. }
  67. if($str == 0){$data[$i]->area = '无';}
  68. }
  69. if($data[$i]->country_id == 0){
  70. $data[$i]->country = '无';
  71. }else{
  72. for($c=0;$c<count($country);$c++){
  73. if($country[$c]->id == $data[$i]->country_id){
  74. $str1 = 1;
  75. $data[$i]->country = $country[$c]->name;
  76. }
  77. }
  78. if($str1 == 0){$data[$i]->country = '无';}
  79. }
  80. }
  81. return $data->toArray();
  82. }
  83. //所有赛事id
  84. function allleague()
  85. {
  86. $data = $this->select('lg_id','name_chinese')->get();
  87. if (!$data) {
  88. return -5040000102; //无相关信息
  89. }
  90. return $data->toArray();
  91. }
  92. //测试冠军联赛数据
  93. function get_league_gj_info($list = 10, $page, $where = '')
  94. {
  95. if (is_array ($where) && count ($where) > 0){
  96. $data = $this
  97. ->join('st_wq_odds','st_wq_odds.lg_id','=','st_wq_league.id')
  98. ->select('st_wq_league.id','st_wq_league.name_chinese','st_wq_league.area_id','st_wq_league.country_id','st_wq_league.status','st_wq_league.utime')
  99. ->orderby('st_wq_league.utime','desc')
  100. ->where($where)
  101. ->distinct('st_wq_league.name_chinese')
  102. ->paginate ($list);
  103. }else{
  104. $data = $this
  105. ->join('st_wq_odds','st_wq_odds.lg_id','=','st_wq_league.id')
  106. ->select('st_wq_league.id','st_wq_league.name_chinese','st_wq_league.area_id','st_wq_league.country_id','st_wq_league.status','st_wq_league.utime')
  107. ->where('st_wq_odds.type',1)
  108. ->distinct('st_wq_league.name_chinese')
  109. ->orderby('st_wq_league.utime','desc')
  110. ->paginate ($list);
  111. }
  112. if (!$data) {
  113. return -5040000102; //无相关信息
  114. }
  115. //地区
  116. $area = \App\Models\StAreaCountry::where('pid','0')->get();
  117. //国家
  118. $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
  119. for($i=0;$i<count($data);$i++){
  120. //$data[$i]->id = $data[$i]->lg_id;
  121. if($data[$i]->status == '-1'){
  122. $data[$i]->league_status = '未启用';
  123. }
  124. if($data[$i]->status == '1'){
  125. $data[$i]->league_status = '启用';
  126. }
  127. $str = 0;
  128. $str1 = 0;
  129. if($data[$i]->area_id == '0'){
  130. $data[$i]->area = '无';
  131. }else{
  132. for($b=0;$b<count($area);$b++){
  133. if($area[$b]->id == $data[$i]->area_id){
  134. $str = 1;
  135. $data[$i]->area = $area[$b]->name;
  136. }
  137. }
  138. if($str == 0){$data[$i]->area = '无';}
  139. }
  140. if($data[$i]->country_id == 0){
  141. $data[$i]->country = '无';
  142. }else{
  143. for($c=0;$c<count($country);$c++){
  144. if($country[$c]->id == $data[$i]->country_id){
  145. $str1 = 1;
  146. $data[$i]->country = $country[$c]->name;
  147. }
  148. }
  149. if($str1 == 0){$data[$i]->country = '无';}
  150. }
  151. }
  152. return $data->toArray();
  153. }
  154. }