| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Jonlin
- * Date: 2019/4/1
- * Time: 10:12
- */
- namespace App\Models;
- use Illuminate\Support\Facades\DB;
- class BaseOdds extends BaseModel
- {
- protected $table = "st_bq_odds";
- public $timestamps = false;
- function getodds($match_id,$where = ''){
- //$data=$this->where($where)->where('expire_time','<',date('Y-m-d H:i:s',time()))->get();
- $data=$this->where('match_id',$match_id)->where($where)->get()->toArray();
- $num=$this->where('match_id',$match_id)->where('sort',0)->get()->toArray();
- $sort = array_column($data,'sort');
- array_multisort($sort,SORT_DESC,$data);
- $data = array_slice($data,0,count($num));
- if(!$data < 0){
- return -2021052003;
- }
- for($i=0;$i<count($data);$i++){
- if($data[$i]['status']==0){
- $data[$i]['status'] = '启用';
- }else if($data[$i]['status']==1){
- $data[$i]['status'] = '停用';
- }else if($data[$i]['status']==-1){
- $data[$i]['status'] = '禁用';
- }
- $odds_name = \App\Models\Matchcode::where('odds_code',$data[$i]['odds_code'])->first();
- if(!empty($odds_name)){
- $data[$i]['odds_code_cn'] = $odds_name->odds_name;
- }else{
- $data[$i]['odds_code_cn'] = $data[$i]['odds_code'];
- }
- $p_name = \App\Models\Matchcode::where('odds_code',$data[$i]['p_code'])->first();
- if(!empty($p_name)){
- $data[$i]['p_code_cn'] = $p_name->odds_name;
- }else{
- $data[$i]['p_code_cn'] = $data[$i]['p_code'];
- }
- }
- return $data;
- }
- }
|