彭俊 6 лет назад
Родитель
Сommit
d0c6e1e707

+ 217 - 4
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -1260,13 +1260,17 @@ class SoccerNoteListController extends Controller
     }
 
 
-//单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
-    public function manualmatchpdate_v2(Req $req)
+//单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算 
+    public function ___manualmatchpdate_v2(Req $req)
     {
         $order_id = isset($req->order_id) ? $req->order_id : 0;
         $game_code = isset($req->game_code) ? $req->game_code : 0;
         $match_id = isset($req->match_id) ? $req->match_id : 0;
         $pdatas = isset($req->matchdata) ? $req->matchdata : [];
+        $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : '';//进程
+        $home_sorce = isset($req->home) ? $req->home : '';//主队比分
+        $guest_sorce = isset($req->guest) ? $req->guest : '';//客队比分
+
         $pdatas = json_decode($pdatas, true);
         if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
             return responseToJson(0, '参数错误');
@@ -1439,12 +1443,217 @@ class SoccerNoteListController extends Controller
 
     }
 
+    //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算 
+    public function manualmatchpdate_v2(Req $req)
+    {
+        $order_id = isset($req->order_id) ? $req->order_id : 0;
+        $game_code = isset($req->game_code) ? $req->game_code : 0;
+        $match_id = isset($req->match_id) ? $req->match_id : 0;
+        $pdatas = isset($req->matchdata) ? $req->matchdata : [];
+        $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : '';//进程
+        $home_sorce = isset($req->home) ? $req->home : '';//主队比分
+        $guest_sorce = isset($req->guest) ? $req->guest : '';//客队比分
+
+        $pdatas = json_decode($pdatas, true);
+        if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
+            return responseToJson(0, '参数错误');
+        }
+        if(in_array(-1,$pdatas)){
+            return responseToJson(-1, '输入比分错误');
+        }
+
+        $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first();
+        if (empty($buyModel)) {
+            return responseToJson(0, '订单数据错误');
+        }
+
+        $restModel = '';
+        switch ($game_code) {
+            case 'zq':
+                $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+            case 'lq':
+                $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+            case 'wq':
+                $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+            case 'bq':
+                $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+        }
+        if (empty($restModel)) {
+            return responseToJson(0, '赛事结果记录没有找到,数据错误');
+        }
+
+        if ($game_code == 'zq') {
+            if($ScoreTitle == '上半'){
+                //替换上半场比分
+                $restModel->u_home_score = $home_sorce;
+                $restModel->u_guest_score = $guest_sorce;
+            }
+            if($ScoreTitle == '全场'){
+                //替换全场比分
+                $restModel->home_score = $home_sorce;
+                $restModel->guest_score = $guest_sorce;
+            }
+            if($ScoreTitle == '角球上半'){
+                //获取角球数据 arr  {"home":0,"guest":0,"home_half":0,"guest_half":0}
+                $corner_arr = json_decode($restModel->corner_ball,256);
+                //替换上半场角球比分
+                $corner_arr['home_half'] = $home_sorce;
+                $corner_arr['guest_half'] = $guest_sorce;
+
+                $restModel->corner_ball = json_encode($corner_arr);
+            }
+            if($ScoreTitle == '角球全场'){
+                //获取角球数据 arr  {"home":0,"guest":0,"home_half":0,"guest_half":0}
+                $corner_arr = json_decode($restModel->corner_ball,256);
+                //替换全场角球比分
+                $corner_arr['home'] = $home_sorce;
+                $corner_arr['guest'] = $guest_sorce;
+
+                $restModel->corner_ball = json_encode($corner_arr);
+            }
+          
+            $restModel->corner_ball = json_decode($restModel->corner_ball, 256);
+            $restModel->penalty_card = json_decode($restModel->penalty_card, 256);
+            $restModel->first_score = json_decode($restModel->first_score, 256);
+            $restModel->warn_more = json_decode($restModel->warn_more, 256);
+
+            $buyModel->single_result = json_encode([$restModel], 256);
+
+            $buyModel->result_flag = 1;
+            $buyModel->is_manual = 1;
+            $ret = $buyModel->save();
+
+            if ($ret) {
+                $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
+
+                if ($ret2['status'] == 1) {
+                    return responseToJson(1, '操作成功!');
+                } else {
+                    return responseToJson(0, '操作失败2!--' . $ret2['data']);
+                }
+            }
+            return responseToJson(0, '更新失败1');
+        }
+
+        if ($game_code == 'lq') {
+            $home = $pdatas['home'];
+            $guest = $pdatas['guest'];
+
+            $restModel->home_score = ['1' => intval($home['0']), '2' => intval($home['1']), '3' => intval($home['2']), '4' => intval($home['3'])];
+            $restModel->guest_score = ['1' => intval($guest['0']), '2' => intval($guest['1']), '3' => intval($guest['2']), '4' => intval($guest['3'])];
+            $restModel->u_home_score = intval($home['0']) + intval($home['1']);
+            $restModel->u_guest_score = intval($guest['0']) + intval($guest['1']);
+
+            $all_home = intval($home['0']) + intval($home['1']) + intval($home['2']) + intval($home['3']);
+            $all_guest = intval($guest['0']) + intval($guest['1']) + intval($guest['2']) + intval($guest['3']);
+            $restModel->all_goal = $all_home + $all_guest;
+            $restModel->match_score = $all_home . ':' . $all_guest;
+            $restModel->match_winer = $all_home > $all_guest ? $restModel->home_team : $restModel->guest_team;
+            $restModel->warn_more = json_decode($restModel->warn_more, 256);
+
+            $buyModel->single_result = json_encode([$restModel], 256);
+            $buyModel->result_flag = 1;
+            $buyModel->is_manual = 1;
+            $ret = $buyModel->save();
+
+            if ($ret) {
+                $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
+                if ($ret2['status'] == 1) {
+                    return responseToJson(1, '操作成功!');
+                } else {
+                    return responseToJson(0, '操作失败2!--' . $ret2['data']);
+                }
+            }
+            return responseToJson(0, '更新失败1');
+        }
+
+        if ($game_code == 'bq') {
+            $home = $pdatas['home'];
+            $guest = $pdatas['guest'];
+            $home_other = $pdatas['home_other'];
+            $guest_other = $pdatas['guest_other'];
+
+            $arrs = [];
+            for ($i = 0; $i <= 8; $i++) {
+                $j = $i + 1;
+                $arrs[$j] = [
+                    'home' => intval($home[$i]),
+                    'guest' => intval($guest[$i]),
+                ];
+            }
+            $arrs['other'] = [
+                'home' => intval($home_other),
+                'guest' => intval($guest_other),
+            ];
+
+            $restModel->match_score_t = $arrs;
+            $restModel->warn_more = json_decode($restModel->warn_more, 256);
+
+            $buyModel->single_result = json_encode([$restModel], 256);
+            $buyModel->result_flag = 1;
+            $buyModel->is_manual = 1;
+            $ret = $buyModel->save();
+
+            if ($ret) {
+                $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
+                if ($ret2['status'] == 1) {
+                    return responseToJson(1, '操作成功!');
+                } else {
+                    return responseToJson(0, '操作失败2!--' . $ret2['data']);
+                }
+            }
+            return responseToJson(0, '更新失败1');
+        }
+
+        if ($game_code == 'wq') {
+            $home = $pdatas['home'];
+            $guest = $pdatas['guest'];
+
+            $arrs = [];
+            for ($i = 0; $i <= 4; $i++) {
+                $j = $i + 1;
+                $arrs[$j] = [
+                    'home' => intval($home[$i]),
+                    'guest' => intval($guest[$i]),
+                ];
+            }
+
+            $restModel->inning = $arrs;
+            $restModel->warn_more = json_decode($restModel->warn_more, 256);
+
+            $buyModel->single_result = json_encode([$restModel], 256);
+            $buyModel->result_flag = 1;
+            $buyModel->is_manual = 1;
+            $ret = $buyModel->save();
+
+            if ($ret) {
+                $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
+                if ($ret2['status'] == 1) {
+                    return responseToJson(1, '操作成功!');
+                } else {
+                    return responseToJson(0, '操作失败2!--' . $ret2['data']);
+                }
+            }
+            return responseToJson(0, '更新失败1');
+        }
+
+
+        return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
+
+    }
+
     //修复比分时用到订单信息及比赛结果数据
     public function manualmatchget_v2(Req $req)
     {
         $order_id = isset($req->order_id) ? $req->order_id : 0;
+        $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : 0;
+
         $model = new  MoneyBuySimplexModel();
-        $ret = $model->OrderinfoResult($order_id);
+        $ret = $model->OrderinfoResult($order_id,$ScoreTitle);
         if ($ret && !empty($ret['result'])) {
             return responseToJson(1, '成功', $ret);
         } else {
@@ -1520,9 +1729,13 @@ class SoccerNoteListController extends Controller
         return $data;
     }
 
+    //获取球类分类下的父级玩法数据
     public function getpcode(){
         $game_type = $_GET["game_type"];
-        $p_code =  \App\Models\StoddsCode::where('p_id',0)->where('game_code',$game_type)->get();
+
+        $pcode = new  \App\Models\StoddsCode();
+        $p_code = $pcode->getpcode($game_type);
+
         return json_encode($p_code);
     }
 

+ 59 - 39
app/Http/Controllers/Admin/SportsbkController.php

@@ -227,50 +227,70 @@ class SportsbkController extends Controller {
 		$simplex_ids = array_column($newapp->allsimplexorder($match_id,'lq'),'order_id');
 		$str_ids = array_column($newapp->allstrorder($match_id),'order_id');
 
+		//判断赛事下注单输赢
+		$datas = array('noticeid' => $noticeid , 'token' => $token);
+		$settlementAuto = new \App\Lib\Settlement\SettlementAuto();
+		$winfail = $settlementAuto->SubmitSettelement('w',$datas);
+		if($winfail == false){
+			return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);//输赢错误
+		}
+		$sim = array(
+			'token'=>$token,
+			'order_ids'=>'', //订单id字符串,用半角都好分隔
+			'bettype'=>1, //结算类型  1单式  2串式
+			'settype'=>2, //结算次数  1首次  2非首冷饮
+			'game_code'=>$type, //赛事类型  zq lq wq bq
+			'match_id'=>$match_id,  // 赛事ID
+			'change_status'=>1  //是否改状态
+		);
+		$str = array(
+			'token'=>$token,
+			'order_ids'=>'', //订单id字符串,用半角都好分隔
+			'bettype'=>2, //结算类型  1单式  2串式
+			'settype'=>2, //结算次数  1首次  2非首冷饮
+			'game_code'=>$type, //赛事类型  zq lq wq bq
+			'match_id'=>$match_id,  // 赛事ID
+			'change_status'=>1  //是否改状态
+		);
 		if(count($simplex_ids)>0 || count($str_ids)>0){
-			$requet = file_get_contents($jsurl."/WinFail?noticeid=".$noticeid."&token=".$token);
-			
-			if(json_decode($requet,true)['status']==1){
-			    $napp = new \App\Models\Stzqresult();
-				//单式结算
-				if(count($simplex_ids)>0 && count($str_ids)==0){
-					$huawei_res = $napp->simplexs($token,$match_id,$jsurl,'lq');
-					
-					if($huawei_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'单式结算有误,请联系管理员!!!('.$huawei_res['msg'].')']);//结算错误
-					}
-				}elseif(count($str_ids)>0 && count($simplex_ids)==0){
-					//串式结算
-					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'lq');
-
-					if($tandem_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'串式结算有误,请联系管理员!!!('.$tandem_res['msg'].')']);//结算错误
-					}
-				}elseif(count($str_ids)>0 && count($simplex_ids)>0){
-					//既有单式又有串式
-					$huawei_res = $napp->simplexs($token,$match_id,$jsurl,'lq');
-
-					//串式结算
-					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'lq');
-					if($tandem_res['status']==1 && $huawei_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'结算成功']); 
-					}elseif($tandem_res['status']!=1 || $huawei_res['status']!=1){
-						return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!('.$tandem_res['msg'].$huawei_res['msg'].')']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'返回参数不对']); 
-					}
+			//单式结算
+			if(count($simplex_ids)>0 && count($str_ids)==0){
+				$sim['order_ids'] = implode(',',$simplex_ids);
+				$settlesim = $settlementAuto->SubmitSettelement('s',$sim);
+				if($settlesim == false){
+					return json_encode(['status'=>3,'msg'=>'单式注单结算有误,请联系管理员!!!']);
+				}else{
+					return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
+				}
+			}
+			elseif(count($str_ids)>0 && count($simplex_ids)==0){
+				$str['order_ids'] = implode(',',$str_ids);
+				$settlestr = $settlementAuto->SubmitSettelement('s',$str);
+				if($settlestr == false){
+					return json_encode(['status'=>3,'msg'=>'串式注单结算有误,请联系管理员!!!']);
+				}else{
+					return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
+				}
+			}
+			elseif(count($str_ids)>0 && count($simplex_ids)>0){
+				$sim['order_ids'] = implode(',',$simplex_ids);
+				$str['order_ids'] = implode(',',$str_ids);
+				$settlesim = $settlementAuto->SubmitSettelement('s',$sim);
+				$settlestr = $settlementAuto->SubmitSettelement('s',$str);
+				if($settlesim == true || $settlestr == true){
+					return json_encode(['status'=>1,'msg'=>'结算成功']);
+				}else{
+					return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!']);
 				}
-			}else{
-				return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);;//输赢错误
 			}
 		}else{
+			$log = array(
+				session('adminInfo.admin_name'),
+			);
+			OperationLog(session('adminInfo.admin_id'), '篮球结算', $log);
 			$res = \App\Models\Stlqresult::where ('match_id', $match_id)->update(['status' =>3]);
-			$res = \App\Models\SportsBasket::where ('match_id', $match_id)->update(['status' =>3]);
-            return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
+			$res = \App\Models\SportsBasket::where ('id', $match_id)->update(['status' =>3]);
+			return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
 		}
 	}
 

