소스 검색

异常处理

彭俊 6 년 전
부모
커밋
23b82eaea4
4개의 변경된 파일183개의 추가작업 그리고 79개의 파일을 삭제
  1. 81 68
      app/Http/Controllers/Admin/SportsfootController.php
  2. 14 6
      app/Lib/Biz/Sport/Common.php
  3. 14 2
      app/Models/SportsNoteList.php
  4. 74 3
      resources/views/sports/sports_notelist.blade.php

+ 81 - 68
app/Http/Controllers/Admin/SportsfootController.php

@@ -563,78 +563,91 @@ class SportsfootController extends Controller {
 			$array[] = $key['home'];
 			$array[] = $key['guest'];
 		}
-		//赛事下注单作废 处理
-		commonFunction::HandleInvalid($data,$match_id,$match_status,'zq');
-
-		$penaltycard = array(
-        	'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
-        	'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
-        	'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
-        	'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
-        );
-        $cornerball = array(
-        	'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
-        	'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
-        	'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
-        	'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
-        );
-        $firstone = array(
-        	'teamscore'=>$req->firstscore ? $req->firstscore:0,
-        	'scoretime'=>intval($req->onescoretime)?intval($req->onescoretime):0,
-        	'scoretype'=>$req->firststye ? $req->firststye:0,
-        );
-		$model->match_score = $data['all']['home'].':'.$data['all']['guest'];
-		$model->u_home_score = $data['half']['home'];
-		$model->u_guest_score = $data['half']['guest'];
-		$model->home_score = $data['all']['home'];
-		$model->guest_score = $data['all']['guest'];
-		$model->last_score = $req->lastscore?$req->lastscore:'';
-		$model->match_winer = $req->matchwiner?$req->matchwiner:'';
-		$model->penalty_card = json_encode($penaltycard,JSON_UNESCAPED_UNICODE);
-		$model->corner_ball = json_encode($cornerball,JSON_UNESCAPED_UNICODE);
-		$model->first_score = json_encode($firstone,JSON_UNESCAPED_UNICODE);
-		$model->is_correct = 1;
-		$model->save();
 
-		$update = $this->addcomendnotice($match_id);
+		//修改足球比分前的比分数据
+		$res = \App\Models\Stzqresult::where('match_id', $match_id)->first();
+		$scores = json_decode($res['penalty_card'],true);
+		$process = array();//进程
+		if($scores['home'] != $data['all']['home'] || $scores['guest'] != $data['all']['guest']){
+			$process[] = 'all';
+		}
+		if($scores['home_half'] != $data['half']['home'] || $scores['guest_half'] != $data['half']['guest']){
+			$process[] = 'half';
+		}
 
