浏览代码

足球结果设置

彭俊 6 年之前
父节点
当前提交
0567ba6f8d

+ 9 - 0
app/Http/Controllers/Admin/SoccerStringNoteListController.php

@@ -30,6 +30,7 @@ class SoccerStringNoteListController extends Controller
         $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
         $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['match_id'] = $_GET['match_id'] ? $_GET['match_id'] : '';
         $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SoccerStringNoteList/info');
@@ -62,6 +63,7 @@ class SoccerStringNoteListController extends Controller
         $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
         $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
         $order_id = Request::get('order_id') ? Request::get('order_id') : '';
+        $match_id = Request::get('match_id') ? Request::get('match_id') : '';
         $status = Request::has('status') ? Request::get('status') : '';
         $order_status = Request::has('order_status') ? Request::get('order_status') : '';
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
@@ -89,6 +91,13 @@ class SoccerStringNoteListController extends Controller
         if (!empty($order_id)){
             $where[] = array('money_buy_str.order_id', $order_id);
         }
+
+        if(!empty($match_id)){
+            $allcs = new \App\Models\MoneyBuyMatch();
+            $csorder = $allcs->allstrorder($match_id);
+            $where[] = array('money_buy_str.order_id', $csorder[0]['order_id']);
+        }
+            
         if ($status != -1) {
             $where[] = array('money_buy_str.settle_status', '=', $status);
         }

+ 35 - 18
app/Http/Controllers/Admin/SportsfootController.php

@@ -67,30 +67,47 @@ class SportsfootController extends Controller {
 				return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);;//输赢错误
 			}
 		}else{
+			$log = array(
+				session('adminInfo.admin_name'),
+			);
+			OperationLog(session('adminInfo.admin_id'), '足球结算', $log);
 			$res = \App\Models\Stzqresult::where ('match_id', $match_id)->update(['status' =>3]);
 			$res = \App\Models\SportsSoccer::where ('match_id', $match_id)->update(['status' =>3]);
             return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
 		}
+		
 	}
 
 	//添加危险球列表
 	function addwarn(Req $req){
 		$match_id = $req->match_id;
 		$warn = \App\Models\Stzqresult::where('match_id', $match_id)->select("warn_more")->first();
-		$request['warnmore'] = json_decode($warn['warn_more'],true);
-		// $sousuo = $req->sousuo;
-		// if($sousuo){
-		// 	for ($i=0; $i < count($request['warnmore']); $i++) { 
-		// 	    if($request['warnmore'][$i]['rtype']==$sousuo){
-		// 	        $array[$i]['timei'] = $request['warnmore'][$i]['timei'];
-		// 	        $array[$i]['rtype'] = $request['warnmore'][$i]['rtype'];
-		// 	    }
-		// 	    // unset($array2D[2]);//删除
-		// 	}
-		// 	$request['warnmore'] = $array;
-		// }
+		$warnmore = json_decode($warn['warn_more'],true);
+
+		$sousuo = $req->sousuo?$req->sousuo:'';
+		if($sousuo){
+			$shuzu = array();
+			for ($i=0; $i < count($warnmore); $i++) { 
+			    if($warnmore[$i]['rtype']==$sousuo){
+			        $shuzu[$i]['timei'] = $warnmore[$i]['timei'];
+			        $shuzu[$i]['rtype'] = $warnmore[$i]['rtype'];
+			    }
+			}
+			$shuzu = array_values($shuzu);
+			$warnmore = $shuzu;
+			$warnmore[0]['timei'] = 10000;
+		}
+		
+		if($warnmore[0]['timei']!="1970-1-1 0:0:1"){
+			$request['warnmore'] = $warnmore;
+			$request['warnmore'][0]['rtype'] = $sousuo;
+		}else{
+			$request['warnmore'] = '';
+		}
+		
 		$request['match_id'] = $match_id;
-
+		$request['sousuo'] = $sousuo;
+		
 		return view('admin.sportsfoot/addwarn', $request);
 	}
 