+ 60 - 40
app/Http/Controllers/Admin/SportsbqController.php

@@ -137,55 +137,75 @@ class SportsbqController extends Controller {
 		if(!$notice){
 			return json_encode(['status'=>5,'msg'=>'请先核对结果,并提交结果']);
 		}
-		//查询赛事单式是否有订单(球)
+		//查询赛事单式是否有订单(球)
 		$newapp = new \App\Models\MoneyBuyMatch();
 		$simplex_ids = array_column($newapp->allsimplexorder($match_id,'bq'),'order_id');
 		$str_ids = array_column($newapp->allstrorder($match_id),'order_id');
 
+		//判断赛事下注单输赢
+		$datas = array('noticeid' => $noticeid , 'token' => $token);
+		$settlementAuto = new \App\Lib\Settlement\SettlementAuto();
+		$winfail = $settlementAuto->SubmitSettelement('w',$datas);
+		if($winfail == false){
+			return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);//输赢错误
+		}
+		$sim = array(
+			'token'=>$token,
+			'order_ids'=>'', //订单id字符串,用半角都好分隔
+			'bettype'=>1, //结算类型  1单式  2串式
+			'settype'=>2, //结算次数  1首次  2非首冷饮
+			'game_code'=>$type, //赛事类型  zq lq wq bq
+			'match_id'=>$match_id,  // 赛事ID
+			'change_status'=>1  //是否改状态
+		);
+		$str = array(
+			'token'=>$token,
+			'order_ids'=>'', //订单id字符串,用半角都好分隔
+			'bettype'=>2, //结算类型  1单式  2串式
+			'settype'=>2, //结算次数  1首次  2非首冷饮
+			'game_code'=>$type, //赛事类型  zq lq wq bq
+			'match_id'=>$match_id,  // 赛事ID
+			'change_status'=>1  //是否改状态
+		);
 		if(count($simplex_ids)>0 || count($str_ids)>0){
-			$requet = file_get_contents($jsurl."/WinFail?noticeid=".$noticeid."&token=".$token);
-			
-			if(json_decode($requet,true)['status']==1){
-				$napp = new \App\Models\Stzqresult();
-				//单式结算
-				if(count($simplex_ids)>0 && count($str_ids)==0){
-					$huawei_res = $napp->simplexs($token,$match_id,$jsurl,'bq');
-					
-					if($huawei_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'单式结算有误,请联系管理员!!!('.$huawei_res['msg'].')']);//结算错误
-					}
-				}elseif(count($str_ids)>0 && count($simplex_ids)==0){
-					//串式结算
-					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'bq');
-
-					if($tandem_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'串式结算有误,请联系管理员!!!('.$tandem_res['msg'].')']);//结算错误
-					}
-				}elseif(count($str_ids)>0 && count($simplex_ids)>0){
-					//既有单式又有串式
-					$huawei_res = $napp->simplexs($token,$match_id,$jsurl,'bq');
-
-					//串式结算
-					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'bq');
-					if($tandem_res['status']==1 && $huawei_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'结算成功']); 
-					}elseif($tandem_res['status']!=1 || $huawei_res['status']!=1){
-						return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!('.$tandem_res['msg'].$huawei_res['msg'].')']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'返回参数不对']); 
-					}
+			//单式结算
+			if(count($simplex_ids)>0 && count($str_ids)==0){
+				$sim['order_ids'] = implode(',',$simplex_ids);
+				$settlesim = $settlementAuto->SubmitSettelement('s',$sim);
+				if($settlesim == false){
+					return json_encode(['status'=>3,'msg'=>'单式注单结算有误,请联系管理员!!!']);
+				}else{
+					return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
+				}
+			}
+			elseif(count($str_ids)>0 && count($simplex_ids)==0){
+				$str['order_ids'] = implode(',',$str_ids);
+				$settlestr = $settlementAuto->SubmitSettelement('s',$str);
+				if($settlestr == false){
+					return json_encode(['status'=>3,'msg'=>'串式注单结算有误,请联系管理员!!!']);
+				}else{
+					return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
+				}
+			}
+			elseif(count($str_ids)>0 && count($simplex_ids)>0){
+				$sim['order_ids'] = implode(',',$simplex_ids);
+				$str['order_ids'] = implode(',',$str_ids);
+				$settlesim = $settlementAuto->SubmitSettelement('s',$sim);
+				$settlestr = $settlementAuto->SubmitSettelement('s',$str);
+				if($settlesim == true || $settlestr == true){
+					return json_encode(['status'=>1,'msg'=>'结算成功']);
+				}else{
+					return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!']);
 				}
-			}else{
-				return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);;//输赢错误
 			}
 		}else{
+			$log = array(
+				session('adminInfo.admin_name'),
+			);
+			OperationLog(session('adminInfo.admin_id'), '棒球结算', $log);
 			$res = \App\Models\Stbqresult::where ('match_id', $match_id)->update(['status' =>3]);
-			$res = \App\Models\SportsBase::where ('match_id', $match_id)->update(['status' =>3]);
-            return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
+			$res = \App\Models\SportsBase::where ('id', $match_id)->update(['status' =>3]);
+			return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
 		}
 	}
 

