彭俊 пре 6 година
родитељ
комит
7565359df7

+ 131 - 3
Application/Api/Controller/Betorder.php

@@ -154,6 +154,11 @@ class Betorder extends BaseController{
                 //计算每个投注玩法下的可赢金额
                 $prize_money += $this->commonFunction->getEarnMoney($game_code,$vv['p_code'],$vv['odds'],$vv['bet_amount'],1);
                 // $prize_money +=  $vv['odds']* $vv['bet_amount'];
+                //是否是滚球投注
+                $is_rolling = 0;
+                if($vv['match_type']=='StRollBall'){
+                    $is_rolling = 1;
+                }
                 $matchData =[
                     'odds_id' =>$vv['id'],
                     'home_team' => $vv['home_team'],
@@ -170,7 +175,8 @@ class Betorder extends BaseController{
                     'bet_type' => 1,
                     'bet_money' => $vv['bet_amount'],
                     'ctime' => $this->time,
-                    'utime' => $this->time
+                    'utime' => $this->time,
+                    'is_rolling' =>$is_rolling,
                 ];
                 //插入数据源
                 $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
@@ -205,6 +211,120 @@ class Betorder extends BaseController{
     }
 
     public function Bet(){
+        /* 模拟单式数据
+        $get_data = [
+            'data'=>[
+                [
+                    'type'=>1,
+                    'index'=>0,
+                    'bet_amount'=>1,
+                ],
+                [
+                    [
+                        'id'=>226063,
+                        'home_team'=>'内蒙古草上飞',
+                        'guest_team'=>'吉林百嘉',
+                        'name'=>'内蒙古草上飞',
+                        'odds'=>0.81,
+                        'match_id'=>1249,
+                        'condition'=>'0.5/1',
+                        'ballId'=>'zq',
+                        'odds_code'=>'concede_home',
+                        'p_code'=>'concede',
+                        'play_name'=>'让球',
+                        'score'=>0,
+                        'bettingTime'=>date('Y-m-d H:i:s',time()),
+                        'odds_only'=>'272af2647b112b7eb337a2ed16753c6f',
+                        'lg_id'=>29,
+                        'repeat'=>'false',
+                        'match_type'=>'StRollBall',//滚球投注
+                    ],
+                ]
+            ],
+            
+            'token'=>'Zowv7715649767885d47a6945b98f',
+            'bet_money'=>1
+
+        ];
+        */
+        /*  模拟串式数据
+         $get_data = [
+            'data'=>[
+                [
+                    'type'=>1,
+                    'index'=>0,
+                    'bet_amount'=>1,
+                ],
+                [
+                    'type'=>'3串1',
+                    'bet_amount' =>1,
+                ],
+                [
+                    [
+                        'id'=>229351,
+                        'home_team'=>'布琳狮子U20',
+                        'guest_team'=>'圣奥尔本斯U20',
+                        'name'=>'圣奥尔本斯U20',
+                        'odds'=>1.01,
+                        'match_id'=>1273,
+                        'condition'=>'4/4.5',
+                        'ballId'=>'zq',
+                        'odds_code'=>'goal_size_big',
+                        'p_code'=>'goal_size',
+                        'play_name'=>'大小',
+                        'score'=>0,
+                        'bettingTime'=>date('Y-m-d H:i:s',time()),
+                        'odds_only'=>'908f8bae2233a0384c96c7b1f42e9ea7',
+                        'lg_id'=>153,
+                        'repeat'=>'false',
+                        'match_type'=>'StRollBall',//滚球投注
+                    ],
+                    [
+                        'id'=>238940,
+                        'home_team'=>'格罗兹尼艾哈迈德U20',
+                        'guest_team'=>'奥伦堡U20',
+                        'name'=>'格罗兹尼艾哈迈德U20',
+                        'odds'=>0.94,
+                        'match_id'=>1247,
+                        'condition'=>'1/1.5',
+                        'ballId'=>'zq',
+                        'odds_code'=>'concede_home',
+                        'p_code'=>'concede',
+                        'play_name'=>'让球',
+                        'score'=>0,
+                        'bettingTime'=>date('Y-m-d H:i:s',time()),
+                        'odds_only'=>'9125bf40d6649fcdb663c43d8f55bebd',
+                        'lg_id'=>20,
+                        'repeat'=>'false',
+                        'match_type'=>'StRollBall',//滚球投注
+                    ],
+                    [
+                        'id'=>238958,
+                        'home_team'=>'巴扬卡拉',
+                        'guest_team'=>'马都拉联',
+                        'name'=>'巴扬卡拉',
+                        'odds'=>1.13,
+                        'match_id'=>1254,
+                        'condition'=>'0.5',
+                        'ballId'=>'zq',
+                        'odds_code'=>'concede_home',
+                        'p_code'=>'concede',
+                        'play_name'=>'让球',
+                        'score'=>0,
+                        'bettingTime'=>date('Y-m-d H:i:s',time()),
+                        'odds_only'=>'3cf81ac0b9765218845fe8bc4de0ad99',
+                        'lg_id'=>61,
+                        'repeat'=>'false',
+                        'match_type'=>'StRollBall',//滚球投注
+                    ],
+                ]
+            ],
+            
+            'token'=>'Zowv7715649767885d47a6945b98f',
+            'bet_money'=>2
+
+        ];
+        */
 
         //如果获取不到data,则为游戏端提交,需转成数组
         if(!empty($_POST['game_data'])){
@@ -238,6 +358,7 @@ class Betorder extends BaseController{
                 $this->Simplex_bet($data['single'],$userInfo,$batch_id);//单式数据处理
             }
             if(!empty($data['bunch'])){
+
                 $data_all = $data['bunch'][count($data['bunch'])-1];//获取最后一个数组
                 unset($data['bunch'][count($data['bunch'])-1]);//删除最后一个元素
                 $this->stringBet($data['bunch'],$data_all,$userInfo,$batch_id);
@@ -458,6 +579,12 @@ class Betorder extends BaseController{
             $getModels = $this->commonFunction->getModels($vv['ballId']);
             $model_match = $getModels['model_match'];
 
+            //获取是否是滚球投注
+            $is_rolling = 0;
+
+            if($vv['match_type'] == 'StRollBall'){
+                $is_rolling = 1;
+            }
             $matchData[] = [
                 'batch_id'=>$batch_id,
                 'odds_id'=>$vv['id'],
@@ -471,10 +598,11 @@ class Betorder extends BaseController{
                 'status'=>0,
                 'match_id'=>$vv['match_id'],
                 'game_code'=>$vv['ballId'],
-                'lg_id'=> $vv['lg_id'],//lm($model_match,"Sports")->select('lg_id')->where('match_id',$vv['match_id'])->first()->lg_id,
+                'lg_id'=> $vv['lg_id'],
                 'ctime'=>$this->time,//写入时间
                 'utime' => $this->time,
-                'bet_type'=>2
+                'bet_type'=>2,
+                'is_rolling'=>$is_rolling,
             ];
         }
         //写赔率数据表

+ 106 - 0
Application/Sports/Controller/RollingBall.php

@@ -8,6 +8,7 @@
 namespace App\Sports\Controller;
 
 use BaseController\Controller;
+use App\Sports\Model\St_zq_competition as matchModel;
 use \System\Model;
 
 class RollingBall extends Controller{
@@ -22,6 +23,33 @@ class RollingBall extends Controller{
     public function zqrollingball(){
         $models = $this->commonFunction->getModels('zq',1);
 
+        $model_match = $models['model_match'];
+
+        //获取 滚球查询条件
+        $where = $this->commonFunction->getState('StRollBall',$model_match);
+
+        //统计联赛下的赛事及查询赛事
+        $ret['game_code'] = 'zq';
+        $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
+
+        //如果赛事为空,直接返回
+        if(empty($matchData)) return $matchData;
+
+        //===获取当前赛事是否有赔率,如果没有则去除===
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
+
+        $data = [
+            'game_code'=>'zq',
+            'gameName'=>'足球',
+            'matchData'=>$matchData_new
+        ];
+
+        return $data;
+
+    }
+    public function __zqrollingball(){
+        $models = $this->commonFunction->getModels('zq',1);
+
         $model_result = $models['model_result'];
         $model_match = $models['model_match'];
         $model_league = $models['model_league'];
@@ -65,6 +93,32 @@ class RollingBall extends Controller{
     public function lqrollingball(){
         $models = $this->commonFunction->getModels('lq',1);
 
+        $model_match = $models['model_match'];
+
+        //获取 滚球查询条件
+        $where = $this->commonFunction->getState('StRollBall',$model_match);
+
+        //统计联赛下的赛事及查询赛事
+        $ret['game_code'] = 'lq';
+        $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
+
+        //如果赛事为空,直接返回
+        if(empty($matchData)) return $matchData;
+
+        //===获取当前赛事是否有赔率,如果没有则去除===
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
+
+        $data = [
+            'game_code'=>'lq',
+            'gameName'=>'篮球',
+            'matchData'=>$matchData_new
+        ];
+
+        return $data;
+    }
+    public function __lqrollingball(){
+        $models = $this->commonFunction->getModels('lq',1);
+
         $model_result = $models['model_result'];
         $model_match = $models['model_match'];
         $model_league = $models['model_league'];
@@ -101,6 +155,32 @@ class RollingBall extends Controller{
     public function wqrollingball(){
         $models = $this->commonFunction->getModels('wq',1);
 
+        $model_match = $models['model_match'];
+
+        //获取 滚球查询条件
+        $where = $this->commonFunction->getState('StRollBall',$model_match);
+
+        //统计联赛下的赛事及查询赛事
+        $ret['game_code'] = 'wq';
+        $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
+
+        //如果赛事为空,直接返回
+        if(empty($matchData)) return $matchData;
+
+        //===获取当前赛事是否有赔率,如果没有则去除===
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
+
+        $data = [
+            'game_code'=>'wq',
+            'gameName'=>'网球',
+            'matchData'=>$matchData_new
+        ];
+
+        return $data;
+    }
+    public function __wqrollingball(){
+        $models = $this->commonFunction->getModels('wq',1);
+
         $model_result = $models['model_result'];
         $model_match = $models['model_match'];
         $model_league = $models['model_league'];
@@ -137,6 +217,32 @@ class RollingBall extends Controller{
     public function bqrollingball(){
         $models = $this->commonFunction->getModels('bq',1);
 
+        $model_match = $models['model_match'];
+
+        //获取 滚球查询条件
+        $where = $this->commonFunction->getState('StRollBall',$model_match);
+
+        //统计联赛下的赛事及查询赛事
+        $ret['game_code'] = 'bq';
+        $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
+
+        //如果赛事为空,直接返回
+        if(empty($matchData)) return $matchData;
+
+        //===获取当前赛事是否有赔率,如果没有则去除===
+        $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
+
+        $data = [
+            'game_code'=>'bq',
+            'gameName'=>'棒球',
+            'matchData'=>$matchData_new
+        ];
+
+        return $data;
+    }
+    public function __bqrollingball(){
+        $models = $this->commonFunction->getModels('bq',1);
+
         $model_result = $models['model_result'];
         $model_match = $models['model_match'];
         $model_league = $models['model_league'];

+ 80 - 20
Application/Sports/Model/St_zq_competition.php

@@ -40,12 +40,22 @@ class St_zq_competition extends Model
         $select = [$model_match.'.lg_id',$model_match.'.id as match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team'];
 
         //获取赛事数据
-        $matchData = lm($model_match,"Sports")
+        if(!empty($lg_ids)){
+            $matchData = lm($model_match,"Sports")
             ->select($select)
             ->whereIn($model_match.'.lg_id',$lg_ids)
             ->where($where)
             ->get()
             ->toarray();
+        }else{
+            $matchData = lm($model_match,"Sports")
+            ->select($select)
+            ->where($where)
+            ->get()
+            ->toarray();
+        }
+        
+        if(empty($matchData)) return $matchData;
 
         $match_ids = [];
         foreach ($matchData as $k=>$v){
@@ -65,26 +75,27 @@ class St_zq_competition extends Model
 //             (select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
 //             where a.match_id = b.match_id and a.id = b.id ";
 //         }
- //如果是网球
- if($game_code == 'wq'){
-    $sql = "select a.match_id,a.home_player_score,a.guest_player_score,a.match_time as a_time,a.match_process,a.result_mark from $result_record a,
-(select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
-where a.match_id = b.match_id and a.id = b.id ";
-}else
-//如果是棒球
-if($game_code == 'bq'){
-    $sql = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.result_mark from $result_record a,
-(select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
-where a.match_id = b.match_id and a.id = b.id ";
-}else{
-    //其他球类
-    $sql = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process from $result_record a,
-(select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
-where a.match_id = b.match_id and a.id = b.id ";
-}
+        //如果是网球
+        if($game_code == 'wq'){
+            $sql = "select a.match_id,a.home_player_score,a.guest_player_score,a.match_time as a_time,a.match_process,a.result_mark from $result_record a,
+        (select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
+        where a.match_id = b.match_id and a.id = b.id ";
+        }else
+        //如果是棒球
+        if($game_code == 'bq'){
+            $sql = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.result_mark from $result_record a,
+        (select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
+        where a.match_id = b.match_id and a.id = b.id ";
+        }else{
+            //其他球类
+            $sql = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process from $result_record a,
+        (select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
+        where a.match_id = b.match_id and a.id = b.id ";
+        }
         $match_result_record = S ('DB')->select ($sql);
 
         //处理赛事数据,追加比分及进程
+        /*
         if(!empty($matchData)){
             foreach ($matchData as $k=>$v){
                 if( !empty($match_result_record)){
@@ -115,10 +126,59 @@ where a.match_id = b.match_id and a.id = b.id ";
                     $matchData[$k]['a_time'] = C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
                     $matchData[$k]['match_process'] = C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
                 }
-                
             }
         }
-        
+        */
+
+        if(!empty($matchData)){
+            foreach ($matchData as $k=>$v){
+                if( !empty($match_result_record)){
+                    foreach ($match_result_record as $kk => $vv){
+                        if($v['match_id'] == $vv->match_id){
+                            //如果是网球
+                            if($model_result == 'st_wq_result'){
+                                $matchData[$k]['home_player_score'] = $vv->home_player_score?:0;
+                                $matchData[$k]['guest_player_score'] = $vv->guest_player_score?:0;
+                            }else{
+                                $matchData[$k]['home_score'] = $vv->home_score?:0;
+                                $matchData[$k]['guest_score'] = $vv->guest_score?:0;
+                            }
+                            $matchData[$k]['a_time'] = $vv->a_time?:C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
+                            $matchData[$k]['match_process'] = $vv->match_process?:C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
+                        }
+                    }
+                }
+                else{
+                     //如果是网球
+                     if($model_result == 'st_wq_result'){
+                        $matchData[$k]['home_player_score'] = 0;
+                        $matchData[$k]['guest_player_score'] = 0;
+                    }else{
+                        $matchData[$k]['home_score'] = 0;
+                        $matchData[$k]['guest_score'] = 0;
+                    }
+                    $matchData[$k]['a_time'] = C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
+                    $matchData[$k]['match_process'] = C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
+                }
+            }
+
+            //追加当赛事数量为N ,赛事结果记录< N时的处理
+            foreach($matchData as $k=>$v){
+                if(count($v) < 10){
+                    //如果是网球
+                    if($model_result == 'st_wq_result'){
+                        $matchData[$k]['home_player_score'] = 0;
+                        $matchData[$k]['guest_player_score'] = 0;
+                    }else{
+                        $matchData[$k]['home_score'] = 0;
+                        $matchData[$k]['guest_score'] = 0;
+                    }
+                    $matchData[$k]['a_time'] = C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
+                    $matchData[$k]['match_process'] = C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
+                }
+            }
+        }
+
         return $matchData;
     }