Stbqresult.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jimy
  5. * Date: 2019/4/18
  6. * Time: 13:59
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. class Stbqresult extends BaseModel {
  11. protected $table = "st_bq_result";
  12. public $timestamps = false;
  13. function getinfo($list = 10, $page, $where = '',$orwhere = '',$if_order)
  14. {
  15. $match_ids = \App\Models\MoneyBuyMatch::select('match_id')->where('game_code','bq')->get()->toArray();
  16. $match_ids = array_column($match_ids,'match_id');
  17. //去重
  18. $match_ids = array_unique($match_ids);
  19. if($if_order == 1){
  20. if (is_array ($where) && count ($where) > 0) {
  21. $data = $this->join('st_bq_league','st_bq_result.lg_id','=','st_bq_league.id')->join('st_bq_competition','st_bq_competition.id','=','st_bq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_bq_result.guest_team','st_bq_result.home_rate','st_bq_result.guest_rate','st_bq_result.first_score','st_bq_competition.status','st_bq_result.last_score','st_bq_result.match_score','st_bq_result.match_winer','st_bq_result.update_time','st_bq_competition.match_time','st_bq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score',$this->table.'.start_time',$this->table.'.manual_result','st_bq_league.name_chinese as saisname')->orderby('st_bq_result.id','desc')->where($where)->wherein('st_bq_competition.id',$match_ids)->paginate ($list);
  22. } else {
  23. $data = $this->join('st_bq_league','st_bq_result.lg_id','=','st_bq_league.id')->join('st_bq_competition','st_bq_competition.id','=','st_bq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_bq_result.guest_team','st_bq_result.home_rate','st_bq_result.guest_rate','st_bq_result.first_score','st_bq_competition.status','st_bq_result.last_score','st_bq_result.match_score','st_bq_result.match_winer','st_bq_result.update_time','st_bq_competition.match_time','st_bq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score',$this->table.'.start_time',$this->table.'.manual_result','st_bq_league.name_chinese as saisname')->orderby('st_bq_result.id','desc')->wherein('st_bq_competition.id',$match_ids)->paginate ($list);
  24. }
  25. }else{
  26. if (is_array ($where) && count ($where) > 0) {
  27. $data = $this->join('st_bq_league','st_bq_result.lg_id','=','st_bq_league.id')->join('st_bq_competition','st_bq_competition.id','=','st_bq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_bq_result.guest_team','st_bq_result.home_rate','st_bq_result.guest_rate','st_bq_result.first_score','st_bq_competition.status','st_bq_result.last_score','st_bq_result.match_score','st_bq_result.match_winer','st_bq_result.update_time','st_bq_competition.match_time','st_bq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score',$this->table.'.start_time',$this->table.'.manual_result','st_bq_league.name_chinese as saisname')->orderby('st_bq_result.id','desc')->where($where)->paginate ($list);
  28. } else {
  29. $data = $this->join('st_bq_league','st_bq_result.lg_id','=','st_bq_league.id')->join('st_bq_competition','st_bq_competition.id','=','st_bq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_bq_result.guest_team','st_bq_result.home_rate','st_bq_result.guest_rate','st_bq_result.first_score','st_bq_competition.status','st_bq_result.last_score','st_bq_result.match_score','st_bq_result.match_winer','st_bq_result.update_time','st_bq_competition.match_time','st_bq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score',$this->table.'.start_time',$this->table.'.manual_result','st_bq_league.name_chinese as saisname')->orderby('st_bq_result.id','desc')->paginate ($list);
  30. }
  31. }
  32. $newsim = new \App\Models\SportsNoteList();
  33. $simplex = $newsim->getsim('bq');
  34. $newstr = new \App\Models\MoneyBuyStr();
  35. $str = $newstr->strmatchs('bq');
  36. //print_r($str);exit;
  37. for ($i=0; $i < count($data); $i++) {
  38. $data[$i]->numsim = 0;
  39. for ($j=0; $j < count($simplex); $j++) {
  40. if($simplex[$j]['match_id'] == $data[$i]->match_id){
  41. $data[$i]->numsim = $data[$i]->numsim+1;
  42. }
  43. }
  44. $data[$i]->numstr = 0;
  45. for ($a=0; $a < count($str); $a++) {
  46. if(in_array($data[$i]->match_id,$str[$a]['match_ids'])){
  47. $data[$i]->numstr = $data[$i]->numstr+1;
  48. }
  49. }
  50. $data[$i]->manual_result = json_decode($data[$i]->manual_result,true);
  51. }
  52. return $data->toArray ();
  53. }
  54. //查询赛事
  55. function matchjg($match_id){
  56. $data = $this->where('match_id',$match_id)->select('id','home_team','guest_team')->first();
  57. if (!$data) {
  58. return -5040000102; //无相关信息
  59. }
  60. return $data->toArray();
  61. }
  62. //更新状态
  63. function updatestatus($field,$where,$data){
  64. $res=$this->where($field,$where)->update($data);
  65. if(!$res) {
  66. return -7020050022;//更新失败
  67. }
  68. return 1;
  69. }
  70. //更新
  71. function updateInfo($data, $match_id)
  72. {
  73. $res = $this->where ('match_id', $match_id)->update ($data);
  74. if (!$res) {
  75. return -7010101202; //更新失败
  76. }
  77. return 1;
  78. }
  79. }