+ 1 - 2
app/Http/Controllers/Admin/SportsfootController.php

@@ -38,7 +38,6 @@ class SportsfootController extends Controller {
 		if($winfail == false){
 			return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);//输赢错误
 		}
-		//print_r(implode(',',$simplex_ids));exit;
 		$sim = array(
 			'token'=>$token,
 			'order_ids'=>'', //订单id字符串,用半角都好分隔
@@ -561,7 +560,7 @@ class SportsfootController extends Controller {
 			$array[] = $key['guest'];
 		}
 		//赛事下注单作废 处理
-			commonFunction::HandleInvalid($data,$match_id,$match_status,'zq');
+		commonFunction::HandleInvalid($data,$match_id,$match_status,'zq');
 
 		$penaltycard = array(
         	'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,

+ 60 - 40
app/Http/Controllers/Admin/SportswqController.php

@@ -148,55 +148,75 @@ class SportswqController extends Controller {
 		if(!$notice){
 			return json_encode(['status'=>5,'msg'=>'请先核对结果,并提交结果']);
 		}
-		//查询赛事单式是否有订单(球)
+		//查询赛事单式是否有订单(球)
 		$newapp = new \App\Models\MoneyBuyMatch();
 		$simplex_ids = array_column($newapp->allsimplexorder($match_id,'wq'),'order_id');
 		$str_ids = array_column($newapp->allstrorder($match_id),'order_id');
 
+		//判断赛事下注单输赢
+		$datas = array('noticeid' => $noticeid , 'token' => $token);
+		$settlementAuto = new \App\Lib\Settlement\SettlementAuto();
+		$winfail = $settlementAuto->SubmitSettelement('w',$datas);
+		if($winfail == false){
+			return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);//输赢错误
+		}
+		$sim = array(
+			'token'=>$token,
+			'order_ids'=>'', //订单id字符串,用半角都好分隔
+			'bettype'=>1, //结算类型  1单式  2串式
+			'settype'=>2, //结算次数  1首次  2非首冷饮
+			'game_code'=>$type, //赛事类型  zq lq wq bq
+			'match_id'=>$match_id,  // 赛事ID
+			'change_status'=>1  //是否改状态
+		);
+		$str = array(
+			'token'=>$token,
+			'order_ids'=>'', //订单id字符串,用半角都好分隔
+			'bettype'=>2, //结算类型  1单式  2串式
+			'settype'=>2, //结算次数  1首次  2非首冷饮
+			'game_code'=>$type, //赛事类型  zq lq wq bq
+			'match_id'=>$match_id,  // 赛事ID
+			'change_status'=>1  //是否改状态
+		);
 		if(count($simplex_ids)>0 || count($str_ids)>0){
-			$requet = file_get_contents($jsurl."/WinFail?noticeid=".$noticeid."&token=".$token);
-			
-			if(json_decode($requet,true)['status']==1){
-			    $napp = new \App\Models\Stzqresult();
-				//单式结算
-				if(count($simplex_ids)>0 && count($str_ids)==0){
-					$huawei_res = $napp->simplexs($token,$match_id,$jsurl,'wq');
-					
-					if($huawei_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'单式结算有误,请联系管理员!!!('.$huawei_res['msg'].')']);//结算错误
-					}
-				}elseif(count($str_ids)>0 && count($simplex_ids)==0){
-					//串式结算
-					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'wq');
-
-					if($tandem_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'串式结算有误,请联系管理员!!!('.$tandem_res['msg'].')']);//结算错误
-					}
-				}elseif(count($str_ids)>0 && count($simplex_ids)>0){
-					//既有单式又有串式
-					$huawei_res = $napp->simplexs($token,$match_id,$jsurl,'wq');
-
-					//串式结算
-					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'wq');
-					if($tandem_res['status']==1 && $huawei_res['status']==1){
-						return json_encode(['status'=>1,'msg'=>'结算成功']); 
-					}elseif($tandem_res['status']!=1 || $huawei_res['status']!=1){
-						return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!('.$tandem_res['msg'].$huawei_res['msg'].')']);
-					}else{
-						return json_encode(['status'=>3,'msg'=>'返回参数不对']); 
-					}
+			//单式结算
+			if(count($simplex_ids)>0 && count($str_ids)==0){
+				$sim['order_ids'] = implode(',',$simplex_ids);
+				$settlesim = $settlementAuto->SubmitSettelement('s',$sim);
+				if($settlesim == false){
+					return json_encode(['status'=>3,'msg'=>'单式注单结算有误,请联系管理员!!!']);
+				}else{
+					return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
+				}
+			}
+			elseif(count($str_ids)>0 && count($simplex_ids)==0){
+				$str['order_ids'] = implode(',',$str_ids);
+				$settlestr = $settlementAuto->SubmitSettelement('s',$str);
+				if($settlestr == false){
+					return json_encode(['status'=>3,'msg'=>'串式注单结算有误,请联系管理员!!!']);
+				}else{
+					return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
+				}
+			}
+			elseif(count($str_ids)>0 && count($simplex_ids)>0){
+				$sim['order_ids'] = implode(',',$simplex_ids);
+				$str['order_ids'] = implode(',',$str_ids);
+				$settlesim = $settlementAuto->SubmitSettelement('s',$sim);
+				$settlestr = $settlementAuto->SubmitSettelement('s',$str);
+				if($settlesim == true || $settlestr == true){
+					return json_encode(['status'=>1,'msg'=>'结算成功']);
+				}else{
+					return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!']);
 				}
-			}else{
-				return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);;//输赢错误
 			}
 		}else{
+			$log = array(
+				session('adminInfo.admin_name'),
+			);
+			OperationLog(session('adminInfo.admin_id'), '网球结算', $log);
 			$res = \App\Models\Stwqresult::where ('match_id', $match_id)->update(['status' =>3]);
-			$res = \App\Models\SportsTennis::where ('match_id', $match_id)->update(['status' =>3]);
-            return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
+			$res = \App\Models\SportsTennis::where ('id', $match_id)->update(['status' =>3]);
+			return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
 		}
 	}
 