@@ -126,16 +143,16 @@ class SportsfootController extends Controller {
 		$only =$model['start_time'];
 		$t = strtotime($only);
 		$tt = date('Y-m-d H:i:s', $t+1*3*60*60);
-		
+		//timei']!="1970-1-1 0:0:1"
 		if($only<$timei && $timei<$tt){
 			if($typenum==10000){
-				if($sel[0]['rtype']==0){
+				if($sel[0]['timei']=="1970-1-1 0:0:1"){
 					//首次添加
-					$res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($addru)]);
+					$res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($addru,JSON_UNESCAPED_UNICODE)]);
 				}else{
 					//再次添加
 					$upnum = array_merge_recursive($sel,$addru);
-					$res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($upnum)]);
+					$res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($upnum,JSON_UNESCAPED_UNICODE)]);
 				}
 			}else{
 				//编辑
@@ -143,7 +160,7 @@ class SportsfootController extends Controller {
 					$sel[$wid]['timei'] = $timei;
 					$sel[$wid]['rtype'] = $rtype;
 				}
-				$res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($sel)]);
+				$res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($sel,JSON_UNESCAPED_UNICODE)]);
 			}
 		}else{
 			return json_encode(['status'=>2,'msg'=>'请设置正确时间']);

+ 4 - 1
app/Http/Controllers/Api/WriteSportsController.php

@@ -2010,7 +2010,9 @@ class WriteSportsController extends BaseController
             if ($data->game_code) {
                 //用于后台 将所有进行中的赛事写入结果
                 $this->match_result($data->game_code);
-            } else {
+            } 
+            /*
+            else {
                 //验证token
                 $dd = $data->session()->get('adminInfo');
                 if (empty($data->token) || ($dd['token'] != $data->token)) return Response::generate('', Response::TOKEN_ERR);
@@ -2217,6 +2219,7 @@ class WriteSportsController extends BaseController
                     }
                 }
             }
+            */
             //提交事务
             DB::commit();
             return Response::success();

+ 130 - 33
app/Http/Model/StZqResult.php

@@ -3,6 +3,8 @@ namespace App\Http\Model;
 
 use Illuminate\Database\Eloquent\Model;
 use App\Http\Response\Response;
+use Illuminate\Support\Facades\DB;
+
 
 /**
  * Class StZqResult
@@ -20,7 +22,7 @@ class StZqResult extends Model
     public static function ZQresult($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"))]])
+            ->where([['ctime','>',date('Y-m-d H:i:s', strtotime("-1 day"))]])
             ->get()
             ->toarray();
 
@@ -28,31 +30,105 @@ class StZqResult extends Model
         if(empty($matchData)) return Response::success();
         //获取赛事结果表 所有当月
         $matchData_r = $model['model_result']::select('match_id')
-            ->where([['ctime','>',date('Y-m-d H:i:s', strtotime("-7 day"))]])
+            ->where([['ctime','>',date('Y-m-d H:i:s', strtotime("-1 day"))]])
             ->get()
             ->toarray();
 
+        //获取赛事对应结果比分
+        //获取赛事id
+        $match_ids = [];
+        foreach($matchData as $k =>$v){
+            //只获取赛事已结束的
+            if($v['status'] == 2){
+                $match_ids[] = $v['id'];
+            }
+        }
+        $match_ids_str = implode(",", $match_ids);
+        
+        //上半场
+        $sql_h = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.all_goal,a.first_score,a.last_score,a.match_score,a.match_winer from st_zq_result_record a,
+        (select match_id,max(id) id from st_zq_result_record where match_process = '上半场' and match_id IN ($match_ids_str) group by match_id)b
+        where a.match_id = b.match_id and a.id = b.id ";
+
+        //全场
+        $sql_f = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.all_goal,a.first_score,a.last_score,a.match_score,a.match_winer,a.home_rate,a.guest_rate from st_zq_result_record a,
+        (select match_id,max(id) id from st_zq_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_h = DB::select($sql_h);
+
+        //全场最终结果
+        $match_result_f = DB::select($sql_f);
+        //拼装赛事结果数据
+        $match_result_record = [];
+        if(!empty($match_result_h) and !empty($match_result_f)){
+            foreach($match_result_h as $k=>$v){
+                foreach($match_result_f as $kk=>$vv){
+                    if($v->match_id == $vv->match_id){
+                        $match_result_record[$k] = [
+                            "match_id"=>$v->match_id,
+                            "home_score"=> $vv->home_score,
+                            "guest_score"=> $vv->guest_score,
+                            "a_time"=> $vv->a_time,
+                            "match_process"=> $vv->match_process,
+                            "all_goal"=> $vv->all_goal,
+                            "first_score"=> $vv->first_score,
+                            "last_score"=> $vv->last_score,
+                            "match_score"=> $vv->match_score,
+                            "match_winer"=> $vv->match_winer,
+                            "u_home_score"=> $v->home_score,
+                            "u_guest_score"=> $v->guest_score,
+                            "home_rate"=> $vv->home_rate,
+                            "guest_rate"=> $vv->guest_rate,
+                        ];
+                    }
+                }
+            }
+        }
+        
+
         //结果表无数据,直接插入
         if(empty($matchData_r)){
             foreach ($matchData as $k=>$v){
                 $start_time = ($v['match_date'].' '.$v['match_time']);
                 $time = time()-strtotime($v['match_time']);
                 $match_time = self::secTime($time);
-                $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'=>$match_time,
-                    "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))
-                ];
+                foreach($match_result_record as $kk =>$vv){        
+                    if($v['id'] == $vv['match_id']){
+                        $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'=>$vv['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"=> $vv['home_rate']?:0, //主队让球
+                            "guest_rate"=> $vv['guest_rate']?:0, //客队让球
+                            "home_score"=> $vv['home_score']?:0, //主队进球数
+                            "guest_score"=> $vv['guest_score']?:0, //客队进球数
+                            "all_goal"=> $vv['all_goal']?:0, //总进球数
+                            "first_score"=> $vv['first_score']?:'', //最先进球球队
+                            "last_score"=> $vv['last_score']?:'', //最后进球球队
+                            "match_score"=> $vv['match_score']?:0, //赛事比分
+                            "match_winer"=>  $vv['match_winer']?:'',//获胜球队
+                            "match_process"=> $vv['match_process']?:'',//比赛进程
+                            "u_home_score"=> $vv['u_home_score']?:0,//上半场主队进球数
+                            "u_guest_score"=> $vv['u_guest_score']?:0,//上半场客队进球数
+                        ];                        
+                    }                   
+                }
+            }
+            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));
             }
-            $ret = $model['model_result']::insert($set_match_r);
-            if($ret != true) throw new \Exception( Response::generate('',Response::ADD_MATCH_R_ERROR));
+            
         }else {
             //如果结果表有数据,则获取结果表没有的赛事
             foreach ($matchData as $k => $v) {
@@ -66,26 +142,47 @@ class StZqResult extends Model
             if (!empty($matchData)) {
                 //写入结果表不存在赛事
                 foreach ($matchData as $k => $v) {
-                    $start_time = ($v['match_date'] . ' ' . $v['match_time']);
-                    $time = time() - strtotime($v['match_time']);
-                    $match_time = self::secTime($time);
-                    $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' => $match_time,
-                        "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))
-                    ];
+                    $start_time = ($v['match_date'].' '.$v['match_time']);
+                    $time = time()-strtotime($v['match_time']);
+                    // $match_time = self::secTime($time);
+                    foreach($match_result_record as $kk =>$vv){        
+                        if($v['id'] == $vv['match_id']){
+                            $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'=>$vv['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"=> $vv['home_rate']?:0, //主队让球
+                                "guest_rate"=> $vv['guest_rate']?:0, //客队让球
+                                "home_score"=> $vv['home_score']?:0, //主队进球数
+                                "guest_score"=> $vv['guest_score']?:0, //客队进球数
+                                "all_goal"=> $vv['all_goal']?:0, //总进球数
+                                "first_score"=> $vv['first_score']?:'', //最先进球球队
+                                "last_score"=> $vv['last_score']?:'', //最后进球球队
+                                "match_score"=> $vv['match_score']?:0, //赛事比分
+                                "match_winer"=>  $vv['match_winer']?:'',//获胜球队
+                                "match_process"=> $vv['match_process']?:'',//比赛进程
+                                "u_home_score"=> $vv['u_home_score']?:0,//上半场主队进球数
+                                "u_guest_score"=> $vv['u_guest_score']?:0,//上半场客队进球数
+                            ];                      
+                        }                   
+                    }
+                }
+                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));
                 }
-                $ret = $model['model_result']::insert($set_match_r);
-                if ($ret != true) throw new \Exception(Response::generate('', Response::ADD_MATCH_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
             }
         }
+
+        return 1;
     }
 
     //计算滚球 赛事进行时间

+ 40 - 15
resources/views/admin/sportsfoot/addwarn.blade.php

@@ -101,39 +101,49 @@
 
 	<div class="layui-row">
 		<div class="layui-col-xs12">
-			<div class="layui-form-item">
+			<div class="layui-form-item" style="margin-left:50px;">
+            <form class="layui-form rewrite" eventType="eventForm"  action="">
 				<div class="layui-inline">
-    				<!-- <label class="layui-form-label">搜&nbsp;&nbsp;索 </label>
+    				<label class="layui-form-label">搜&nbsp;&nbsp;索 </label>
                     <input type="hidden" id="match_id" name="match_id" value="{{$match_id}}">
     				<div class="layui-input-inline">
-    					<input type="text" name="sousuo" id="sousuo" lay-verify="" autocomplete="off" class="layui-input" value="">
+    					<input type="text" name="sousuo" id="sousuo" lay-verify="" autocomplete="off" class="layui-input" value="{{$sousuo}}">
     				</div>
 
     				<div class="layui-inline">
-                        <button class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload" style="opacity: 1; pointer-events: auto;" onclick="soulist()">提交</button>
-    				</div> -->
+                        <button class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload" style="opacity: 1; pointer-events: auto;">提交</button>
+    				</div>
                     
-					<div class="layui-inline" style="margin-left:20px;"><button onclick="addResult({{$match_id}},'',10000)" class="layui-btn layui-btn-sm layui-btn-green set">添加</button></div>
 				</div>
-			</div>
+            </form>
+            <div class="layui-inline" style="margin-left:320px;margin-top:-55px;"><button onclick="addResult({{$match_id}},'',10000)" class="layui-btn layui-btn-sm layui-btn-green set">危险球添加</button></div>
+            </div>
 		</div>
 	</div>
 	
-    <table lay-filter="parse-table-demo">
+    <table lay-filter="parse-table-demo" style="width:80%;text-align:left;">
         <tr class="layui-form-item">
-            <td class="layui-form-label" style="width:150px;left:10px;">时 间</td>
-            <td class="layui-form-label" style="width:100px;left:10px;">类 型</td>
-            <td class="layui-form-label" style="width:100px;left:10px;">操 作</td>
+            <td class="layui-form-label" style="width:5%;left:10px;"><h3>id</h3></td>
+            <td class="layui-form-label" style="width:20%;left:10px;"><h3>危险球时间</h3></td>
+            <td class="layui-form-label" style="width:20%;left:10px;"><h3>危险球类型</h3></td>
+            <td class="layui-form-label" style="width:20%;left:10px;"><h3>操 作</h3></td>
         </tr>
+        @if($warnmore)
         @foreach ($warnmore as $k=>$val)
         <tr class="layui-form-item">
-            <td class="layui-form-label" style="width:150px;left:10px;">{{$warnmore[$k]['timei']}}</td>
-            <td class="layui-form-label" style="width:100px;left:10px;">{{$warnmore[$k]['rtype']}}</td>
-            <td class="layui-form-label" style="width:100px;left:10px;">
+            <td class="layui-form-label" style="width:5%;left:10px;">{{$k}}</td>
+            <td class="layui-form-label" style="width:20%;left:10px;">{{$warnmore[$k]['timei']}}</td>
+            <td class="layui-form-label" style="width:20%;left:10px;">{{$warnmore[$k]['rtype']}}</td>
+            <td class="layui-form-label" style="width:20%;left:10px;">
                 <button onclick="addResult({{$match_id}},{{$k}},2)" class="layui-btn layui-btn-sm layui-btn-green set">编辑</button>
             </td>
         </tr>
         @endforeach
+        @else
+        <tr class="layui-form-item">
+            <td class="layui-form-label" style="width:150px;left:10px;">暂时无危险球数据</td>
+        </tr>
+        @endif
     </table>
 
 	<!-- 弹窗 -->
@@ -165,7 +175,22 @@
             </div>
     </div>
 
-    <script>
+    <script type="text/javascript">
+        $(function () {
+            $('body').on('click', 'a[eventtype="event-delete"]', function () {
+                var span = $(this).prev();
+                var id = span.attr('data-id');
+            })
+            $('body').on('click','#form_sureblur~.layui-form-switch',function(){
+                var sus = $('#form_sureblur').next().text();
+                if(sus=='精确'){
+                    $('#form_sureblurs').val('on');
+                }else{
+                    $('#form_sureblurs').val('off');
+                }
+            })
+        })
+
     	function addResult(match_id,wid,typenum){
             $(":input",$("#myModal")).each(function(i){  $(this).val('');});
             var wid = wid?wid:0;

+ 4 - 0
resources/views/admin/sportsfoot/outcome.blade.php

@@ -120,6 +120,10 @@
         <span><a href="/admin/SoccerNoteList/notelist?type=zq&match_id=@{{d.match_id}}"> 单式</a></span>
     </script>
 
+    <script type="text/html" id="csnum">
+        <span><a href="/admin/SoccerStringNoteList/notelist?match_id=@{{d.match_id}}"> 串式</a></span>
+    </script>
+
     <script type="text/html" id="status">
             <button onclick="addResult(@{{d.match_id}})" class="layui-btn layui-btn-sm layui-btn-green set">赛事结果</button>
             <a href="/admin/sportsfoot/addwarn?match_id=@{{d.match_id}}" class="layui-btn layui-btn-sm ">危险球</a>

+ 1 - 0
resources/views/sports/sports_stringnotelist.blade.php

@@ -75,6 +75,7 @@
     <div class="layui-row">
         <div class="layui-col-xs12">
             <form class="layui-form rewrite" eventType="eventForm"  action="" method="get">
+            <input type="hidden" name="match_id" id="match_id" value="{$match_id}">
                 <div class="layui-form-item">
 
                     <div class="layui-inline">