Quellcode durchsuchen

新增验证赛事更新数据

彭俊 vor 6 Jahren
Ursprung
Commit
42ee58b934

+ 24 - 25
app/Http/Controllers/Admin/SportswqController.php

@@ -32,11 +32,12 @@ class SportswqController extends Controller {
         $dt->setDataSource('/admin/Sportswq/outcomeinfo');
         $dt->setLang('sportswq');
         $dt->addColsFields('newtime', array('templet' => '#newtime', 'sort' => false, 'width' => 200));
-        $dt->addColsFields('home_player_name', array('templet' => '#home_team', 'sort' => false, 'width' => 80));
-        $dt->addColsFields('guest_player_name', array('templet' => '#guest_team', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('start_time', array('templet' => '#home_team', 'sort' => false, 'width' => 155));
+        $dt->addColsFields('home_player_name', array('templet' => '#home_team', 'sort' => false, 'width' => 130));
+        $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' => '#home_rate', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('match_score', array('templet' => '#matchscore', 'sort' => false, 'width' => 130));
         $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));
@@ -245,35 +246,33 @@ class SportswqController extends Controller {
         return responseToJson(1);
 	}
 
-	//更新赛事比分
-	function updatenum(Req $req){
-		$type = $req->type;
-		$id = $req->id;
-		$num = $req->num;
-		$match_id = $req->match_id;
-		$newapp = new \App\Models\Stwqresult();
-		
-		if($type==1){
-			$data['u_home_score'] = $num;
-			$res = $newapp->updateInfo($data,$id);//联赛id
-		}else if($type==2){
-			$data['u_guest_score'] = $num;
-			$res = $newapp->updateInfo($data,$id);//联赛id
-		}else if($type==3){
-			$data['home_score'] = $num;
-			$res = $newapp->updateInfo($data,$id);//联赛id
-		}else{
-			$data['guest_score'] = $num;
-			$res = $newapp->updateInfo($data,$id);//联赛id
+	//修改添加赛事比分
+	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->save();
+
 		$addnew = new \App\Models\Comendnotice();
 		$addnew->addcomendnotice($match_id,'wq');
 
-		$twoapp = new \App\Models\SportsTennis();
+		$twoapp = new \App\Models\SportsBasket();
 		$twoapp->updatestatus('match_id',$match_id,['status'=>2]);//修改赛事状态
+		$newapp = new \App\Models\Stwqresult();
 		$newapp->updatestatus('match_id',$match_id,['status'=>2]);//修改结果状态
 
-		return responseToJson(1);
+		return responseToJson(1); 
 	}
 
 

+ 44 - 35
app/Http/Controllers/Api/WriteSportsController.php

@@ -1133,41 +1133,50 @@ class WriteSportsController extends BaseController{
             DB::beginTransaction();
             //获取待更新赛事
             $obt = $data->data;
-            if($obt){
-                //json转数组
-                $data = $this->getAddData($obt);
-                //获取 球类代码
-                $game_code = $data['game_code'];
-                //获取 数据源 
-                $source = $data['source'];
-
-                //获取所有数据源赛事 match_id
-                $others_match_ids = [];
-                foreach ($data['data'] as $k=>$v){
-                    $others_match_ids[] = $v['match_id'];
-                }
-                //根据球类代码 获取model
-                $model =commonFunction::getModels($game_code,1);
-                //获取所有赛事 match_id
-                $local_match = $model['model_local_match']::SELECT('others_match_id','match_id')
-                    ->where(['source'=>$source])
-                    ->whereIn('others_match_id',$others_match_ids)
-                    ->get()->toArray();
-                if(empty($local_match)) throw new \Exception(Response::generate('',Response::MATCHID_NULL));
-                //更新状态字段
-                foreach ($local_match as $k=>$v){
-                    $set_status = [
-                        'status'=>$v['status'],
-                        'is_rollball'=>$v['is_rollball'],
-                        'stais_todaytus'=>$v['is_today'],
-                        'is_morningplate'=>$v['is_morningplate'],
-                        'is_stringscene'=>$v['is_stringscene'],
-                        'is_horn'=>$v['is_horn'],
-                    ];
-                    $ret = $model['model_match']::where(['id'=>$v['match_id']])
-                        -> update($set_status);
-                    if($ret<1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$v['others_match_id'],Response::UPSTATUS_ERROR));
-                }
+
+            //请求 数据 为空
+            if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
+            $getData = $this->getAddData($obt);
+            //不是 直播 数据
+            if($getData['title'] != '"match_status",') throw new \Exception(Response::generate('不是更新赛事状态数据',Response::ABNORMAL));
+
+            //写请求数据 日志记录
+            if($this->isRecord){
+                $setSportsRecord = St_set_sports_recordModel::setSportsRecord($getData['title'],$obt,$getData);
+                if($setSportsRecord < 1) throw new \Exception(Response::generate('',Response::SPORTS_RECORD_ERR));    
+            }
+       
+            //获取 球类代码
+            $game_code = $data['game_code'];
+            //获取 数据源 
+            $source = $data['source'];
+
+            //获取所有数据源赛事 match_id
+            $others_match_ids = [];
+            foreach ($data['data'] as $k=>$v){
+                $others_match_ids[] = $v['match_id'];
+            }
+            //根据球类代码 获取model
+            $model =commonFunction::getModels($game_code,1);
+            //获取所有赛事 match_id
+            $local_match = $model['model_local_match']::SELECT('others_match_id','match_id')
+                ->where(['source'=>$source])
+                ->whereIn('others_match_id',$others_match_ids)
+                ->get()->toArray();
+            if(empty($local_match)) throw new \Exception(Response::generate('',Response::MATCHID_NULL));
+            //更新状态字段
+            foreach ($local_match as $k=>$v){
+                $set_status = [
+                    'status'=>$v['status'],
+                    'is_rollball'=>$v['is_rollball'],
+                    'stais_todaytus'=>$v['is_today'],
+                    'is_morningplate'=>$v['is_morningplate'],
+                    'is_stringscene'=>$v['is_stringscene'],
+                    'is_horn'=>$v['is_horn'],
+                ];
+                $ret = $model['model_match']::where(['id'=>$v['match_id']])
+                    -> update($set_status);
+                if($ret<1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$v['others_match_id'],Response::UPSTATUS_ERROR));
             }
             //提交事务
             DB::commit();

+ 2 - 0
resources/lang/zh-cn/sportswq.php

@@ -29,5 +29,7 @@ return array(
     'csnum' => '串式注单',
     'statusmatch' => '比赛状态',
     'operation' => '操作',
+    'start_time' => '时间',
+
 
 );

+ 9 - 10
resources/views/admin/Sportswq/outcome.blade.php

@@ -130,6 +130,11 @@
       @{{#} }}
     </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>
+
     <script type="text/html" id="dsnum">
         <span><a href="/admin/SoccerNoteList/notelist?type=wq&match_id=@{{d.match_id}}">单式</a></span>
     </script>
@@ -500,19 +505,13 @@
         }
 
         //修改赛事比分  only:唯一 num:inputval match_id:match_id
-        function teamscore(only,num,match_id){
+        function inputscore(only,num,match_id){
             var only = only;
             var num = num;
             var match_id = match_id;
             var reg = /^[0-99]\d*$/;
-            var okteamscore = $("#okteamscore"+match_id).val();
-            var ozteamscore = $("#ozteamscore"+match_id).val();
-            var tkteamscore = $("#tkteamscore"+match_id).val();
-            var tzteamscore = $("#tzteamscore"+match_id).val();
-            var skteamscore = $("#skteamscore"+match_id).val();
-            var szteamscore = $("#szteamscore"+match_id).val();
-            var akteamscore = $("#akteamscore"+match_id).val();
-            var azteamscore = $("#azteamscore"+match_id).val();
+            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('不能为空值');
@@ -523,7 +522,7 @@
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/Sportswq/updatascore',
-                data: {only:only,num:num,match_id:match_id,okteamscore:okteamscore,ozteamscore:ozteamscore,tkteamscore:tkteamscore,tzteamscore:tzteamscore,skteamscore:skteamscore,szteamscore:szteamscore,akteamscore:akteamscore,azteamscore:azteamscore},
+                data: {only:only,num:num,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);