+ 32 - 32
app/Lib/Biz/Sport/Common.php

@@ -1411,41 +1411,41 @@ class Common
         $upapp = new \App\Models\SportsNoteList();
         $upapp->settleorder($match_id,$oddsData_sim_settle,$oddsData_str_settle,$game_code);
 
-		//如果是已结算赛事 
+		//如果是已结算赛事
 //		if($match_status == 3){
-//			//合并上半场/全场 待处理 单式+串式订单
-//			$oddsData = array_merge($oddsData_sim,$oddsData_str);
-//			//去重
-//            $oddsData = self::uniquArrV2($oddsData,'order_id');
-//
-//            if(count($oddsData) > 0){
-//                $url = 'http://stadmin.bocai108.com:9094/UnsetOneOrder';
-//                $data_up = [
-//                    'token'=>session('adminInfo.token'),
-//                    'game_code'=>$game_code,
-//                    'match_id'=>$match_id,
-//                ];
-//
-//                //返回请求状态码
-//                $set_status = [];
-//                foreach($oddsData as $k=>$v){
-//                    $data_up['order_id'] = $v['order_id'];
-//                    $ret_json = self::https_request($url,$data_up);
-//                    $ret_arr = json_decode($ret_json,true);
-//                    $set_status[] = $ret_arr['status'];
-//                }
-//                //如果返回结果中有 0,则返回失败
-//                if(in_array(0,$set_status)){
-//                    return responseToJson(-20003);
-//                }
-//            }
+			//合并上半场/全场 待处理 单式+串式订单
+			$oddsData = array_merge($oddsData_sim,$oddsData_str);
+			//去重
+            $oddsData = self::uniquArrV2($oddsData,'order_id');
+
+            if(count($oddsData) > 0){
+                $url = 'http://stadmin.bocai108.com:9094/UnsetOneOrder';
+                $data_up = [
+                    'token'=>session('adminInfo.token'),
+                    'game_code'=>$game_code,
+                    'match_id'=>$match_id,
+                ];
+
+                //返回请求状态码
+                $set_status = [];
+                foreach($oddsData as $k=>$v){
+                    $data_up['order_id'] = $v['order_id'];
+                    $ret_json = self::https_request($url,$data_up);
+                    $ret_arr = json_decode($ret_json,true);
+                    $set_status[] = $ret_arr['status'];
+                }
+                //如果返回结果中有 0,则返回失败
+                if(in_array(0,$set_status)){
+                    return responseToJson(-20003);
+                }
+            }
 //		}else{
             //赛事 处理 下单式注单作废,串关注单下此赛事按平局处理
