|
|
@@ -139,6 +139,113 @@ class SportswqController extends Controller {
|
|
|
return responseToJson(1);
|
|
|
}
|
|
|
|
|
|
+ //结算
|
|
|
+ function Settlement1(Req $req){
|
|
|
+ $match_id = $req->match_id;
|
|
|
+ $type = $req->type;
|
|
|
+ $process = $req->process;
|
|
|
+ if(empty($process)){
|
|
|
+ $process = array();
|
|
|
+ }
|
|
|
+
|
|
|
+ $token = session('adminInfo.token');
|
|
|
+ $notice = \App\Models\Comendnotice::where('match_id', $match_id)->first();
|
|
|
+
|
|
|
+ if(!$notice){
|
|
|
+ return json_encode(['status'=>5,'msg'=>'请先核对结果,并提交结果']);
|
|
|
+ }
|
|
|
+ $noticeid = $notice['id'];
|
|
|
+ //查询赛事单式是否有订单(网球)
|
|
|
+ $newapp = new \App\Models\MoneyBuyMatch();
|
|
|
+ $simplex = $newapp->simsettleorder($match_id,$type);
|
|
|
+ $str = $newapp->strsettleorder($match_id);
|
|
|
+
|
|
|
+ //获取赛事结算进程下的注单
|
|
|
+ $simplex = commonFunction::getOrderData($data = [],$simplex,$type,$process);
|
|
|
+ $str = commonFunction::getOrderData($data = [],$str,$type,$process);
|
|
|
+
|
|
|
+ //获取注单id组成一维数组
|
|
|
+ $simplex_ids = array_column($simplex['settle'],'order_id');
|
|
|
+ $str_ids = array_column($str['settle'],'order_id');
|
|
|
+
|
|
|
+ //去重
|
|
|
+ $simplex_ids = array_unique($simplex_ids);
|
|
|
+ $str_ids = array_unique($str_ids);
|
|
|
+// print_r($simplex_ids);exit;
|
|
|
+
|
|
|
+ //判断赛事下注单输赢
|
|
|
+ $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){
|
|
|
+ //单式结算
|
|
|
+ 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{
|
|
|
+ $log = array(
|
|
|
+ session('adminInfo.admin_name'),
|
|
|
+ );
|
|
|
+ OperationLog(session('adminInfo.admin_id'), '网球结算', $log);
|
|
|
+ $res = \App\Models\SportsTennis::where ('id', $match_id)->first();
|
|
|
+ if($res['status'] == 1){
|
|
|
+ return json_encode(['status'=>4,'msg'=>'该赛事进程下没有任何订单']);
|
|
|
+ }
|
|
|
+ $res = \App\Models\Stwqresult::where ('match_id', $match_id)->update(['status' =>3]);
|
|
|
+ $res = \App\Models\SportsTennis::where ('id', $match_id)->update(['status' =>3]);
|
|
|
+ return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
//结算
|
|
|
function Settlement(Req $req){
|
|
|
$jsurl = config('sconstant.url');//结算请求域名地址
|
|
|
@@ -232,7 +339,7 @@ class SportswqController extends Controller {
|
|
|
$newapp = \App\Models\Stwqresult::where('match_id', $match_id)->first();
|
|
|
|
|
|
$array =array(
|
|
|
- 'wqresult' => json_decode($newapp['inning'],true),
|
|
|
+ 'wqresult' => json_decode($newapp['manual_result'],true),
|
|
|
'newapp' => $newapp,
|
|
|
);
|
|
|
return $array;
|
|
|
@@ -268,28 +375,28 @@ class SportswqController extends Controller {
|
|
|
|
|
|
$data = array(
|
|
|
"1" => array(
|
|
|
- 'home' => intval($req->homeo)?intval($req->homeo):0,
|
|
|
- 'guest' => intval($req->guesto)?intval($req->guesto):0,
|
|
|
+ 'home' => intval($req->homeo)?intval($req->homeo):'',
|
|
|
+ 'guest' => intval($req->guesto)?intval($req->guesto):'',
|
|
|
),
|
|
|
"2" => array(
|
|
|
- 'home' => intval($req->homet)?intval($req->homet):0,
|
|
|
- 'guest' => intval($req->guestt)?intval($req->guestt):0,
|
|
|
+ 'home' => intval($req->homet)?intval($req->homet):'',
|
|
|
+ 'guest' => intval($req->guestt)?intval($req->guestt):'',
|
|
|
),
|
|
|
"3" => array(
|
|
|
- 'home' => intval($req->homes)?intval($req->homes):0,
|
|
|
- 'guest' => intval($req->guests)?intval($req->guests):0,
|
|
|
+ 'home' => intval($req->homes)?intval($req->homes):'',
|
|
|
+ 'guest' => intval($req->guests)?intval($req->guests):'',
|
|
|
),
|
|
|
"4" => array(
|
|
|
- 'home' => intval($req->homef)?intval($req->homef):0,
|
|
|
- 'guest' => intval($req->guestf)?intval($req->guestf):0,
|
|
|
+ 'home' => intval($req->homef)?intval($req->homef):'',
|
|
|
+ 'guest' => intval($req->guestf)?intval($req->guestf):'',
|
|
|
),
|
|
|
"5" => array(
|
|
|
- 'home' => intval($req->homee)?intval($req->homee):0,
|
|
|
- 'guest' => intval($req->gueste)?intval($req->gueste):0,
|
|
|
+ 'home' => intval($req->homee)?intval($req->homee):'',
|
|
|
+ 'guest' => intval($req->gueste)?intval($req->gueste):''
|
|
|
),
|
|
|
"all" => array(
|
|
|
- 'home' => intval($req->homen)?intval($req->homen):0,
|
|
|
- 'guest' => intval($req->guestn)?intval($req->guestn):0,
|
|
|
+ 'home' => intval($req->homen)?intval($req->homen):'',
|
|
|
+ 'guest' => intval($req->guestn)?intval($req->guestn):'',
|
|
|
),
|
|
|
);
|
|
|
|
|
|
@@ -300,7 +407,7 @@ class SportswqController extends Controller {
|
|
|
|
|
|
//修改网球比分前的比分数据
|
|
|
$res = \App\Models\Stwqresult::where('match_id', $match_id)->first();
|
|
|
- $scores = json_decode($res['inning'],true);
|
|
|
+ $scores = json_decode($res['manual_result'],true);
|
|
|
$process = array();//进程
|
|
|
if($scores[1]['home'] != $data[1]['home'] || $scores[1]['guest'] != $data[1]['guest']){
|
|
|
$process[] = 'one';
|
|
|
@@ -329,6 +436,7 @@ class SportswqController extends Controller {
|
|
|
"home_player_score"=>$data['all']['home'],
|
|
|
"guest_player_score"=>$data['all']['guest'],
|
|
|
"inning"=>json_encode($data),
|
|
|
+ "manual_result"=>json_encode($data),
|
|
|
"match_score"=>$data['all']['home'].':'.$data['all']['guest'],
|
|
|
"first_inning_score"=>$data[1]['home'].':'.$data[1]['guest'],
|
|
|
"second_inning_score"=>$data[2]['home'].':'.$data[2]['guest'],
|
|
|
@@ -438,6 +546,14 @@ class SportswqController extends Controller {
|
|
|
return responseToJson(1);
|
|
|
}
|
|
|
|
|
|
+ //获取赛事进程数据
|
|
|
+ function getprocess(Req $req){
|
|
|
+ $type = $req->type;
|
|
|
+
|
|
|
+ $process = commonFunction::getprocess($type);
|
|
|
+ return json_encode($process);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|