SoccerLeague.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. use App\Lib\Biz\Sport\Common as commonFunction;
  11. class SoccerLeague extends BaseModel {
  12. protected $table = "st_zq_league";
  13. public $timestamps = false;
  14. function getinfo($list = 10, $page, $where = '')
  15. {
  16. // $source = \App\Models\Setinfo::where('id','1000')->first();
  17. // if($source->infocontent != '混合数据'){
  18. // $where[] = array('st_zq_local_league.source', '=', $source->infocontent);
  19. // }
  20. if (is_array ($where) && count ($where) > 0){
  21. $data = $this
  22. //->join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')
  23. ->select('st_zq_league.id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.status','st_zq_league.utime')
  24. ->orderby('st_zq_league.utime','desc')
  25. ->where($where)
  26. //->distinct('st_zq_league.id')
  27. ->paginate ($list);
  28. }else{
  29. $data = $this
  30. ->select('st_zq_league.id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.status','st_zq_league.utime')
  31. ->orderby('st_zq_league.utime','desc')
  32. //->distinct('st_zq_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('id','name_chinese')->get();
  87. if (!$data) {
  88. return -5040000102; //无相关信息
  89. }
  90. return $data->toArray();
  91. }
  92. //赛事信息
  93. function onlyleague($lg_id){
  94. $data=$this->where('lg_id',$lg_id)->first();
  95. if (!$data) {
  96. return -5040000102; //无相关信息
  97. }
  98. return $data->toArray();
  99. }
  100. //测试冠军联赛数据
  101. function get_league_gj_info($list = 10, $page, $where = '')
  102. {
  103. if (is_array ($where) && count ($where) > 0){
  104. $data = $this
  105. ->join('st_zq_odds','st_zq_odds.lg_id','=','st_zq_league.id')
  106. ->select('st_zq_league.id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.status','st_zq_league.utime')
  107. ->orderby('st_zq_league.utime','desc')
  108. ->where($where)
  109. ->distinct('st_zq_league.name_chinese')
  110. ->paginate ($list);
  111. }else{
  112. $data = $this
  113. ->join('st_zq_odds','st_zq_odds.lg_id','=','st_zq_league.id')
  114. ->select('st_zq_league.id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.status','st_zq_league.utime')
  115. ->where('st_zq_odds.type',1)
  116. ->distinct('st_zq_league.name_chinese')
  117. ->orderby('st_zq_league.utime','desc')
  118. ->paginate ($list);
  119. }
  120. if (!$data) {
  121. return -5040000102; //无相关信息
  122. }
  123. //地区
  124. $area = \App\Models\StAreaCountry::where('pid','0')->get();
  125. //国家
  126. $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
  127. for($i=0;$i<count($data);$i++){
  128. //$data[$i]->id = $data[$i]->lg_id;
  129. if($data[$i]->status == '-1'){
  130. $data[$i]->league_status = '未启用';
  131. }
  132. if($data[$i]->status == '1'){
  133. $data[$i]->league_status = '启用';
  134. }
  135. $str = 0;
  136. $str1 = 0;
  137. if($data[$i]->area_id == '0'){
  138. $data[$i]->area = '无';
  139. }else{
  140. for($b=0;$b<count($area);$b++){
  141. if($area[$b]->id == $data[$i]->area_id){
  142. $str = 1;
  143. $data[$i]->area = $area[$b]->name;
  144. }
  145. }
  146. if($str == 0){$data[$i]->area = '无';}
  147. }
  148. if($data[$i]->country_id == 0){
  149. $data[$i]->country = '无';
  150. }else{
  151. for($c=0;$c<count($country);$c++){
  152. if($country[$c]->id == $data[$i]->country_id){
  153. $str1 = 1;
  154. $data[$i]->country = $country[$c]->name;
  155. }
  156. }
  157. if($str1 == 0){$data[$i]->country = '无';}
  158. }
  159. }
  160. return $data->toArray();
  161. }
  162. }