-            if(count($oddsData_str) > 0){
-                $oddsData_str = $oddsData_str;
-            }
-            $type = 1;
-			$upapp->delorder($match_id,$game_code,$oddsData_sim,$oddsData_str,$type);
+//            if(count($oddsData_str) > 0){
+//                $oddsData_str = $oddsData_str;
+//            }
+//            $type = 1;
+//			$upapp->delorder($match_id,$game_code,$oddsData_sim,$oddsData_str,$type);
 		//}
 		//=== end ===
 	}

+ 9 - 2
app/Models/MoneyBuySimplex.php

@@ -17,14 +17,18 @@ class MoneyBuySimplex extends BaseModel
 
 
     //单式订单数据及比赛结果数据
-    public function OrderinfoResult($order_id)
+    public function OrderinfoResult($order_id,$ScoreTitle='')
     {
         $Ordermodel = $this->where('order_id', $order_id)->first();
         if (empty($Ordermodel)) {
             return false;
         }
-        $odds_code = \App\Models\MoneyBuyMatch::where('batch_id',$Ordermodel->batch_id)->first();
+        // $odds_code = \App\Models\MoneyBuyMatch::where('batch_id',$Ordermodel->batch_id)->first();
+        $odds_code = \App\Models\MoneyBuyMatch::where('order_id',$order_id)->first();
+
+
         $Ordermodel->odds_code = $odds_code->odds_code;
+      
         $game_code = $Ordermodel->game_code;
         $match_id = $Ordermodel->match_id;
 
@@ -52,6 +56,9 @@ class MoneyBuySimplex extends BaseModel
             $resultsModel['result'] = '';
         }
 
