Browse Source

异常处理

彭俊 6 years ago
parent
commit
6aa34edcd7

+ 105 - 91
app/Http/Controllers/Admin/SportsfootController.php

@@ -31,97 +31,61 @@ class SportsfootController extends Controller {
 		$simplex_ids = array_column($newapp->allsimplexorder($match_id,'zq'),'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'=>$simplex_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'=>$str_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){
-//			//单式结算
-//			if(count($simplex_ids)>0){
-//				$sim['order_ids'] = json_encode($simplex_ids);
-//				$settlesim = $settlementAuto->SubmitSettelement('s',$sim);
-//				if($settlesim == false){
-//					return json_encode(['status'=>3,'msg'=>'单式注单结算有误,请联系管理员!!!']);
-//				}
-//			}
-//			if(count($str_ids)>0){
-//				$str['order_ids'] = json_encode($str_ids);
-//				$settlestr = $settlementAuto->SubmitSettelement('s',$str);
-//				if($settlestr == false){
-//					return json_encode(['status'=>3,'msg'=>'串式注单结算有误,请联系管理员!!!']);
-//				}
-//			}
-//			return json_encode(['status'=>1,'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 ('id', $match_id)->update(['status' =>3]);
-//            return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
-//		}
-
+		//判断赛事下注单输赢
+		$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'=>$simplex_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'=>$str_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,'zq');
-
-					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,'zq');
-
-					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,'zq');
-
-					//串式结算
-					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'zq');
-					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'] = json_encode($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'] = json_encode($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'] = json_encode($simplex_ids);
+				$str['order_ids'] = json_encode($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(
@@ -129,9 +93,59 @@ class SportsfootController extends Controller {
 			);
 			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'=>'该赛事没有任何订单,将会结束该赛事!!!']);
+			$res = \App\Models\SportsSoccer::where ('id', $match_id)->update(['status' =>3]);
+            return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
 		}
+
+//		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,'zq');
+//
+//					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,'zq');
+//
+//					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,'zq');
+//
+//					//串式结算
+//					$tandem_res = $napp->tandems($token,$match_id,$jsurl,'zq');
+//					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'=>'返回参数不对']);
+//					}
+//				}
+//			}else{
+//				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'=>'该赛事没有任何订单,将会结束该赛事!!!']);
+//		}
 		
 	}
 

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

@@ -1412,41 +1412,41 @@ class Common
         $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);
-                }
-            }
-		}else{
-            //未结算赛事 处理 下单式注单作废,串关注单下此赛事按平局处理
+//		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);
+//                }
+//            }
+//		}else{
+            //赛事 处理 下单式注单作废,串关注单下此赛事按平局处理
             if(count($oddsData_str) > 0){
                 $oddsData_str = $oddsData_str;
             }
             $type = 1;
 			$upapp->delorder($match_id,$game_code,$oddsData_sim,$oddsData_str,$type);
-		}
+		//}
 		//=== end ===
 	}
 	/**

+ 2 - 2
app/Models/SportsNoteList.php

@@ -1367,11 +1367,11 @@ class SportsNoteList extends BaseModel
                 foreach($orders as $kk=>$vv){
                     if($v['account_identity'] == $vv['account_identity']){
                         if($account_money == 0){
-                            $vv['available_cash'] = $v['available_cash']+$vv['money']-$vv['money']-$vv['gain_money'];
+                            $vv['available_cash'] = $v['available_cash']+$vv['money']-$vv['return_money']-$vv['gain_money'];
                             //当前注单退款后的余额
                             $account_money = $vv['available_cash'];
                         }else{//其他 获取 上个注单处理后的余额
-                            $vv['available_cash'] = $account_money+$vv['money']-$vv['money']-$vv['gain_money'];
+                            $vv['available_cash'] = $account_money+$vv['money']-$vv['return_money']-$vv['gain_money'];
                             $account_money = $vv['available_cash'];
                         }
                     }