彭俊 hace 6 años
padre
commit
57b99c1787

+ 7 - 15
app/Http/Controllers/Admin/SportsbqController.php

@@ -30,7 +30,7 @@ class SportsbqController extends Controller {
         $dt->addColsFields('guest_team', array('templet' => '#guest_team', 'sort' => false, 'width' => 80));
         $dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 80));
         $dt->addColsFields('csnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
-        $dt->addColsFields('match_score', array('templet' => '#match_score', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('match_score', array('templet' => '#match_score', 'sort' => false, 'width' => 220));
         $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 80));
         $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
 		return view('admin.Sportsbq/outcome', $dt->render($request));
@@ -207,21 +207,13 @@ class SportsbqController extends Controller {
 		$match_id = $req->match_id;
 		$newapp = new \App\Models\Stbqresult();
 
-		// $data = array();
 		// $data['update_time'] = data('Y-m-d H:i:s');//更新时间
-		if($only==1){
-			$data['u_home_score'] = $num;
-			$res = $newapp->updateInfo($data,$match_id);//联赛id
-		}else if($only==2){
-			$data['u_guest_score'] = $num;
-			$res = $newapp->updateInfo($data,$match_id);//联赛id
-		}else if($only==3){
-			$data['home_score'] = $num;
-			$res = $newapp->updateInfo($data,$match_id);//联赛id
-		}else{
-			$data['guest_score'] = $num;
-			$res = $newapp->updateInfo($data,$match_id);//联赛id
-		}
+		$data['u_home_score'] = intval($req->u_home_score)?intval($req->u_home_score):0;
+		$data['u_guest_score'] = intval($req->u_guest_score)?intval($req->u_guest_score):0;
+		$data['guest_score'] = intval($req->guest_score)?intval($req->guest_score):0;
+		$data['home_score'] = intval($req->home_score)?intval($req->home_score):0;
+		$res = $newapp->updateInfo($data,$match_id);//联赛id
+		
 		$addnew = new \App\Models\Comendnotice();
 		$addnew->addcomendnotice($match_id,'bq');
 

+ 3 - 11
app/Http/Controllers/Admin/SportswqController.php

@@ -37,7 +37,7 @@ class SportswqController extends Controller {
         $dt->addColsFields('guest_player_name', array('templet' => '#guest_team', 'sort' => false, 'width' => 130));
         $dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 80));
         $dt->addColsFields('csnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
-        $dt->addColsFields('match_score', array('templet' => '#matchscore', 'sort' => false, 'width' => 130));
+        $dt->addColsFields('match_score', array('templet' => '#matchscore', 'sort' => false, 'width' => 160));
         $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 80));
         $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
         return view('admin.Sportswq/outcome', $dt->render($request));