+        //处理足球角球数据
+        $corner_ball_json = $resultModel->corner_ball;
+
         return [
             'order' => $Ordermodel,
             'result' => $resultModel,

+ 7 - 7
app/Models/SportsNoteList.php

@@ -215,12 +215,12 @@ class SportsNoteList extends BaseModel
                 $function = 'setScore_v2';
             }
             
-            /*
             //获取 投注玩法名称
             $odds_name = $contentData['odds_name'];
             //根据球类/玩法名称 获取需设置比分项 
             $ScoreTitle = $this->getScoreTitle($odds_name,$type);
 
+            /*
             //操作
             //未结算时 加载结算按钮
             if($v->status==1 and $v->settle_status ==1){
@@ -250,10 +250,10 @@ class SportsNoteList extends BaseModel
             */
 
             //操作 按钮
-            //投注/未结算 则有结算/作废 按钮
+            //投注/未结算 则有结算/作废 按钮  
             if($v->status==1 and $v->settle_status ==1){
                 $v->game_status = '
-                <button style="margin-left: 0;" onclick="'.$function.'(\'' . $v->order_id . '\',\''.$v->match_id.'\',\''.$type.'\')"  class="layui-btn layui-btn-sm settlement">手动结算</button>
+                <button style="margin-left: 0;" onclick="'.$function.'(\'' . $v->order_id . '\',\''.$v->match_id.'\',\''.$type.'\',\''.$ScoreTitle.'\',\''.$v->league.'\',\''.$v->home_team.'\',\''.$v->guest_team.'\')"  class="layui-btn layui-btn-sm settlement">手动结算</button>
                 <br>
                 <a class="layui-btn layui-btn-sm invalid" style="background-color:red" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $v->id . '\',\''.$v->order_id.'\',\''.$v->league.'\');"> 作废 </a>';
             }
