BaseOdds.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/4/1
  6. * Time: 10:12
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. class BaseOdds extends BaseModel
  11. {
  12. protected $table = "st_bq_odds";
  13. public $timestamps = false;
  14. function getodds($match_id,$where = ''){
  15. //$data=$this->where($where)->where('expire_time','<',date('Y-m-d H:i:s',time()))->get();
  16. $data=$this->where('match_id',$match_id)->where($where)->get()->toArray();
  17. $num=$this->where('match_id',$match_id)->where('sort',0)->get()->toArray();
  18. $sort = array_column($data,'sort');
  19. array_multisort($sort,SORT_DESC,$data);
  20. $data = array_slice($data,0,count($num));
  21. if(!$data < 0){
  22. return -2021052003;
  23. }
  24. for($i=0;$i<count($data);$i++){
  25. if($data[$i]['status']==0){
  26. $data[$i]['status'] = '启用';
  27. }else if($data[$i]['status']==1){
  28. $data[$i]['status'] = '停用';
  29. }else if($data[$i]['status']==-1){
  30. $data[$i]['status'] = '禁用';
  31. }
  32. $odds_name = \App\Models\Matchcode::where('odds_code',$data[$i]['odds_code'])->first();
  33. if(!empty($odds_name)){
  34. $data[$i]['odds_code_cn'] = $odds_name->odds_name;
  35. }else{
  36. $data[$i]['odds_code_cn'] = $data[$i]['odds_code'];
  37. }
  38. $p_name = \App\Models\Matchcode::where('odds_code',$data[$i]['p_code'])->first();
  39. if(!empty($p_name)){
  40. $data[$i]['p_code_cn'] = $p_name->odds_name;
  41. }else{
  42. $data[$i]['p_code_cn'] = $data[$i]['p_code'];
  43. }
  44. }
  45. return $data;
  46. }
  47. }