@@ -213,20 +213,12 @@ class SportswqController extends Controller {
 
 	//修改添加赛事比分
 	function updatascore(Req $req){
-		$only = $req->only;//节数唯一标识
 		$match_id = $req->match_id;//节数唯一标识
-		$home_player_score = intval($req->home_player_score);//主队比分
-		$guest_player_score = intval($req->guest_player_score);//客队比分
 
 		$model = \App\Models\Stwqresult::where('match_id', $match_id)->first();
 		$model->update_time = date('Y-m-d H:i:s');
-			
-		if($home_player_score){
-			$model->home_player_score = $home_player_score;
-		}
-		if($guest_player_score){
-			$model->guest_player_score = $guest_player_score;
-		}
+		$model->home_player_score = intval($req->home_player_score)?intval($req->home_player_score):0;//主队比分
+		$model->guest_player_score = intval($req->guest_player_score)?intval($req->guest_player_score):0;//客队比分
 		$model->save();
 
 		$addnew = new \App\Models\Comendnotice();

+ 175 - 1
app/Http/Model/StBqResult.php

@@ -3,6 +3,8 @@ namespace App\Http\Model;
 
 use Illuminate\Database\Eloquent\Model;
 use App\Http\Response\Response;
+use Illuminate\Support\Facades\DB;
+use App\Lib\Biz\Sport\Common as commonFunction;
 
 /**
  * Class StBqResult
@@ -16,8 +18,9 @@ class StBqResult extends Model
 
     /*
      * 写赛事结果
+     * 弃用
      */
-    public static function BQresult($model){
+    public static function BQresult__($model){
         //获取赛事表7天内所有赛事
         $matchData = $model['model_match']::select('id','home_team','guest_team','lg_id','status','tag','match_date','match_time')
             ->where([['ctime','>',date('Y-m-d H:i:s', strtotime("-7 day"))]])
@@ -89,6 +92,177 @@ class StBqResult extends Model
         }
     }
 
+    public static function BQresult($model){
+        //获取赛事表7天内所有赛事
+        $matchData = $model['model_match']::select('id','home_team','guest_team','lg_id','status','tag','match_date','match_time')
+            ->where([['match_date','>',date('Y-m-d',strtotime("-2 day"))],['status','=',2]])
+            ->get()
+            ->toArray();
+
+        
+        //获取赛事结果表 一天内
+        $matchData_r = $model['model_result']::select('match_id')
+            ->where([['ctime','>',date('Y-m-d H:i:s', strtotime("-2 day"))]])
+            ->get()
+            ->toArray();
+
+        if(!empty($matchData_r)){
+            //如果结果表有数据,则获取结果表没有的赛事
+            foreach ($matchData as $k => $v) {
+                foreach ($matchData_r as $kk => $vv) {
+                    if ($v['id'] == $vv['match_id']) {
+                        unset($matchData[$k]);
+                    }
+                }
+            }
+        }
+
+         //没有数据,无需操作
+         if(empty($matchData)) return Response::success();
+        //获取赛事id 用于获取赛事对应结果比分
+        $match_ids = [];
+        foreach($matchData as $k =>$v){
+            //只获取赛事已结束的
+            if($v['status'] == 2){
+                $match_ids[] = $v['id'];
+            }
+        }
+
+        $match_ids_str = implode(",", $match_ids);
+
+         // 组装sql
+         $sql_result = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.all_inning,a.first_score,a.last_score,a.match_score,a.match_winer,a.home_rate,a.guest_rate,a.result_mark from st_bq_result_record a,
+         (select match_id,max(id) id from st_bq_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 = DB::select($sql_result);
+
+        //拼装赛事结果数据 
+        $set_match_r = [];
+
+        if(!empty($match_result)){
+            foreach($matchData as $k =>$v ){
+                //获取开赛时间
+                $start_time = ($v['match_date'].' '.$v['match_time']);
+                $time = time()-strtotime($v['match_time']);
+                $match_time = self::secTime($time);
+                //获取赛事每节的赛果
+                $resultData = commonFunction::filter_by_value($match_result,'match_id',$v['id']);
+            
+                if(!empty($resultData)){
+                    //获取赛果json
+                    $result_mark = json_decode($resultData['result_mark'],true);
+
+                    //获取进程
+                    $match_process = $resultData['match_process'];
+
+                    //获胜球员
+                    $match_winer = '';
+                    if($result_mark['game_num_H'] > $result_mark['game_num_C']){
+                        $match_winer = $v['home_team'];
+                    }else{
+                        $match_winer = $v['guest_team'];
+                    }
+
+                    //组装输赢结果json
+                    $inning = [
+                        1=>[
+                            "home"=>$result_mark['sc_1th_H'],
+                            "guest"=>$result_mark['sc_1th_C'],
+                        ],
+                        2=>[
+                            "home"=>$result_mark['sc_2th_H'],
+                            "guest"=>$result_mark['sc_2th_C'],
+                        ],
+                        3=>[
+                            "home"=>$result_mark['sc_3th_H'],
+                            "guest"=>$result_mark['sc_3th_C'],
+                        ],
+                        4=>[
+                            "home"=>$result_mark['sc_4th_H'],
+                            "guest"=>$result_mark['sc_4th_C'],
+                        ],
+                        5=>[
+                            "home"=>$result_mark['sc_5th_H'],
+                            "guest"=>$result_mark['sc_5th_C'],
+                        ],
+                        6=>[
+                            "home"=>$result_mark['sc_6th_H'],
+                            "guest"=>$result_mark['sc_6th_C'],
+                        ],
+                        7=>[
+                            "home"=>$result_mark['sc_7th_H'],
+                            "guest"=>$result_mark['sc_7th_C'],
+                        ],
+                        8=>[
+                            "home"=>$result_mark['sc_8th_H'],
+                            "guest"=>$result_mark['sc_8th_C'],
+                        ],
+                        9=>[
+                            "home"=>$result_mark['sc_9th_H'],
+                            "guest"=>$result_mark['sc_9th_C'],
+                        ],
+                        "other"=>[//加时
+                            "home"=>$result_mark['OT_H'],
+                            "guest"=>$result_mark['OT_C'],
+                        ]
+                    
+                    ];
+
+                    //上半场主队进球
+                    $u_home_score = $result_mark['sc_1th_H']+$result_mark['sc_2th_H']+$result_mark['sc_3th_H']+$result_mark['sc_4th_H']+$result_mark['sc_5th_H'];
+
+                    //上半场客队进球
+                    $u_guest_score = $result_mark['sc_1th_C']+$result_mark['sc_2th_C']+$result_mark['sc_3th_C']+$result_mark['sc_4th_C']+$result_mark['sc_5th_C'];
+
+                    //赛事比分
+                    $match_score = $result_mark['game_num_H'].':'.$result_mark['game_num_C'];
+
+                    //总进球数
+                    $all_goal = $result_mark['game_num_H'] + $result_mark['game_num_C'];
+                   
+                    //赛事待写入赛果数据
+                    $set_match_r[] = [
+                        "match_id"=> $v['id'],
+                        "home_team"=>$v['home_team'],
+                        "guest_team"=>$v['guest_team'],
+                        "lg_id"=>$v['lg_id'],
+                        "status"=>$v['status'],
+                        "tag"=> $v['tag'],
+                        'match_time'=>$resultData['a_time']?:0,
+                        "ctime"=>date('Y-m-d H:i:s'),
+                        "update_time"=>date('Y-m-d H:i:s'),
+                        "start_time"=>date('Y-m-d H:i:s',strtotime($start_time)),
+
+                        "home_rate"=> $resultData['home_rate']?:0, //主队让球
+                        "guest_rate"=> $resultData['guest_rate']?:0, //客队让球
+                        "home_score"=> $result_mark['game_num_H']?:0, //主队进球
+                        "guest_score"=> $result_mark['game_num_C']?:0, //客队进球
+                        "all_goal"=> $all_goal?:0, //总局数
+                        // "first_score"=> $resultData['first_score']?:'', //最先得分
+                        // "last_score"=> $resultData['last_score']?:'', //最后得分
+                        "match_score"=> $match_score?:'',//赛事比分
+                        "match_winer"=>  $match_winer?:'',//获胜队员
+                        "match_process"=> $match_process?:'',//比赛进程
+                        "u_home_score"=> $u_home_score,//上半场主队进球
+                        "u_guest_score"=> $u_guest_score ,//上半场客队进球
+                        "match_score_t"=> json_encode($inning)?:'',//每局输赢结果
+                    ];    
+                }
+            }
+        }
+
+        //写入赛果
+        if(!empty($set_match_r)){
+            $ret = $model['model_result']::insert($set_match_r);
+            if($ret != true) throw new \Exception( Response::generate('',Response::ADD_MATCH_R_ERROR));
+        }
+
+        return 1;
+
+    }
+
     //计算滚球 赛事进行时间
     public static function secTime($sec=0){
         $min = floor($sec/60);

+ 1 - 1
app/Http/Model/StWqResult.php

@@ -130,7 +130,7 @@ class StWqResult extends Model
  
          $match_ids_str = implode(",", $match_ids);
 
-        //组装sql match_process = '第一节' and
+        //组装sql 
         //获取赛事最终赛果
         $sql_result = "select a.match_id,a.home_player_score,a.guest_player_score,a.match_time as a_time,a.home_player_let_plate,a.guest_player_let_plate,a.home_player_let_inning,a.guest_player_let_inning,a.all_inning,a.match_process,a.first_score_player,a.last_score_player,a.first_inning_score,a.second_inning_score,a.third_inning_score,a.match_winer_player,a.result_mark from st_wq_result_record a,
         (select match_id,max(id) id from st_wq_result_record where match_id IN ($match_ids_str) group by match_id)b

+ 1 - 1
resources/lang/zh-cn/Sportsbq.php

@@ -14,7 +14,7 @@ return array(
     'status' => '比赛状态',
     'first_score' => '最先进球球队',
     'last_score' => '最后进球球队',
-    'match_score' => '赛事比分',
+    'match_score' => '赛事比分(主/客)',
     'match_winer' => '获胜球队',
     'update_time' => '更新时间',
     'match_time' => '比赛进行时间',

+ 2 - 2
resources/lang/zh-cn/sportsbk.php

@@ -35,9 +35,9 @@ return array(
 	'select_status' => '请选择比赛状态',
 	'dsnum' => '单式单',
 	'csnum' => '串式单',
-	'sectionone_two' =>'第一/二节(客/主)',
+	'sectionone_two' =>'第一/二节(主/客)',
 	'sectiontwo' => '第二节',
-	'sectionthere_four' => '第三/四节(客/主)',
+	'sectionthere_four' => '第三/四节(主/客)',
 	'sectionfour' => '第四节',
 	'overtimeone' => '第一加时',
 	'overtimetwo' => '第二加时',

+ 1 - 1
resources/lang/zh-cn/sportsfoot.php

@@ -37,7 +37,7 @@ return array(
 	'all_goal' => '总进球数',
 	'dsnum' => '单式注单数',
 	'csnum' => '串式注单数',
-	'sxalfcourt' => '上半场/全场比分',
+	'sxalfcourt' => '上半场/全场比分(主/客)',
 	'statusmatch' => '比赛状态',
 	'homeallcorner' => '主队全场角球',
 	'guestallcorner' => '客队全场角球',

+ 1 - 1
resources/lang/zh-cn/sportswq.php

@@ -14,7 +14,7 @@ return array(
     'status' => '比赛状态',
     'first_score' => '最先进球球队',
     'last_score' => '最后进球球队',
-    'match_score' => '赛事比分',
+    'match_score' => '赛事比分(主/客)',
     'match_winer' => '获胜球队',
     'update_time' => '更新时间',
     'match_time' => '比赛进行时间',

+ 16 - 13
resources/views/admin/Sportsbq/outcome.blade.php

@@ -137,10 +137,11 @@
     </script>
 
     <script type="text/html" id="match_score">
-            <input type="text" style="width:30px;heigth:20px" id="u_home_score@{{d.id}}" name="u_home_score" value="@{{d.u_home_score}}" onchange="teamscore(1, event.target.value,@{{d.match_id}})"> 
-            <input type="text" style="width:30px;heigth:20px" id="u_guest_score@{{d.id}}" name="u_guest_score" value="@{{d.u_guest_score}}" onchange="teamscore(2, event.target.value,@{{d.match_id}})"> / 
-            <input type="text" style="width:30px;heigth:20px" id="home_score@{{d.id}}" name="home_score" value="@{{d.home_score}}" onchange="teamscore(3, event.target.value,@{{d.match_id}})">
-            <input type="text" style="width:30px;heigth:20px" id="guest_score@{{d.id}}" name="guest_score" value="@{{d.guest_score}}" onchange="teamscore(4, event.target.value,@{{d.match_id}})">
+            <input type="text" style="width:30px;heigth:20px" id="u_home_score@{{d.match_id}}" name="u_home_score" value="@{{d.u_home_score}}"> 
+            <input type="text" style="width:30px;heigth:20px" id="u_guest_score@{{d.match_id}}" name="u_guest_score" value="@{{d.u_guest_score}}"> / 
+            <input type="text" style="width:30px;heigth:20px" id="home_score@{{d.match_id}}" name="home_score" value="@{{d.home_score}}">
+            <input type="text" style="width:30px;heigth:20px" id="guest_score@{{d.match_id}}" name="guest_score" value="@{{d.guest_score}}">
+            <button class="layui-btn layui-btn-sm lay-btn-diy" onclick="teamscore(@{{d.match_id}})"><h6>提交</h6></button>
     </script>
 
     <script type="text/html" id="dsnum">
@@ -532,22 +533,24 @@
         }
 
         //修改赛事比分  only:唯一 num:inputval match_id:match_id
-        function teamscore(only,num,match_id){
-            var only = only;
-            var num = num;
+        function teamscore(match_id){
             var match_id = match_id;
-            var reg = /^[0-99]\d*$/;
+            var u_home_score = document.getElementById("u_home_score"+match_id).value;
+            var u_guest_score = document.getElementById("u_guest_score"+match_id).value;
+            var home_score = document.getElementById("home_score"+match_id).value;
+            var guest_score = document.getElementById("guest_score"+match_id).value;
+            // var reg = /^[0-99]\d*$/;
 
-            if(reg.test(num)==false){ 
-                layer.msg('不能为空值');
-                reloadDataTable();return;
-            }
+            // if(reg.test(num)==false){ 
+            //     layer.msg('不能为空值');
+            //     reloadDataTable();return;
+            // }
 
             $.ajax({
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/Sportsbq/updatascore',
-                data: {only:only,num:num,match_id:match_id},
+                data: {match_id:match_id,u_home_score:u_home_score,u_guest_score:u_guest_score,home_score:home_score,guest_score:guest_score},
                 success: function(data) {
                     if(data.status==1){
                         layer.msg(data.msg);

+ 12 - 13
resources/views/admin/Sportswq/outcome.blade.php

@@ -130,9 +130,10 @@
       @{{#} }}
     </script>
 
-    <script type="text/html" id="matchscore">
-            <input type="text" style="width:30px;heigth:20px" id="guest_player_score@{{d.match_id}}" name="guest_player_score" value="@{{d.guest_player_score}}" onchange="inputscore(@{{d.id}}, event.target.value,@{{d.match_id}})"> 
-            <input type="text" style="width:30px;heigth:20px" id="home_player_score@{{d.match_id}}" name="home_player_score" value="@{{d.home_player_score}}" onchange="inputscore(@{{d.id}}, event.target.value,@{{d.match_id}})">
+    <script type="text/html" id="matchscore"> 
+            <input type="text" style="width:30px;heigth:20px" id="home_player_score@{{d.match_id}}" name="home_player_score" value="@{{d.home_player_score}}"> /
+            <input type="text" style="width:30px;heigth:20px" id="guest_player_score@{{d.match_id}}" name="guest_player_score" value="@{{d.guest_player_score}}">
+            <button class="layui-btn layui-btn-sm lay-btn-diy" onclick="inputscore(@{{d.match_id}})"><h6>提交</h6></button>
     </script>
 
     <script type="text/html" id="dsnum">
@@ -517,25 +518,23 @@
             })
         }
 
-        //修改赛事比分  only:唯一 num:inputval match_id:match_id
-        function inputscore(only,num,match_id){
-            var only = only;
-            var num = num;
+        //修改赛事比分
+        function inputscore(match_id){
             var match_id = match_id;
-            var reg = /^[0-99]\d*$/;
+            // var reg = /^[0-99]\d*$/;
             var guest_player_score = $("#guest_player_score"+match_id).val();
             var home_player_score = $("#home_player_score"+match_id).val();
 
-            if(reg.test(num)==false){ 
-                layer.msg('不能为空值');
-                reloadDataTable();return;
-            }
+            // if(reg.test(num)==false){ 
+            //     layer.msg('不能为空值');
+            //     reloadDataTable();return;
+            // }
 
             $.ajax({
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/Sportswq/updatascore',
-                data: {only:only,num:num,match_id:match_id,guest_player_score:guest_player_score,home_player_score:home_player_score},
+                data: {match_id:match_id,guest_player_score:guest_player_score,home_player_score:home_player_score},
                 success: function(data) {
                     if(data.status==1){
                         layer.msg(data.msg);

+ 6 - 6
resources/views/admin/sportsbk/outcome.blade.php

@@ -173,17 +173,17 @@
     </script>
     
     <script type="text/html" id="sectionone_two">
-        <input type="text" style="width:30px;heigth:20px" id="okteamscore@{{d.match_id}}" name="okteamscore" value="@{{d.okteamscore}}"> 
-        <input type="text" style="width:30px;heigth:20px" id="ozteamscore@{{d.match_id}}" name="ozteamscore" value="@{{d.ozteamscore}}"> / 
-        <input type="text" style="width:30px;heigth:20px" id="tkteamscore@{{d.match_id}}" name="tkteamscore" value="@{{d.tkteamscore}}">
+        <input type="text" style="width:30px;heigth:20px" id="ozteamscore@{{d.match_id}}" name="ozteamscore" value="@{{d.ozteamscore}}">
+        <input type="text" style="width:30px;heigth:20px" id="okteamscore@{{d.match_id}}" name="okteamscore" value="@{{d.okteamscore}}"> / 
         <input type="text" style="width:30px;heigth:20px" id="tzteamscore@{{d.match_id}}" name="tzteamscore" value="@{{d.tzteamscore}}">
+        <input type="text" style="width:30px;heigth:20px" id="tkteamscore@{{d.match_id}}" name="tkteamscore" value="@{{d.tkteamscore}}">
     </script>
 
     <script type="text/html" id="sectionthere_four">
-        <input type="text" style="width:30px;heigth:20px" id="skteamscore@{{d.match_id}}" name="skteamscore" value="@{{d.skteamscore}}"> 
-        <input type="text" style="width:30px;heigth:20px" id="szteamscore@{{d.match_id}}" name="szteamscore" value="@{{d.szteamscore}}"> / 
-        <input type="text" style="width:30px;heigth:20px" id="akteamscore@{{d.match_id}}" name="akteamscore" value="@{{d.akteamscore}}">
+        <input type="text" style="width:30px;heigth:20px" id="szteamscore@{{d.match_id}}" name="szteamscore" value="@{{d.szteamscore}}">
+        <input type="text" style="width:30px;heigth:20px" id="skteamscore@{{d.match_id}}" name="skteamscore" value="@{{d.skteamscore}}"> / 
         <input type="text" style="width:30px;heigth:20px" id="azteamscore@{{d.match_id}}" name="azteamscore" value="@{{d.azteamscore}}">
+        <input type="text" style="width:30px;heigth:20px" id="akteamscore@{{d.match_id}}" name="akteamscore" value="@{{d.akteamscore}}">
         <button class="layui-btn layui-btn-sm lay-btn-diy" onclick="teamscore(@{{d.match_id}})"><h6>提交</h6></button>
     </script>