@@ -287,19 +287,19 @@ class SportsNoteList extends BaseModel
             $ScoreTitle_c = commonFunction::checkstr($oddsName,'角球');
             //有上半场 无角球 为上半场比分
             if($ScoreTitle_h == 1 and $ScoreTitle_c == 0){
-                $ScoreTitle = '上半场比分';
+                $ScoreTitle = '上半';
             }
             //有上半场 有角球 为角球上半场比分
             if($ScoreTitle_h == 1 and $ScoreTitle_c == 1){
-                $ScoreTitle = '角球上半场比分';
+                $ScoreTitle = '角球上半';
             }
             //有全场 无角球 为全场比分
             if($ScoreTitle_f == 1 and $ScoreTitle_c == 0){
-                $ScoreTitle = '全场比分';
+                $ScoreTitle = '全场';
             }
             //有全场 有角球 为角球全场比分
             if($ScoreTitle_f == 1 and $ScoreTitle_c == 1){
-                $ScoreTitle = '角球全场比分';
+                $ScoreTitle = '角球全场';
             }
         }
 

+ 12 - 0
app/Models/StoddsCode.php

@@ -1,6 +1,8 @@
 <?php
 
 namespace App\Models;
+
+use App\Lib\Biz\Sport\Common as commonFunction;
 /**
  *
  */
@@ -39,6 +41,16 @@ class StoddsCode extends BaseModel
         }
     }
 
+    //根据分类获取各球类父级玩法数据
+    public function getpcode($game_type){
+        //获取球类父级玩法代码
+        $pcode = commonFunction::getOddsPcode($game_type);
+
+        $p_code =  $this->where('p_id',0)->where('game_code',$game_type)->wherein('odds_code',$pcode)->get();
+
+        return $p_code;
+    }
+
 }
 
 ?>

+ 2 - 2
resources/views/admin/Sportsbq/outcome.blade.php