-		$twoapp = new \App\Models\SportsSoccer();
-		$twoapp->updatestatus('id',$match_id,['status'=>2,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
-		$newapp = new \App\Models\Stzqresult();
-		$newapp->updatestatus('match_id',$match_id,['status'=>2,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
+		if(!empty($process)){
+			//赛事下注单作废 处理
+			commonFunction::HandleInvalid($data,$match_id,$match_status,'zq',$process);
 
-        //添加赛事结果记录
-        $lastLog = \App\Models\Stzqresultlog::where([
-            ['match_id', $match_id],
-            ['type', 1]
-        ])->orderBy('id', 'desc')->first();
-        if(empty($lastLog) || !($lastLog['penalty_card'] == $model->penalty_card
-                && $lastLog['corner_ball'] == $model->corner_ball
-                && $lastLog['first_score'] == $model->first_score
-                && $lastLog['last_score'] == $model->last_score
-                && $lastLog['match_winer'] == $model->match_winer
-				&& $lastLog['u_home_score'] == $data['half']['home']
-				&& $lastLog['u_guest_score'] == $data['half']['guest']
-				&& $lastLog['home_score'] == $data['all']['home']
-				&& $lastLog['guest_score'] == $data['all']['guest']
-            )){
-            \App\Models\Stzqresultlog::insert([
-				'u_home_score' => $data['half']['home'],
-				'u_guest_score' => $data['half']['guest'],
-				'home_score' => $data['all']['home'],
-				'guest_score' => $data['all']['guest'],
-                'match_id' => $match_id,
-                'penalty_card' => $model->penalty_card ,
-                'corner_ball' => $model->corner_ball,
-                'first_score' => $model->first_score,
-                'last_score' => $model->last_score,
-                'match_winer' => $model->match_winer,
-                'user_id' => session('adminInfo.admin_id'),
-                'type' => 1,
-                'create_at' => now()
-            ]);
-        }
+			$penaltycard = array(
+				'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
+				'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
+				'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
+				'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
+			);
+			$cornerball = array(
+				'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
+				'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
+				'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
+				'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
+			);
+			$firstone = array(
+				'teamscore'=>$req->firstscore ? $req->firstscore:0,
+				'scoretime'=>intval($req->onescoretime)?intval($req->onescoretime):0,
+				'scoretype'=>$req->firststye ? $req->firststye:0,
+			);
+			$model->match_score = $data['all']['home'].':'.$data['all']['guest'];
+			$model->u_home_score = $data['half']['home'];
+			$model->u_guest_score = $data['half']['guest'];
+			$model->home_score = $data['all']['home'];
+			$model->guest_score = $data['all']['guest'];
+			$model->last_score = $req->lastscore?$req->lastscore:'';
+			$model->match_winer = $req->matchwiner?$req->matchwiner:'';
+			$model->penalty_card = json_encode($penaltycard,JSON_UNESCAPED_UNICODE);
+			$model->corner_ball = json_encode($cornerball,JSON_UNESCAPED_UNICODE);
+			$model->first_score = json_encode($firstone,JSON_UNESCAPED_UNICODE);
+			$model->is_correct = 1;
+			$model->save();
 
+			$update = $this->addcomendnotice($match_id);
+
+			$twoapp = new \App\Models\SportsSoccer();
+			$twoapp->updatestatus('id',$match_id,['status'=>2,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
+			$newapp = new \App\Models\Stzqresult();
+			$newapp->updatestatus('match_id',$match_id,['status'=>2,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
+
+			//添加赛事结果记录
+			$lastLog = \App\Models\Stzqresultlog::where([
+				['match_id', $match_id],
+				['type', 1]
+			])->orderBy('id', 'desc')->first();
+			if(empty($lastLog) || !($lastLog['penalty_card'] == $model->penalty_card
+					&& $lastLog['corner_ball'] == $model->corner_ball
+					&& $lastLog['first_score'] == $model->first_score
+					&& $lastLog['last_score'] == $model->last_score
+					&& $lastLog['match_winer'] == $model->match_winer
+					&& $lastLog['u_home_score'] == $data['half']['home']
+					&& $lastLog['u_guest_score'] == $data['half']['guest']
+					&& $lastLog['home_score'] == $data['all']['home']
+					&& $lastLog['guest_score'] == $data['all']['guest']
+				)){
+				\App\Models\Stzqresultlog::insert([
+					'u_home_score' => $data['half']['home'],
+					'u_guest_score' => $data['half']['guest'],
+					'home_score' => $data['all']['home'],
+					'guest_score' => $data['all']['guest'],
+					'match_id' => $match_id,
+					'penalty_card' => $model->penalty_card ,
+					'corner_ball' => $model->corner_ball,
+					'first_score' => $model->first_score,
+					'last_score' => $model->last_score,
+					'match_winer' => $model->match_winer,
+					'user_id' => session('adminInfo.admin_id'),
+					'type' => 1,
+					'create_at' => now()
+				]);
+			}
+		}
         return responseToJson(1);
 	}
 

+ 14 - 6
app/Lib/Biz/Sport/Common.php

@@ -1373,7 +1373,7 @@ class Common
     /**
 	 * 赛事下注单作废处理
 	 */
-	public static function HandleInvalid($data=[],$match_id='',$match_status='',$game_code=''){
+	public static function HandleInvalid($data=[],$match_id='',$match_status='',$game_code='',$process){
 		//===作废处理===
 		$moneyBuyMatch = new \App\Models\MoneyBuyMatch();
 
@@ -1392,7 +1392,7 @@ class Common
         $oddsData_sim_settle = [];
 		if(count($match_order_sim_obj) > 0 ){
 			//获取单式注单中 待处理注单
-			$oddsData_sim = self::getOrderData($data,$match_order_sim_obj,$game_code);
+			$oddsData_sim = self::getOrderData($data,$match_order_sim_obj,$game_code,$process);
             $oddsData_sim_settle = $oddsData_sim['settle'];
             $oddsData_sim = $oddsData_sim['invalid'];
 		}
@@ -1402,7 +1402,7 @@ class Common
         $oddsData_str_settle = [];
 		if(count($match_order_str_obj) > 0){
 			//获取串式注单中 待处理注单
-			$oddsData_str = self::getOrderData($data,$match_order_str_obj,$game_code);
+			$oddsData_str = self::getOrderData($data,$match_order_str_obj,$game_code,$process);
             $oddsData_str_settle = $oddsData_str['settle'];
             $oddsData_str = $oddsData_str['invalid'];
 		}
@@ -1452,7 +1452,7 @@ class Common
 	/**
 	 * 获取赛事下 符合条件 待处理注单
 	 */
-	public static function getOrderData($data,$match_order,$game_code){
+	public static function getOrderData($data,$match_order,$game_code,$process){
 		//===足球===
 		if($game_code == 'zq'){
             //上半场(作废)
@@ -1484,8 +1484,16 @@ class Common
             }
 
             //合并待处理 注单
-			$orderData['invalid'] = array_merge($matchOdds_h,$matchOdds_f);
-            $orderData['settle'] = array_merge($matchOdds_half,$matchOdds_fall);
+            $orderData['invalid'] = array();
+            $orderData['settle'] = array();
+            if(in_array('half',$process)){
+                $orderData['invalid'] = array_merge($orderData['invalid'],$matchOdds_h);
+                $orderData['settle'] = array_merge($orderData['settle'],$matchOdds_half);
+            }
+            if(in_array('all',$process)){
+                $orderData['invalid'] = array_merge($orderData['invalid'],$matchOdds_f);
+                $orderData['settle'] = array_merge($orderData['settle'],$matchOdds_fall);
+            }
         }
         //====end===
 

+ 14 - 2
app/Models/SportsNoteList.php

@@ -330,8 +330,20 @@ class SportsNoteList extends BaseModel
 
         //棒球
         if($gameCode == 'bq'){
-            //得分最后一位数
-            $ScoreTitle_dfNum = commonFunction::checkstr($oddsName,'得分最后一位数');
+            //全场
+            $ScoreTitle_f = commonFunction::checkstr($oddsName,'全场');
+
+            //前五局
+            $ScoreTitle_five = commonFunction::checkstr($oddsName,'前五局');
+
+            //有全场
+            if($ScoreTitle_f == 1){
+                $ScoreTitle = '全场';
+            }
+            //前五局
+            if($ScoreTitle_five == 1){
+                $ScoreTitle = '前五局';
+            }
         }
 
         return $ScoreTitle;

+ 74 - 3
resources/views/sports/sports_notelist.blade.php

@@ -562,7 +562,7 @@
                             setScore_v2_lq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code,ScoreTitle,leagueName,home_team,guest_team);
                             break;
                         case 'bq':
-                            setScore_v2_bq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
+                            setScore_v2_bq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code,ScoreTitle,leagueName,home_team,guest_team);
                             break;
                         case 'wq':
                             setScore_v2_wq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
@@ -833,7 +833,6 @@ console.log(matchdata);
                         '    </div>' +
                         '  </div>' ;
 
-
             layer.open({
                 area: ['800px', '300px'], //宽高
                 type: 1,
@@ -857,7 +856,7 @@ console.log(matchdata);
             return;
         }
 
-        function setScore_v2_bq(orderObj, resultObj,order_id,match_id,game_code) {
+        function __setScore_v2_bq(orderObj, resultObj,order_id,match_id,game_code) {
             let match_score = JSON.parse(resultObj.match_score_t);
 
             let content = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' +
@@ -930,6 +929,78 @@ console.log(matchdata);
 
             return ;
         }
+        function setScore_v2_bq(orderObj, resultObj,order_id,match_id,game_code,ScoreTitle,leagueName,home_team,guest_team) {
+            let match_score = JSON.parse(resultObj.match_score_t);
+
+            //主队比分
+            var home_score;
+            //客队比分
+            var guest_score;
+            //全场
+            if(ScoreTitle == '全场'){
+                for (let i=1;i<=9;i++){
+                    home_score += match_score[i]['home'];
+                    guest_score += match_score[i]['guest'];
+                }
+            }
+            //上半场
+            if(ScoreTitle == '前五局'){
+                for (let i=1;i<=5;i++){
+                    home_score += match_score[i]['home'];
+                    guest_score += match_score[i]['guest'];
+                }
+            }
+
+            let content = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' ;
+
+                content += '  <div class="layui-inline" style="width: -webkit-fill-available;height: 80px;">' +
+                        '    <label class="layui-form-label" style="text-align:center;width: -webkit-fill-available;height: 25px;">'+leagueName+'</label><br></br>' +
+                        '    <label class="layui-form-label"  style="width:200px;">'+resultObj.home_team+'-('+ScoreTitle+')</label>' +
+                        '    <div class="layui-input-inline" style="width: 50px;">' +
+                        '      <input type="text" name="set_zq_home_score" id="set_bq_home_score" placeholder="主"  value="' + home_score +'"  required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '    <label class="layui-form-label"  style="width:200px;">'+resultObj.guest_team+'-('+ScoreTitle+')</label>' +
+                        '    <div class="layui-input-inline" style="width: 50px;">' +
+                        '      <input type="text" name="set_zq_home_score" id="set_bq_guest_score" placeholder="主"  value="' + home_score +'"  required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '  </div>' ;
+
+            layer.open({
+                area: ['800px', '300px'], //宽高
+                type: 1,
+                title: '设置比分',
+                content: content, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响,
+                btn: ['提交', '取消'],
+                yes: function (index, layero) {
+                    var home = $("#set_bq_home_score").val();
+                    var guest = $("#set_bq_guest_score").val();
+
+                    let home_scores=[],guest_scores=[],str_home,str_guest,i;
+                    for (i=0;i<=8;i++){
+                        str_home = '#set_bq_home_score_'+(i+1);
+                        str_guest = '#set_bq_guest_score_'+(i+1);
+                        home_scores.push($(str_home).val());
+                        guest_scores.push($(str_guest).val());
+                        //home_scores[i] = $(str_home).val();
+                        //guest_scores[i] = $(str_guest).val();
+                        //console.log(home_scores[i],guest_scores[i]);
+                    }
+
+                    matchdata = JSON.stringify({
+                        'home':home_scores,
+                        'guest':guest_scores,
+                        'home_other':$("#set_bq_home_score_ext").val(),
+                        'guest_other':$("#set_bq_guest_score_ext").val(),
+                    });
+
+                    // 请求设置接口
+                    ajax_setScore_all_v2(order_id,game_code,match_id,matchdata,ScoreTitle,home,guest);
+                    return true;
+                },
+            });
+
+            return ;
+        }
 
         function setScore_v2_wq(orderObj, resultObj,order_id,match_id,game_code) {
             let match_score = JSON.parse(resultObj.inning);