Эх сурвалжийг харах

处理写赛事新增上半场赛事ID

彭俊 6 жил өмнө
parent
commit
f83abff921

+ 13 - 35
app/Http/Controllers/Admin/SportsSoccerController.php

@@ -15,7 +15,6 @@ use Request;
 class SportsSoccerController extends Controller {
 
     public function score(Req $req) {
-        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
         $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
         $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
         $request['match_date'] = isset($req->match_date) ? trim($req->match_date) : null;
@@ -37,8 +36,6 @@ class SportsSoccerController extends Controller {
             $data = \App\Models\SoccerLeague::select('id','name_chinese')->get();
         }
 
-//        $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
-
         $request['league'] = $data;
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SportsSoccer/info');
@@ -51,7 +48,6 @@ class SportsSoccerController extends Controller {
         $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
         $dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
         $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
-        //$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
         if (checkRriv('/admin/SportsSoccer/edit')) {
             $arr[] = 'edit';
         }
@@ -75,9 +71,6 @@ class SportsSoccerController extends Controller {
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $where = array();
         $orwhere = array();
-//        if (!empty($name_chinese) && $name_chinese!=-1) {
-//            $where[] = array('st_zq_league.name_chinese', '=', $name_chinese);
-//        }
         if (!empty($name_chinese)) {
             if (empty($sureblur) || $sureblur == 'off') {
                 $where[] = array('st_zq_league.name_chinese', 'like', '%' . $name_chinese . '%');
@@ -109,9 +102,6 @@ class SportsSoccerController extends Controller {
             }
         }
 
-//        if(!empty($match_date)){
-//            $where[] = array('st_zq_competition.match_date', '=', $match_date);
-//        }
         if($status != -1){
             $where[] = array('st_zq_competition.status', '=', $status);
         }
@@ -147,8 +137,6 @@ class SportsSoccerController extends Controller {
             $data = \App\Models\SoccerLeague::select('id','name_chinese')->get();
         }
 
-//        $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
-
         if (!$data) {
             return;
         }
@@ -305,15 +293,13 @@ class SportsSoccerController extends Controller {
 
             $data['match_status'] = $match_status;
 
-
-            //$lange = trans('menu');
             foreach ($data['parents'] as $k => $v) {
                 $arr = trim($data['parents'][$k]['name_chinese']);
                 if (isset($lange[$arr])) {
                     $data['parents'][$k]['name_chinese']=$lange[$arr];
                 }
             }
-// var_dump($data);die;
+
             return view('sports.soccer_form', $data);
         } else {
             $model = new \App\Models\SportsSoccer();
@@ -364,11 +350,11 @@ class SportsSoccerController extends Controller {
     public function delete(Req $req) {
         $id = $req->input('id');
         if (empty($id)) {
-            return responseToJson(-2001); //id������
+            return responseToJson(-2001); 
         }
         $ids = explode(',', $id);
         if (!is_array($ids) && intval($ids) < 0) {
-            return responseToJson(-2002); //id����
+            return responseToJson(-2002); 
         }
         $id = array();
         $localmatch = \App\Models\Stzqlocalmatch::get();
@@ -388,15 +374,15 @@ class SportsSoccerController extends Controller {
 
         $rows = \App\Models\SportsSoccer::whereIn('id', $ids)->delete();
         if (!$rows) {
-            return responseToJson(-2003); //id����
+            return responseToJson(-2003); 
         }
         if(count($id)>0) {
             $row = \App\Models\Stzqlocalmatch::whereIn('id', $id)->delete();
             if (!$row) {
-                return responseToJson(-2003); //id????
+                return responseToJson(-2003); 
             }
         }
-        return responseToJson(1, trans('menu.delete_success')); //id����
+        return responseToJson(1, trans('menu.delete_success')); 
 
     }
 
@@ -409,7 +395,7 @@ class SportsSoccerController extends Controller {
         if (intval($id) < 1) {
             return -1;
         }
-        //return $id;
+
         $SettlementWinFail = new SettlementWinFail();
         $data = $SettlementWinFail->doRun($id);
         return $data;
@@ -422,7 +408,7 @@ class SportsSoccerController extends Controller {
         $request['p_code'] = isset($req->p_code) ? trim($req->p_code) : '-1';
         $request['id'] = isset($req->id) ? trim($req->id) : null;
         $newapp = \App\Models\SportsSoccer::where('id',$request['id'])->first();
-       // $match_id = $newapp->match_id;
+
         if(empty($newapp)){
             $match_id = $req->input('id');
         }else{
@@ -430,7 +416,7 @@ class SportsSoccerController extends Controller {
         }
         $request['match_id'] = isset($match_id) ? trim($match_id) : null;
         $data = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
-        //$data = \App\Model\Matchcode::where('p_id','0')->get();
+
         $request['pcode'] = $data;
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SportsSoccer/oddsinfo?match_id='.$match_id.'');
@@ -440,7 +426,6 @@ class SportsSoccerController extends Controller {
         $dt->addColsFields('odds_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
         $dt->addColsFields('condition', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
         $dt->addColsFields('odds', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
-//        $dt->addColsFields('p_id', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
         $dt->addColsFields('p_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
         $dt->addColsFields('max', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
         $dt->addColsFields('min', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
@@ -502,7 +487,6 @@ class SportsSoccerController extends Controller {
      */
     function addodds(Req $req) {
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
-        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
         for($i=0;$i<count($pcodedata);$i++){
             $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
         }
@@ -576,7 +560,6 @@ class SportsSoccerController extends Controller {
     function oddsedit(Req $req) {
         $lange = trans('sportsoddscode');
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
-        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
         for($i=0;$i<count($pcodedata);$i++){
             $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
         }
@@ -626,7 +609,6 @@ class SportsSoccerController extends Controller {
             $data = $data->toArray();
 
             $data['pcode'] = $pcodedata;
-            //$data['code'] = $codedata;
 
             return view('sports.soccer_odds_form', $data);
         } else {
@@ -634,9 +616,7 @@ class SportsSoccerController extends Controller {
             $data = new \App\Models\SoccerOddsRecord();
             $model->id = $req->input('id');
             $model = $model::find($model->id);
-            //$model->odds_code = $req->input('code');
             $model->status = $req->input('status');
-            //$model->p_code = $req->input('pcode');
             $model->odds = $req->input('odds');
             $model->condition = $req->input('condition');
             $model->max = $req->input('max');
@@ -648,9 +628,7 @@ class SportsSoccerController extends Controller {
 
             $result = \App\Models\SoccerOdds::where('id',$model->id)->first();
             $data->match_id = $result->match_id;
-            //$data->odds_code = $model->odds_code;
             $data->status = $model->status;
-            //$data->p_code = $model->p_code;
             $data->p_id = $result->p_id;
             $record = \App\Models\SoccerOddsRecord::where('match_id',$data->match_id)->where('odds_code',$result->odds_code)->where('p_id',$result->p_id)->orderby('utime','desc')->first();
             if(!empty($record)){
@@ -681,11 +659,11 @@ class SportsSoccerController extends Controller {
     public function oddsdelete(Req $req) {
         $id = $req->input('id');
         if (empty($id)) {
-            return responseToJson(-2001); //id������
+            return responseToJson(-2001); 
         }
         $ids = explode(',', $id);
         if (!is_array($ids) && intval($ids) < 0) {
-            return responseToJson(-2002); //id����
+            return responseToJson(-2002); 
         }
         if (is_array($ids) && count($ids) > 0) {
             foreach ($ids as $k => $v) {
@@ -697,9 +675,9 @@ class SportsSoccerController extends Controller {
 
         $rows = \App\Models\SoccerOdds::whereIn('id', $ids)->delete();
         if (!$rows) {
-            return responseToJson(-2003); //id����
+            return responseToJson(-2003); 
         }
-        return responseToJson(1, trans('menu.delete_success')); //id����
+        return responseToJson(1, trans('menu.delete_success')); 
 
     }
 }

+ 6 - 130
app/Http/Controllers/Api/WriteSportsController.php

@@ -327,20 +327,22 @@ class WriteSportsController extends BaseController{
                     foreach($s_match_ids as $kk=> $s_match_id){
                         if($v['match_id'] == $s_match_id){
                             $data = $v;
-                            $half_match_id = 0;
+                            $half_match_id = $v['half_match_id'];
                             //获取 本地 联赛 ID
                             //验证本赛事是否有数据源lg_id
                             if(empty($data['lg_id'])) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::S_LG_ID_NULL));
                             $lg_id = commonFunction::searcharray($data['uuid'],'identity',$l_lg_data,'lg_id');
                             //验证 本赛事是否获取到本地lg_id
                             if(empty($lg_id)) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::L_LG_ID_NULL));
+                            /*
                             //如果有上半场赛事id 获取上半场赛事是否存在
                             if(!empty($l_match_data) and $data['half_match_id'] > 0){
                                 $half_match_id = -1;
-                                // $half_match_id = $models['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$source])
-                                //     ->value('match_id');
-                                // if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'上半场赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
+                                $half_match_id = $models['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$source])
+                                    ->value('match_id');
+                                if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'上半场赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
                             }
+                            */
                             //如果赛事没有开始日期,则为冠军盘口赛事 
                             if(empty($data['match_date'])){
                                 //冠军盘口赛事获取所属联赛结束时间
@@ -401,132 +403,6 @@ class WriteSportsController extends BaseController{
 
     }
 
-    //测试获取上半场赛事 暂未使用
-    public function __setMatch(Req $data){
-        //验证token
-        $user = new \App\Models\System_user;
-        if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
-        $token = $user::where(['token'=>$data->token])->value('token');
-        if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
-        try {
-            //开启事务
-            DB::beginTransaction();
-            $obt = $data->data;
-            //请求 数据 为空
-            if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
-            $getData = $this->getAddData($obt);
-            //不是 赛事 数据
-            if($getData['title'] != 'match') throw new \Exception(Response::generate('不是赛事数据,',Response::ABNORMAL));
-
-            //写请求数据 日志记录
-            $setSportsRecord = St_set_sports_recordModel::setSportsRecord($getData['title'],$obt,$getData);
-            if($setSportsRecord < 1) throw new \Exception(Response::generate('',Response::SPORTS_RECORD_ERR));
-            //获取球类代码
-            $game_code = $getData['game_code'];
-            //获取数据源
-            $source = $getData['source'];
-            //获取球类名称
-            $gameName = gameModel::getGameName($game_code);
-            //获取 model
-            $models = commonFunction::getModels($game_code, 1);
-            //获取 赛事 数据
-            $matchData = $getData['data'];
-            //获取 当前请求 所有 uuid /match_id
-            $identity = [];
-            $s_match_ids = [];
-            foreach($matchData as $k=>$v){
-                $identity[] = $v['uuid'];
-                $s_match_ids[] = $v['match_id'];
-            }
-
-            //====验证 赛事 所属 联赛 是否存在====
-            $identity = array_unique($identity);
-            sort($identity);
-
-            //获取 本地 已存在 联赛
-            $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id','others_lg_id')->get()->toArray();
-            //二维数组去重
-            $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
-            //循环对比 请求uuid->本地identity
-            foreach($l_lg_data as $k=>$v){
-                foreach($identity as $kk=> $uuid){
-                    if($v['identity'] == $uuid){
-                        unset($identity[$kk]);
-                    }
-                }
-            }
-            sort($identity);
-            //去除本地和请求里都存在的联赛,如果还有剩余联赛id,则返回异常
-            if(!empty($identity))  throw new \Exception(Response::generate($gameName.'联赛:uuid-'.$identity[0].';',Response::LEAGUE_ERROR));
-            //====end====
-
-            //====获取 本地 已存在 赛事====
-            $s_match_ids = array_unique($s_match_ids);
-            sort($s_match_ids);
-
-            $l_match_data = $models['model_local_match']::whereIn('others_match_id',$s_match_ids)->where('source',$source)->select('others_match_id','match_id')->get()->toArray();
-            //二维数组去重
-            $l_match_data = commonFunction::uniquArrV2($l_match_data,'others_match_id');
-        
-            //循环对比 请求match_id->本地others_match_id 
-            //如果本地有 赛事,则取出本地不存在赛事
-            if(!empty($l_match_data)){
-                foreach($l_match_data as $k=>$v){
-                    foreach($s_match_ids as $kk=> $s_match_id){
-                        if($v['others_match_id'] == $s_match_id){
-                            unset($s_match_ids[$kk]);
-                        }
-                    }
-                }
-                sort($s_match_ids);
-            }
-           
-            //剩余 赛事 数据 写入
-            if(!empty($s_match_ids)){
-                //上半场赛事
-                $half_match = [];
-                $other_match = [];
-                foreach($matchData as $k=>$v){
-                    foreach($s_match_ids as $kk=> $s_match_id){
-                        if($v['match_id'] == $s_match_id){
-                            //取出上半场赛事
-                            if($v['half_match_id'] == 0){
-                                $half_match[] = $v;
-                            }else{
-                            //取出其他赛事
-                                $other_match[] = $v;
-                            }
-                        }
-                    }
-                }
-
-                //如果有上半场赛事,则先处理
-                if(!empty($half_match)){
-                    $set_half_match = [];
-                    foreach($half_match as $k=>$v){
-                         $data = $v;
-                         //验证本赛事是否有数据源lg_id
-                         if(empty($data['lg_id'])) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::S_LG_ID_NULL));
-                         $lg_id = commonFunction::searcharray($data['lg_id'],'others_lg_id',$l_lg_data,'lg_id');
-                         //验证 本赛事是否获取到本地lg_id
-                         if(empty($lg_id)) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::L_LG_ID_NULL));
-                   
-
-                    }
-                }
-            }
-    
-            //提交事务
-            DB::commit();
-            return Response::success();
-        } catch (\Exception $e) {
-            //回滚事务
-            DB::rollBack();
-            return $e->getMessage();
-        }
-
-    }
-
     /*
      * 写 赛事 结果 记录 数据
      * 每个请求 包含 N个联赛 下 N个赛事 结果数据

+ 2 - 6
resources/views/sports/soccer_league.blade.php

@@ -41,7 +41,6 @@
     </style>
 
     <script type="text/html" id="isresults">
-        <!-- <button onclick="addResult('@{{d.id}}')" class="layui-btn layui-btn-sm layui-btn-green set">修改结果</button> -->
         <button class="layui-btn layui-btn-sm layui-btn-green set"><a href="/admin/ZqChampionsLeague/edit?id=@{{d.id}}" class="layui-btn layui-btn-sm layui-btn-green set">修改结果</a></button>
 
     </script>
@@ -142,9 +141,6 @@
                         @if(checkRriv('/admin/SoccerLeague/delete'))<a href="javascript:delWin('/admin/SoccerLeague/delete?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a>@endif
                     </div>
 
-                    <!-- &nbsp;&nbsp;&nbsp;&nbsp;<div class="layui-inline"><a href="javascript:openWin('/admin/user/infoAdd','{{ trans('menu.menu_add') }}','700px','500px')" class="layui-btn layui-btn-sm  ">添加</a></div>
-                    <div class="layui-inline"><a href="/admin/menu/add" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a></div> -->
-
                 </div>
             </form>
         </div>
@@ -258,7 +254,7 @@
         }
     </script>
     @include('vip.datatable')
-    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
+    <!-- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> -->
     <script>
         var id;
         var aa;
@@ -273,7 +269,7 @@
                     data:{id:id},
                     dataType:'json',
                     success:function(data){  //请求成功回调函数
-                        //console.log(data);
+                       
                         var option = '';
                         var dd = '';
                         option += '<option value></option>';

+ 2 - 7
resources/views/sports/soccer_match.blade.php

@@ -52,11 +52,11 @@
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportssoccer.team_search') }}</label>
                         <div class="layui-input-inline">
-                            <input type="text" name="home_team" id="home_team" eventType="event-query"  value="{{ $home_team }}" lay-verify="required" autocomplete="off" class="layui-input">
+                            <input type="text" name="home_team" id="home_team" eventType="event-query"  value="{{ $home_team }}" lay-verify="required" autocomplete="off" class="layui-input" placeholder="输入主队,客队名">
                         </div>
                         <label class="layui-form-label">{{ trans('sportssoccer.league_search') }}</label>
                         <div class="layui-input-inline">
-                            <input type="text" name="name_chinese" id="home_team" eventType="event-query"  value="{{ $name_chinese }}" lay-verify="required" autocomplete="off" class="layui-input">
+                            <input type="text" name="name_chinese" id="home_team" eventType="event-query"  value="{{ $name_chinese }}" lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入联赛名">
                         </div>
                         <div class="layui-input-inline checkbox">
                             <input type="checkbox" name="sureblur" id="form_sureblur" lay-skin="switch" lay-text="精确|模糊" @if(!isset($sureblurs) || $sureblurs=='on') checked @endif  class="layui-input" eventType=event-query>
@@ -125,9 +125,6 @@
                         @if(checkRriv('/admin/SportsSoccer/delete'))<a href="javascript:delWin('/admin/SportsSoccer/delete?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a>@endif
                     </div>
 
-                    <!-- &nbsp;&nbsp;&nbsp;&nbsp;<div class="layui-inline"><a href="javascript:openWin('/admin/user/infoAdd','{{ trans('menu.menu_add') }}','700px','500px')" class="layui-btn layui-btn-sm  ">添加</a></div>
-                    <div class="layui-inline"><a href="/admin/menu/add" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a></div> -->
-
                 </div>
             </form>
         </div>
@@ -138,7 +135,6 @@
             $('body').on('click', 'a[eventtype="event-delete"]', function () {
                 var span = $(this).prev();
                 var id = span.attr('data-id');
-                // openWin('/admin/system/AddMenu','{{ trans("menu.menu_edit")}}','600px','500px',id);
             })
             $('body').on('click','#form_sureblur~.layui-form-switch',function(){
                 var sus = $('#form_sureblur').next().text();
@@ -222,7 +218,6 @@
                 btn: ['确认', '取消'] //按钮
             }, function() {
                 $.getJSON(url, function(data, textStatus) {
-                    //console.log(data);
                     if (data.status == '1') {
                         reloadDataTable();
                         layer.msg('处理成功');