@@ -66,10 +66,10 @@
         <a href="javascript:;" onclick="resultLog(@{{d.match_id}})" class="layui-btn layui-btn-sm">比分记录</a>
         @{{#if(d.status==2 || d.status==3){ }}
             @{{#if(d.status==2){ }}
-                <a href="javascript:;" onclick="settlement(@{{d.match_id}},1)" class="layui-btn layui-btn-sm">结算</a>
+                <a href="javascript:;" onclick="settlement(@{{d.match_id}},'bq')" class="layui-btn layui-btn-sm">结算</a>
             @{{#} }}
             @{{#if(d.status==3){ }}
-                <a href="javascript:;" onclick="settlement(@{{d.match_id}},2)" class="layui-btn layui-btn-sm">再结算</a>
+                <a href="javascript:;" onclick="settlement(@{{d.match_id}},'bq')" class="layui-btn layui-btn-sm">再结算</a>
             @{{#} }}
         @{{#} }}
         <!--

+ 2 - 2
resources/views/admin/Sportswq/outcome.blade.php

@@ -57,10 +57,10 @@
         <a href="javascript:;" onclick="addResult(@{{d.match_id}})" class="layui-btn layui-btn-sm">赛事结果</a>
         @{{#if(d.status==2 || d.status==3){ }}
             @{{#if(d.status==2){ }}
-                <a href="javascript:;" onclick="settlement(@{{d.match_id}},1)" class="layui-btn layui-btn-sm">结算</a>
+                <a href="javascript:;" onclick="settlement(@{{d.match_id}},'wq')" class="layui-btn layui-btn-sm">结算</a>
             @{{#} }}
             @{{#if(d.status==3){ }}
-                <a href="javascript:;" onclick="settlement(@{{d.match_id}},2)" class="layui-btn layui-btn-sm">再结算</a>
+                <a href="javascript:;" onclick="settlement(@{{d.match_id}},'wq')" class="layui-btn layui-btn-sm">再结算</a>
             @{{#} }}
         @{{#} }}
         <!--

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

@@ -168,10 +168,10 @@
         <a href="javascript:;" onclick="resultLog(@{{d.match_id}})" class="layui-btn layui-btn-sm">比分记录</a>
         @{{#if(d.status==2 || d.status==3){ }}
             @{{#if(d.status==2){ }}
-                <a href="javascript:;" onclick="lqsettlement(@{{d.match_id}},1)" class="layui-btn layui-btn-sm">结算</a>
+                <a href="javascript:;" onclick="lqsettlement(@{{d.match_id}},'lq')" class="layui-btn layui-btn-sm">结算</a>
             @{{#} }}
             @{{#if(d.status==3){ }}
-                <a href="javascript:;" onclick="lqsettlement(@{{d.match_id}},2)" class="layui-btn layui-btn-sm">再结算</a>
+                <a href="javascript:;" onclick="lqsettlement(@{{d.match_id}},'lq')" class="layui-btn layui-btn-sm">再结算</a>
             @{{#} }}
         @{{#} }}
         <!--

+ 76 - 6
resources/views/sports/sports_notelist.blade.php

@@ -545,13 +545,13 @@
 
 
         // 设置结算比分
-        function setScore_v2(order_id, match_id, game_code) {
-            $.getJSON("/admin/SoccerNoteList/manualmatchget_v2", {'order_id': order_id}, function (res) {
+        function setScore_v2(order_id, match_id, game_code,ScoreTitle,leagueName,home_team,guest_team) {
+            $.getJSON("/admin/SoccerNoteList/manualmatchget_v2", {'order_id': order_id,'ScoreTitle':ScoreTitle}, function (res) {
                 if (1 == res.status) {
                     //console.log(res);
                     switch (game_code) {
                         case 'zq':
-                            setScore_v2_zq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
+                            setScore_v2_zq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code,ScoreTitle,leagueName,home_team,guest_team);
                             break;
                         case 'lq':
                             setScore_v2_lq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
@@ -593,8 +593,78 @@
             });
         }
         */
+        function setScore_v2_zq(orderObj, resultObj,resultsObj,order_id,match_id,game_code,ScoreTitle,leagueName,home_team,guest_team) {
+            //主队比分
+            var home_score;
+            //客队比分
+            var guest_score;
+            //全场
+            if(ScoreTitle == '全场'){
+                home_score = resultObj.home_score;
+                guest_score = resultObj.guest_score;
+            }
+            //上半场
+            if(ScoreTitle == '上半'){
+                home_score = resultObj.u_home_score;
+                guest_score = resultObj.u_guest_score;
+            }
+            //全场角球
+            if(ScoreTitle == '角球全场'){//{"home":0,"guest":0,"home_half":0,"guest_half":0}
+                home_score = resultObj.corner_ball.home;
+                guest_score = resultObj.corner_ball.guest;
+            }
+            //上半场角球
+            if(ScoreTitle == '角球上半'){
+                home_score = resultObj.corner_ball.home_half;
+                guest_score = resultObj.corner_ball.guest_half;
+            }
+            console.log(resultsObj.result);
+            let content = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' ;
+            if(orderObj['is_champion'] == 1){
+                content += '  <div class="layui-inline">' +
+                        '    <label class="layui-form-label" style="width:100px;">冠军注单玩法:</label>' +
+                        '    <label class="layui-form-label"  style="width:120px;">'+orderObj.odds_code+'</label>' +
+                        '    <div class="layui-input-inline" style="width: 150px;">' +
+                        '      <input type="text" name="result" id="result" placeholder=""  value="' + resultsObj.result +'"  required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '  </div>' ;
+            }else{
+                content += '  <div class="layui-inline" style="width: -webkit-fill-available;height: 100px;">' +
+                        '    <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_zq_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_zq_guest_score" placeholder="主"  value="' + guest_score +'"  required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '  </div>' ;
+            }
+
+            content += '</div>';
+
+            layer.open({
+                area: ['700px', '250px'], //宽高
+                type: 1,
+                title: '设置结算比分',
+                content: content, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响,
+                btn: ['提交', '取消'],
+                yes: function (index, layero) {
+                            var home = $("#set_zq_home_score").val();
+                            var guest = $("#set_zq_guest_score").val();
+                 matchdata = JSON.stringify({
+                            home: $("#set_zq_home_score").val(),
+                            guest: $("#set_zq_guest_score").val(),
+                        });
+console.log(matchdata);
+                    ajax_setScore_all_v2(order_id,game_code,match_id,matchdata,ScoreTitle,home,guest);
+                    return true;
+                },
+            });
+        }
 
-        function setScore_v2_zq(orderObj, resultObj,resultsObj,order_id,match_id,game_code) {
+        function ___setScore_v2_zq(orderObj, resultObj,resultsObj,order_id,match_id,game_code) {
             console.log(resultsObj.result);
             let content = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' ;
             if(orderObj['is_champion'] == 1){
@@ -837,13 +907,13 @@ console.log(matchdata);
 
             return ;
         }
-        function  ajax_setScore_all_v2(order_id, game_code, match_id, matchdata){
+        function  ajax_setScore_all_v2(order_id, game_code, match_id, matchdata,ScoreTitle,home,guest){
             // 请求设置接口
             $.ajax({
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/SoccerNoteList/manualmatchpdate_v2',
-                data: {order_id: order_id, game_code: game_code, match_id: match_id, matchdata: matchdata},
+                data: {order_id: order_id, game_code: game_code, match_id: match_id, matchdata: matchdata,ScoreTitle:ScoreTitle,home:home,guest:guest},
                 success: function (res) {
                     if (1 == res.status) {
                         layer.alert("设置成功", {title: '友情提示', icon: 1, closeBtn: 0}, function () {