彭俊 6 vuotta sitten
vanhempi
commit
ddfcb962b2

+ 215 - 173
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -5,6 +5,7 @@
  * Date: 2019/4/9
  * Time: 9:11
  */
+
 namespace App\Http\Controllers\Admin;
 
 use App\Http\Controllers\Controller;
@@ -25,11 +26,11 @@ class SoccerNoteListController extends Controller
     {
         $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
         $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
-        $request['account'] = isset($req->account) ? trim($req->account) :null ;
-        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
-        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
-        $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
-        $request['match_id'] = isset($req->match_id) ? trim($req->match_id) :null ;
+        $request['account'] = isset($req->account) ? trim($req->account) : null;
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
+        $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
+        $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
         $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
@@ -48,7 +49,7 @@ class SoccerNoteListController extends Controller
         $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
         $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
         $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
-        $dt->addColsFields('game_status', array('templet' => '#game_status','sort' => false, 'width' =>90));
+        $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 90));
         //$arr[] = 'view';
 //        if (checkRriv('/admin/SoccerNoteList/edit')) {
 //            $arr[] = 'edit';
@@ -59,50 +60,51 @@ class SoccerNoteListController extends Controller
     }
 
     //修改冠军单订单结果
-    function orderupgj(Req $req){
+    function orderupgj(Req $req)
+    {
         $id = $req->id;//37
         $orderid = $req->order;//S20190916094723915270970
         if (intval($id) < 1) {
             return -1;
         }
 
-        $data = \App\Models\SoccerLeague::where('id',$id)->first();
+        $data = \App\Models\SoccerLeague::where('id', $id)->first();
 
-        $odds_code = \App\Models\SoccerOdds::where('lg_id',$id)->where('type',1)->where('odds_code','!=','')->select('odds_code')->distinct()->get()->toArray();//赔率表
+        $odds_code = \App\Models\SoccerOdds::where('lg_id', $id)->where('type', 1)->where('odds_code', '!=', '')->select('odds_code')->distinct()->get()->toArray();//赔率表
 
-        for ($i=0; $i < count($odds_code); $i++) { 
-            $allteam[] = \App\Models\SoccerOdds::where('odds_code',$odds_code[$i]['odds_code'])->where('lg_id',$id)->where('type',1)->select('team')->distinct()->get()->toArray();
+        for ($i = 0; $i < count($odds_code); $i++) {
+            $allteam[] = \App\Models\SoccerOdds::where('odds_code', $odds_code[$i]['odds_code'])->where('lg_id', $id)->where('type', 1)->select('team')->distinct()->get()->toArray();
         }
 
         $data = $data->toArray();
-        $isdisplay = \App\Models\Stwqleagueresult::where(['lg_id'=>$id,'status'=>1])->select("game_name")->distinct()->get()->toArray();
-        $idisplay = array_column($isdisplay,'game_name');
-        $displays = implode(",",$idisplay);//转换成字符串
+        $isdisplay = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'status' => 1])->select("game_name")->distinct()->get()->toArray();
+        $idisplay = array_column($isdisplay, 'game_name');
+        $displays = implode(",", $idisplay);//转换成字符串
 
         //新增纪录
-        foreach($odds_code as $k => $v) {
-            foreach($allteam[$k] as $kk => $vv) {
+        foreach ($odds_code as $k => $v) {
+            foreach ($allteam[$k] as $kk => $vv) {
                 $name = $v['odds_code'];
                 $isteam = $allteam[$k][$kk]['team'];
-                $res = \App\Models\Stwqleagueresult::where(['lg_id'=>$id,'game_name'=>$name,'result'=>$isteam])->first();
+                $res = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'game_name' => $name, 'result' => $isteam])->first();
 
                 $addresult = [
                     'lg_id' => $id,
                     'game_name' => $name,
                     'result' => $isteam,
-                    'ctime' => date('Y-m-d H:i:s',time()),
+                    'ctime' => date('Y-m-d H:i:s', time()),
                     'status' => 0,
-                    'updated_at' => date('Y-m-d H:i:s',time()),
+                    'updated_at' => date('Y-m-d H:i:s', time()),
                 ];
 
-                if(empty($res)){
+                if (empty($res)) {
                     \App\Models\Stwqleagueresult::insert($addresult);
                 }
 
             }
         }
-        $orderjg = \App\Models\SportsNoteList::where(['order_id'=>$orderid])->select("single_result")->first();
-        $orderjg = json_decode($orderjg['single_result'],true);
+        $orderjg = \App\Models\SportsNoteList::where(['order_id' => $orderid])->select("single_result")->first();
+        $orderjg = json_decode($orderjg['single_result'], true);
 
         $data['allteam'] = $allteam;
         $data['odds_code'] = $odds_code;
@@ -112,31 +114,32 @@ class SoccerNoteListController extends Controller
         $data['orderid'] = $orderid;
         $data['lg_id'] = $id;
 
-        return view('sports/orderupgj',$data);
+        return view('sports/orderupgj', $data);
     }
 
     //修改冠军单订单结果提交
-    function ajaxtj(Req $req){
+    function ajaxtj(Req $req)
+    {
         $isstatus = $req->isstatus;//更新
         $order = $req->order;
 
-        if($isstatus){
+        if ($isstatus) {
             $gjresult = array(
-                'lg_id'=>$req->lg_id?$req->lg_id:'',
-                'game_name'=> $req->odds_code?$req->odds_code:'',
-                'result'=> $req->team?$req->team:'',
-                'updatetime' => date("Y-m-d H:i:s",time()),
+                'lg_id' => $req->lg_id ? $req->lg_id : '',
+                'game_name' => $req->odds_code ? $req->odds_code : '',
+                'result' => $req->team ? $req->team : '',
+                'updatetime' => date("Y-m-d H:i:s", time()),
             );
-        }else{
+        } else {
             $gjresult = array(
-                'lg_id'=>'',
-                'game_name'=>'',
-                'result'=>'',
+                'lg_id' => '',
+                'game_name' => '',
+                'result' => '',
             );
         }
 
-        \App\Models\SportsNoteList::where(['order_id'=>$order])->update(['single_result'=>json_encode($gjresult,JSON_UNESCAPED_UNICODE)]);
-        
+        \App\Models\SportsNoteList::where(['order_id' => $order])->update(['single_result' => json_encode($gjresult, JSON_UNESCAPED_UNICODE)]);
+
         return responseToJson(1);
     }
 
@@ -145,8 +148,8 @@ class SoccerNoteListController extends Controller
         $page = Request::has('page') ? Request::get('page') : '';
         $list = Request::has('limit') ? Request::get('limit') : 10;
         $account = Request::get('account') ? Request::get('account') : '';
-        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
-        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
         $order_id = Request::get('order_id') ? Request::get('order_id') : '';
         $match_id = Request::get('match_id') ? Request::get('match_id') : '';
         $status = Request::has('status') ? Request::get('status') : '';
@@ -163,22 +166,22 @@ class SoccerNoteListController extends Controller
             }
         }
         if (!empty($star_time)) {
-            if (!empty($end_time)){
+            if (!empty($end_time)) {
                 $where[] = array('money_buy_simplex.money_time', '>', $star_time);
                 $where[] = array('money_buy_simplex.money_time', '<', $end_time);
-            }else{
+            } else {
                 $where[] = array('money_buy_simplex.money_time', '>', $star_time);
             }
-        }else if(empty($star_time)){
-            if (!empty($end_time)){
+        } else if (empty($star_time)) {
+            if (!empty($end_time)) {
 
                 $where[] = array('money_buy_simplex.money_time', '<', $end_time);
             }
         }
-        if (!empty($order_id)){
+        if (!empty($order_id)) {
             $where[] = array('money_buy_simplex.order_id', $order_id);
         }
-        if (!empty($match_id)){
+        if (!empty($match_id)) {
             $where[] = array('money_buy_simplex.match_id', $match_id);
         }
         if ($status != -1) {
@@ -189,7 +192,7 @@ class SoccerNoteListController extends Controller
         }
         $where[] = array('money_buy_simplex.game_code', $type);
         $newapp = new \App\Models\SportsNoteList();
-        $data = $newapp->getinfo($list, $page, $where,$type);
+        $data = $newapp->getinfo($list, $page, $where, $type);
 
         return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
     }
@@ -198,11 +201,11 @@ class SoccerNoteListController extends Controller
     {
         $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
         $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
-        $request['account'] = isset($req->account) ? trim($req->account) :null ;
-        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
-        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
-        $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
-        $request['match_id'] = isset($req->match_id) ? trim($req->match_id) :null ;
+        $request['account'] = isset($req->account) ? trim($req->account) : null;
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
+        $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
+        $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null;
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
         $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
@@ -221,7 +224,7 @@ class SoccerNoteListController extends Controller
         $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
         $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
         $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
-        $dt->addColsFields('game_status', array('sort' => false, 'width' =>90));
+        $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
         //$arr[] = 'view';
 //        if (checkRriv('/admin/SoccerNoteList/edit')) {
 //            $arr[] = 'edit';
@@ -233,47 +236,47 @@ class SoccerNoteListController extends Controller
 
     //查询赛事结果
     // function Sairesult(Req $req){
-        // $did = $req->did;
-        // $qlgame = $req->qlgame?$req->qlgame:'zq';
-        // $newapp = \App\Models\SportsNoteList::where('id', $did)->first();
-
-        // if($qlgame=='zq'){
-        //     if($newapp['match_id']){
-        //         $newre = new \App\Models\Stzqresult();
-        //         $teamname = $newre->matchjg($newapp['match_id']);
-        //     }else{
-        //         $teamname ='';
-        //     }
-        // }elseif($qlgame=='lq'){
-        //     if($newapp['match_id']){
-        //         $newre = new \App\Models\Stlqresult();
-        //         $teamname = $newre->matchjg($newapp['match_id']);
-        //     }else{
-        //         $teamname ='';
-        //     }
-        // }elseif($qlgame=='bq'){
-        //     if($newapp['match_id']){
-        //         $newre = new \App\Models\Stbqresult();
-        //         $teamname = $newre->matchjg($newapp['match_id']);
-        //     }else{
-        //         $teamname ='';
-        //     }
-        // }elseif($qlgame=='wq'){
-        //     if($newapp['match_id']){
-        //         $newre = new \App\Models\Stwqresult();
-        //         $teamname = $newre->matchjg($newapp['match_id']);
-        //     }else{
-        //         $teamname ='';
-        //     } 
-        // }else{
-        //     $data = "参数错误";
-        // }
-
-        // $data =array(
-        //     'singleresult' => json_decode($newapp['single_result'],true),
-        //     'teamname' => $teamname,
-        // );
-        // return $data;
+    // $did = $req->did;
+    // $qlgame = $req->qlgame?$req->qlgame:'zq';
+    // $newapp = \App\Models\SportsNoteList::where('id', $did)->first();
+
+    // if($qlgame=='zq'){
+    //     if($newapp['match_id']){
+    //         $newre = new \App\Models\Stzqresult();
+    //         $teamname = $newre->matchjg($newapp['match_id']);
+    //     }else{
+    //         $teamname ='';
+    //     }
+    // }elseif($qlgame=='lq'){
+    //     if($newapp['match_id']){
+    //         $newre = new \App\Models\Stlqresult();
+    //         $teamname = $newre->matchjg($newapp['match_id']);
+    //     }else{
+    //         $teamname ='';
+    //     }
+    // }elseif($qlgame=='bq'){
+    //     if($newapp['match_id']){
+    //         $newre = new \App\Models\Stbqresult();
+    //         $teamname = $newre->matchjg($newapp['match_id']);
+    //     }else{
+    //         $teamname ='';
+    //     }
+    // }elseif($qlgame=='wq'){
+    //     if($newapp['match_id']){
+    //         $newre = new \App\Models\Stwqresult();
+    //         $teamname = $newre->matchjg($newapp['match_id']);
+    //     }else{
+    //         $teamname ='';
+    //     }
+    // }else{
+    //     $data = "参数错误";
+    // }
+
+    // $data =array(
+    //     'singleresult' => json_decode($newapp['single_result'],true),
+    //     'teamname' => $teamname,
+    // );
+    // return $data;
     // }
     // function Sairesult(Req $req){
     //     $did = $req->did;
@@ -288,56 +291,57 @@ class SoccerNoteListController extends Controller
     // }
 
     //结果添加
-    function addend(Req $req){
+    function addend(Req $req)
+    {
         $did = $req->did;//59;//
         $qlgame = $req->qlgame;//1;
         $model = \App\Models\SportsNoteList::where('id', $did)->first();
         $pid = $model['match_id'];
 
-        if ($qlgame==1) {
-            if($model['result_flag']!=1){
-                $saisjg = \App\Models\Stzqresult::where('match_id',$pid)->first()->toArray();//赛事结果
-                $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'],true);
-                $saisjg['first_score'] = json_decode($saisjg['first_score'],true);
-                $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'],true);
-                $saisjg['warn_more'] = json_decode($saisjg['warn_more'],true);
-                
-                $model->single_result = json_encode([$saisjg],JSON_UNESCAPED_UNICODE);
+        if ($qlgame == 1) {
+            if ($model['result_flag'] != 1) {
+                $saisjg = \App\Models\Stzqresult::where('match_id', $pid)->first()->toArray();//赛事结果
+                $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'], true);
+                $saisjg['first_score'] = json_decode($saisjg['first_score'], true);
+                $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'], true);
+                $saisjg['warn_more'] = json_decode($saisjg['warn_more'], true);
+
+                $model->single_result = json_encode([$saisjg], JSON_UNESCAPED_UNICODE);
                 $model->save();
             }
             $newm = \App\Models\SportsNoteList::where('id', $did)->first();
             return $newm['single_result'];
-        }else{
+        } else {
             $new = \App\Models\SportsNoteList::where('id', $did)->first();
-            $newa = json_decode($new['single_result'],true); 
+            $newa = json_decode($new['single_result'], true);
             $newa[0]['home_score'] = $req->home_score;//主队进球
             $newa[0]['guest_score'] = $req->guest_score;//客队进球
-            $newa[0]['all_goal'] = intval($req->guest_score)+intval($req->home_score);//总进球
-            $newa[0]['last_score'] = $req->lastscore?$req->lastscore:'';//最后进球球队
-            $newa[0]['match_winer'] = $req->matchwiner?$req->matchwiner:'';//赢球球队
+            $newa[0]['all_goal'] = intval($req->guest_score) + intval($req->home_score);//总进球
+            $newa[0]['last_score'] = $req->lastscore ? $req->lastscore : '';//最后进球球队
+            $newa[0]['match_winer'] = $req->matchwiner ? $req->matchwiner : '';//赢球球队
             $newa[0]['update_time'] = time();//更新时间
             $newa[0]['u_guest_score'] = $req->u_guest_score;//上半场-主队进球数
             $newa[0]['u_home_score'] = $req->u_home_score;//上半场-客队进球数
             $newa[0]['penalty_card'] = array(
-                'home'=>$req->homeallcard,
-                'guest'=>$req->guestallcard,
-                'home_half'=>$req->homehalfcard,
-                'guest_half'=>$req->guesthalfcard,
+                'home' => $req->homeallcard,
+                'guest' => $req->guestallcard,
+                'home_half' => $req->homehalfcard,
+                'guest_half' => $req->guesthalfcard,
             );
             $newa[0]['corner_ball'] = array(
-                'home'=>$req->homeallcorner,
-                'guest'=>$req->guestallcorner,
-                'home_half'=>$req->homehalfcorner,
-                'guest_half'=>$req->guesthalfcorner,
+                'home' => $req->homeallcorner,
+                'guest' => $req->guestallcorner,
+                'home_half' => $req->homehalfcorner,
+                'guest_half' => $req->guesthalfcorner,
             );
             //最新进球
             $newa[0]['first_score'] = array(
-                'teamscore'=>$req->firstscore?$req->firstscore:0,//最先进球球队
-                'scoretime'=> $req->onescoretime?$req->onescoretime:'',//进球时间
-                'scoretype'=> $req->firststye?$req->firststye:'',//进球方式
+                'teamscore' => $req->firstscore ? $req->firstscore : 0,//最先进球球队
+                'scoretime' => $req->onescoretime ? $req->onescoretime : '',//进球时间
+                'scoretype' => $req->firststye ? $req->firststye : '',//进球方式
             );
 
-            $model->single_result = json_encode($newa,JSON_UNESCAPED_UNICODE);
+            $model->single_result = json_encode($newa, JSON_UNESCAPED_UNICODE);
             $model->result_flag = 1;
 
             $model->save();
@@ -350,8 +354,8 @@ class SoccerNoteListController extends Controller
         $page = Request::has('page') ? Request::get('page') : '';
         $list = Request::has('limit') ? Request::get('limit') : 10;
         $account = Request::get('account') ? Request::get('account') : '';
-        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
-        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
         $order_id = Request::get('order_id') ? Request::get('order_id') : '';
         $match_id = Request::get('match_id') ? Request::get('match_id') : '';
         $status = Request::has('status') ? Request::get('status') : '-1';
@@ -367,22 +371,22 @@ class SoccerNoteListController extends Controller
             }
         }
         if (!empty($star_time)) {
-            if (!empty($end_time)){
+            if (!empty($end_time)) {
                 $where[] = array('money_buy_simplex.money_time', '>', $star_time);
                 $where[] = array('money_buy_simplex.money_time', '<', $end_time);
-            }else{
+            } else {
                 $where[] = array('money_buy_simplex.money_time', '>', $star_time);
             }
-        }else if(empty($star_time)){
-            if (!empty($end_time)){
+        } else if (empty($star_time)) {
+            if (!empty($end_time)) {
 
                 $where[] = array('money_buy_simplex.money_time', '<', $end_time);
             }
         }
-        if (!empty($order_id)){
+        if (!empty($order_id)) {
             $where[] = array('money_buy_simplex.order_id', $order_id);
         }
-        if (!empty($match_id)){
+        if (!empty($match_id)) {
             $where[] = array('money_buy_simplex.match_id', $match_id);
         }
         if ($status != -1) {
@@ -393,7 +397,7 @@ class SoccerNoteListController extends Controller
         }
         $where[] = array('money_buy_simplex.game_code', $type);
         $newapp = new \App\Models\SportsNoteList();
-        $data = $newapp->info($list, $page, $where,$type);
+        $data = $newapp->info($list, $page, $where, $type);
 
         return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
     }
@@ -407,30 +411,30 @@ class SoccerNoteListController extends Controller
         if (intval($id) < 1) {
             return -1;
         }
-        $order = \App\Models\SportsNoteList::where('id',$id)->first();
+        $order = \App\Models\SportsNoteList::where('id', $id)->first();
         //用戶账户金额
-        $account_money = \App\Models\Account_detailed::where('account_identity',$order->account_identity)->first();
+        $account_money = \App\Models\Account_detailed::where('account_identity', $order->account_identity)->first();
         //反水
-        $water_return_money = \App\Models\Money_details::where('trade_id',$order->order_id)->where('trade_type','7')->first();
-        if(!empty($water_return_money)){
+        $water_return_money = \App\Models\Money_details::where('trade_id', $order->order_id)->where('trade_type', '7')->first();
+        if (!empty($water_return_money)) {
             $water_return = $water_return_money->money;
-        }else{
+        } else {
             $water_return = 0;
         }
         //撤单后用户账户金额
         $available_cash = $account_money->available_cash;
-        $new_available_cash = $available_cash+$order->money-$order->gain_money-$water_return;
+        $new_available_cash = $available_cash + $order->money - $order->gain_money - $water_return;
 
-        $model =new \App\Models\Money_details();
+        $model = new \App\Models\Money_details();
         $model->info_identity = UUID();
         $model->trade_id = $order->order_id;
         $model->account_name = $order->account_name;
         $model->account_identity = $order->account_identity;
-        $model->money = abs($order->money-$order->gain_money-$water_return);
-        $model->money_time = date("Y-m-d H:i:s",time());
-        if($new_available_cash>$available_cash){
+        $model->money = abs($order->money - $order->gain_money - $water_return);
+        $model->money_time = date("Y-m-d H:i:s", time());
+        if ($new_available_cash > $available_cash) {
             $model->money_type = '1';
-        }else{
+        } else {
             $model->money_type = '2';
         }
         $model->money_cash = $new_available_cash;
@@ -439,8 +443,8 @@ class SoccerNoteListController extends Controller
         $model->status = '1';
         try {
             DB::beginTransaction();//开启事务
-            \App\Models\SportsNoteList::where('id',$id)->update(['status'=>'2'],['gain_money'=>'0']);
-            \App\Models\Account_detailed::where('account_identity',$order->account_identity)->update(['available_cash'=>$new_available_cash,'cash'=>$new_available_cash]);
+            \App\Models\SportsNoteList::where('id', $id)->update(['status' => '2'], ['gain_money' => '0']);
+            \App\Models\Account_detailed::where('account_identity', $order->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
             $model->save();
 
             DB::commit();//提交
@@ -473,7 +477,7 @@ class SoccerNoteListController extends Controller
         //结算
         $SettlementOrder = new SettlementOrder();
         $settype = 1; //首次结算
-        $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
+        $data = $SettlementOrder->reSettlement($order_ids, $bet_type, $settype, $game_code, $match_id, $match_status = 0);
         return $data;
     }
 
@@ -502,7 +506,8 @@ class SoccerNoteListController extends Controller
     //     $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
     //     return $data;
     // }
-    public function resettlement(Req $req) {
+    public function resettlement(Req $req)
+    {
         $order_id = $req->order_id;
         $type = $req->type;
         $match_id = $req->match_id;
@@ -511,60 +516,63 @@ class SoccerNoteListController extends Controller
         //查询是否有订单
         $newapp = new \App\Models\SportsNoteList();
         $simplexnum = $newapp->onlyorder($order_id);
-        if($simplexnum==1){
-            $requet = file_get_contents($jsurl."/DoWinFailOneOrder?order_id=".$order_id."&token=".$token);
-            if(json_decode($requet,true)['status']==1){
+        if ($simplexnum == 1) {
+            $requet = file_get_contents($jsurl . "/DoWinFailOneOrder?order_id=" . $order_id . "&token=" . $token);
+            if (json_decode($requet, true)['status'] == 1) {
                 $napp = new \App\Models\Stzqresult();
                 $simplex = array(
-                    'token'=>$token,  
-                    'order_ids'=>$order_id, //订单id字符串,用半角都好分隔
-                    'bettype'=>1, //结算类型  1单式  2串式 
-                    'settype'=>2, //结算次数  1首次  2非首冷饮
-                    'game_code'=>$type, //赛事类型  zq lq wq bq
-                    'match_id'=>$match_id, // 赛事ID
-                    'change_status'=>0   //是否改状态
+                    'token' => $token,
+                    'order_ids' => $order_id, //订单id字符串,用半角都好分隔
+                    'bettype' => 1, //结算类型  1单式  2串式
+                    'settype' => 2, //结算次数  1首次  2非首冷饮
+                    'game_code' => $type, //赛事类型  zq lq wq bq
+                    'match_id' => $match_id, // 赛事ID
+                    'change_status' => 0   //是否改状态
                 );
-                $url=$jsurl.'/Settelement';
-                $simplex_res = $napp->post_curls($url,$simplex);//返回json
-                $huawei_res = json_decode($simplex_res,true);
-                if($huawei_res['status']==1){
-                    return json_encode(['status'=>1,'msg'=>'结算成功']);
-                }else{
-                    return json_encode(['status'=>4,'msg'=>'结算失败']);
+                $url = $jsurl . '/Settelement';
+                $simplex_res = $napp->post_curls($url, $simplex);//返回json
+                $huawei_res = json_decode($simplex_res, true);
+                if ($huawei_res['status'] == 1) {
+                    return json_encode(['status' => 1, 'msg' => '结算成功']);
+                } else {
+                    return json_encode(['status' => 4, 'msg' => '结算失败']);
                 }
-            }else{
-                return json_encode(['status'=>3,'msg'=>'输赢判断错误']);
-            } 
-        }else{
-            return json_encode(['status'=>2,'msg'=>'订单不存在']);
+            } else {
+                return json_encode(['status' => 3, 'msg' => '输赢判断错误']);
+            }
+        } else {
+            return json_encode(['status' => 2, 'msg' => '订单不存在']);
         }
     }
+
     /**
      *单式注单批量结算
      */
-    public function batchsettlement(){
-        $orders = \App\Models\SportsNoteList::where('settle_status','1')->get();
+    public function batchsettlement()
+    {
+        $orders = \App\Models\SportsNoteList::where('settle_status', '1')->get();
         $order_ids = array();
-        for($i=0;$i<count($orders);$i++){
-            $result = \App\Models\MoneyBuyMatch::where('batch_id',$orders[$i]->batch_id)->where('match_id',$orders[$i]->match_id)->get();
+        for ($i = 0; $i < count($orders); $i++) {
+            $result = \App\Models\MoneyBuyMatch::where('batch_id', $orders[$i]->batch_id)->where('match_id', $orders[$i]->match_id)->get();
             $res = array();
-            for($j=0;$j<count($result);$j++){
+            for ($j = 0; $j < count($result); $j++) {
                 $res[] = $result[$j]->result;
             }
-            if(!in_array(0,$res)){
+            if (!in_array(0, $res)) {
                 $order_ids[] = $orders[$i]->order_id;
             }
         }
         $SettlementOrder = new SettlementOrder();
         $bet_type = 1;//单式注单
-        $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
+        $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
         return $data;
     }
 
     /**
      *删除订单
      */
-    public function delete(Req $req) {
+    public function delete(Req $req)
+    {
         $id = $req->input('id');
         if (empty($id)) {
             return responseToJson(-2001); //id
@@ -598,8 +606,42 @@ class SoccerNoteListController extends Controller
         $type = Request::has('type') ? Request::get('type') : 'zq';
         $db = new \App\Models\SportsNoteList;
 
-        $data = $db->MoneyCount($where,$type);
+        $data = $db->MoneyCount($where, $type);
         return responseToJson($data);
     }
 
+    //单式订直接手动更改输赢结果并结算
+    public function manualmatchget(Req $req)
+    {
+        $order_id = isset($req->order_id) ? $req->order_id : 0;
+        $model = new  \App\Models\SportsNoteList();
+        $ret = $model->getorder($order_id);
+        if ($ret) {
+            $ret = $ret->toArray();
+            return responseToJson(1, '成功', $ret);
+        } else {
+            return responseToJson(-1, 'false', $ret);
+        }
+        
+    }
+
+
+    //单式订直接手动更改输赢结果并结算
+    public function manualmatchpdate(Req $req)
+    {
+        $order_id = isset($req->order_id) ? $req->order_id : 0;
+        $datas = isset($req->matchdata) ? $req->matchdata : [];
+        if (empty($order_id) || empty($datas)) {
+            return responseToJson(-1, '参数不能为空!');
+        }
+
+        //$simple = new  \App\Models\MoneyBuy;
+        //$match_datas = \App\Models\MoneyBuyMatch::where('match_id', $req->order_id)->get()->toArray();
+
+
+        return responseToJson(1, '成功');
+
+    }
+
+
 }

+ 170 - 139
app/Http/Controllers/Admin/SportsSoccerController.php

@@ -12,28 +12,30 @@ use Request;
 /**
  *
  */
-class SportsSoccerController extends Controller {
+class SportsSoccerController extends Controller
+{
 
-    public function score(Req $req) {
+    public function score(Req $req)
+    {
         $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;
         $request['recommend'] = isset($req->recommend) ? trim($req->recommend) : '';
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
-        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
-        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
 
         $request['is_rollball'] = isset($req->is_rollball) ? trim($req->is_rollball) : '0';
         $request['is_today'] = isset($req->is_today) ? trim($req->is_today) : '0';
         $request['is_morningplate'] = isset($req->is_morningplate) ? trim($req->is_morningplate) : '0';
         $request['is_stringscene'] = isset($req->is_stringscene) ? trim($req->is_stringscene) : '0';
 
-        $source = \App\Models\Setinfo::where('id','1000')->first();
-        if($source->infocontent != '混合数据'){
-            $data = \App\Models\SoccerLeague::join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')->select('st_zq_league.id','st_zq_league.name_chinese')->where('st_zq_local_league.source',$source->infocontent)->get();
-        }else{
-            $data = \App\Models\SoccerLeague::select('id','name_chinese')->get();
+        $source = \App\Models\Setinfo::where('id', '1000')->first();
+        if ($source->infocontent != '混合数据') {
+            $data = \App\Models\SoccerLeague::join('st_zq_local_league', 'st_zq_league.id', '=', 'st_zq_local_league.lg_id')->select('st_zq_league.id', 'st_zq_league.name_chinese')->where('st_zq_local_league.source', $source->infocontent)->get();
+        } else {
+            $data = \App\Models\SoccerLeague::select('id', 'name_chinese')->get();
         }
 
         $request['league'] = $data;
@@ -46,7 +48,7 @@ class SportsSoccerController extends Controller {
         $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
         $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
         $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('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120, 'align' => 'center'));
         $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
         if (checkRriv('/admin/SportsSoccer/edit')) {
             $arr[] = 'edit';
@@ -59,7 +61,8 @@ class SportsSoccerController extends Controller {
         return view('sports/soccer_match', $dt->render($request));
     }
 
-    function info(Req $req) {
+    function info(Req $req)
+    {
         $page = Request::has('page') ? Request::get('page') : '';
         $list = Request::has('limit') ? Request::get('limit') : 10;
         $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
@@ -89,31 +92,33 @@ class SportsSoccerController extends Controller {
         }
 
         if (!empty($star_time)) {
-            if (!empty($end_time)){
+            if (!empty($end_time)) {
                 $where[] = array('st_zq_competition.match_date', '>=', $star_time);
                 $where[] = array('st_zq_competition.match_date', '<=', $end_time);
-            }else{
+            } else {
                 $where[] = array('st_zq_competition.match_date', '>=', $star_time);
             }
-        }else if(empty($star_time)){
-            if (!empty($end_time)){
+        } else if (empty($star_time)) {
+            if (!empty($end_time)) {
 
                 $where[] = array('st_zq_competition.match_date', '<=', $end_time);
             }
         }
 
-        if($status != -1){
+        if ($status != -1) {
             $where[] = array('st_zq_competition.status', '=', $status);
         }
 
         $newapp = new \App\Models\SportsSoccer();
-        $data = $newapp->getinfo($list, $page, $where,$orwhere);
+        $data = $newapp->getinfo($list, $page, $where, $orwhere);
         return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
     }
+
     /**
      *设置是否为推荐赛事
      */
-    function recommendmatch(Req $req) {
+    function recommendmatch(Req $req)
+    {
         $id = $req->id;
         $recommend = is_numeric($req->recommend) ? intval($req->recommend) : '';
         if (empty($id) || !is_numeric($recommend)) {
@@ -126,15 +131,17 @@ class SportsSoccerController extends Controller {
         $res = $u_db->updateInfos($data, $id);
         return responseToJson($res);
     }
+
     /**
      *获取所有足球联赛信息
      */
-    function getParent() {
-        $source = \App\Models\Setinfo::where('id','1000')->first();
-        if($source->infocontent != '混合数据'){
-            $data = \App\Models\SoccerLeague::join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')->select('st_zq_league.id','st_zq_league.name_chinese')->where('st_zq_local_league.source',$source->infocontent)->get();
-        }else{
-            $data = \App\Models\SoccerLeague::select('id','name_chinese')->get();
+    function getParent()
+    {
+        $source = \App\Models\Setinfo::where('id', '1000')->first();
+        if ($source->infocontent != '混合数据') {
+            $data = \App\Models\SoccerLeague::join('st_zq_local_league', 'st_zq_league.id', '=', 'st_zq_local_league.lg_id')->select('st_zq_league.id', 'st_zq_league.name_chinese')->where('st_zq_local_league.source', $source->infocontent)->get();
+        } else {
+            $data = \App\Models\SoccerLeague::select('id', 'name_chinese')->get();
         }
 
         if (!$data) {
@@ -142,15 +149,17 @@ class SportsSoccerController extends Controller {
         }
         return $data->toArray();
     }
+
     /**
      *获取所有国家信息
      */
-    function getCountry() {
-        $data = \App\Models\Country::select('country_id','name_chinese')->get();
+    function getCountry()
+    {
+        $data = \App\Models\Country::select('country_id', 'name_chinese')->get();
         if (!$data) {
             return;
         }
-        for($i=0;$i<count($data);$i++){
+        for ($i = 0; $i < count($data); $i++) {
             $data[$i]->home_country_name = $data[$i]->name_chinese;
             $data[$i]->home_country_id = $data[$i]->country_id;
             $data[$i]->guest_country_name = $data[$i]->name_chinese;
@@ -158,26 +167,30 @@ class SportsSoccerController extends Controller {
         }
         return $data->toArray();
     }
+
     /**
      *获取国家的球队信息
      */
-    function getteam() {
+    function getteam()
+    {
         $countryid = $_GET["countryid"];
-        $gametype = \App\Models\StGameType::where('game_code','zq')->first();
-        $res = \App\Models\Team::where('country_id',$countryid)->where('game_type_id',$gametype->id)->get();
+        $gametype = \App\Models\StGameType::where('game_code', 'zq')->first();
+        $res = \App\Models\Team::where('country_id', $countryid)->where('game_type_id', $gametype->id)->get();
         return json_encode($res);
     }
+
     /**
      *添加赛事
      */
-    function add(Req $req) {
+    function add(Req $req)
+    {
         if (!$req->isMethod('post')) {
             $parents = $this->getParent();
             $lange = trans('menu');
             foreach ($parents as $k => $v) {
                 $arr = trim($parents[$k]['name_chinese']);
                 if (isset($lange[$arr])) {
-                    $parents[$k]['name']=$lange[$arr];
+                    $parents[$k]['name'] = $lange[$arr];
                 }
             }
             $data['parents'] = $parents;
@@ -190,30 +203,30 @@ class SportsSoccerController extends Controller {
             $model->match_date = $req->input('match_date');
             $model->match_time = $req->input('match_time');
             $model->status = $req->input('status');
-            if($req->input('is_rollball') == true){
+            if ($req->input('is_rollball') == true) {
                 $model->is_rollball = 1;
-            }else{
+            } else {
                 $model->is_rollball = 0;
             }
-            if($req->input('is_today') == true){
+            if ($req->input('is_today') == true) {
                 $model->is_today = 1;
-            }else{
+            } else {
                 $model->is_today = 0;
             }
-            if($req->input('is_morningplate') == true){
+            if ($req->input('is_morningplate') == true) {
                 $model->is_morningplate = 1;
-            }else{
+            } else {
                 $model->is_morningplate = 0;
             }
-            if($req->input('is_stringscene') == true){
+            if ($req->input('is_stringscene') == true) {
                 $model->is_stringscene = 1;
-            }else{
+            } else {
                 $model->is_stringscene = 0;
             }
-            $model->match_id = time() ;
-            $model->ctime = date('Y-m-d H:i:s',time());
-            $model->utime = date('Y-m-d H:i:s',time());
-            $model->tag = mt_rand(0,100) ;
+            $model->match_id = time();
+            $model->ctime = date('Y-m-d H:i:s', time());
+            $model->utime = date('Y-m-d H:i:s', time());
+            $model->tag = mt_rand(0, 100);
             $model->source = 'user-defined';
 
             $db = new \App\Models\Stzqlocalmatch();
@@ -227,14 +240,16 @@ class SportsSoccerController extends Controller {
         }
     }
 
-    function view(Req $req) {
+    function view(Req $req)
+    {
         return $this->edit($req);
     }
 
     /**
      *修改赛事
      */
-    function edit(Req $req) {
+    function edit(Req $req)
+    {
         $id = $req->id;
         if (intval($id) < 1) {
             return -1;
@@ -249,35 +264,35 @@ class SportsSoccerController extends Controller {
 
             //查看赛事是否有下注细信息
             $res = \App\Models\MoneyBuyMatch::where('match_id', $data->match_id)->get()->toArray();
-            if(!empty($res)){
-                if($data->status == 0){
-                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废']);
+            if (!empty($res)) {
+                if ($data->status == 0) {
+                    $match_status = array(['status' => 0, 'name' => '未开始'], ['status' => 1, 'name' => '正在进行'], ['status' => 4, 'name' => '作废']);
                 }
-                if($data->status == 1){
-                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+                if ($data->status == 1) {
+                    $match_status = array(['status' => 1, 'name' => '正在进行'], ['status' => 2, 'name' => '已结束'], ['status' => 4, 'name' => '作废']);
                 }
-            }else{
-                if($data->status == 0){
-                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+            } else {
+                if ($data->status == 0) {
+                    $match_status = array(['status' => 0, 'name' => '未开始'], ['status' => 1, 'name' => '正在进行'], ['status' => 4, 'name' => '作废'], ['status' => 6, 'name' => '取消']);
                 }
-                if($data->status == 1){
-                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+                if ($data->status == 1) {
+                    $match_status = array(['status' => 1, 'name' => '正在进行'], ['status' => 2, 'name' => '已结束'], ['status' => 4, 'name' => '作废'], ['status' => 6, 'name' => '取消']);
                 }
             }
-            if($data->status == 2){
-                $match_status =array(['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+            if ($data->status == 2) {
+                $match_status = array(['status' => 2, 'name' => '已结束'], ['status' => 4, 'name' => '作废']);
             }
-            if($data->status == 3){
-                $match_status =array(['status'=>3,'name'=>'已结算'],['status'=>5,'name'=>'待结算']);
+            if ($data->status == 3) {
+                $match_status = array(['status' => 3, 'name' => '已结算'], ['status' => 5, 'name' => '待结算']);
             }
-            if($data->status == 4){
-                $match_status =array(['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+            if ($data->status == 4) {
+                $match_status = array(['status' => 4, 'name' => '作废'], ['status' => 6, 'name' => '取消']);
             }
-            if($data->status == 5){
-                $match_status =array(['status'=>5,'name'=>'待结算'],['status'=>4,'name'=>'作废']);
+            if ($data->status == 5) {
+                $match_status = array(['status' => 5, 'name' => '待结算'], ['status' => 4, 'name' => '作废']);
             }
-            if($data->status == 6){
-                $match_status =array(['status'=>6,'name'=>'取消']);
+            if ($data->status == 6) {
+                $match_status = array(['status' => 6, 'name' => '取消']);
             }
 
             $name_chinese = \App\Models\SoccerLeague::where('id', $data->lg_id)->first();
@@ -292,7 +307,7 @@ class SportsSoccerController extends Controller {
             foreach ($data['parents'] as $k => $v) {
                 $arr = trim($data['parents'][$k]['name_chinese']);
                 if (isset($lange[$arr])) {
-                    $data['parents'][$k]['name_chinese']=$lange[$arr];
+                    $data['parents'][$k]['name_chinese'] = $lange[$arr];
                 }
             }
 
@@ -314,43 +329,45 @@ class SportsSoccerController extends Controller {
             $model->match_date = $req->input('match_date');
             $model->match_time = $req->input('match_time');
             $model->status = $req->input('status');
-            if($req->input('is_rollball') == true){
+            if ($req->input('is_rollball') == true) {
                 $model->is_rollball = 1;
-            }else{
+            } else {
                 $model->is_rollball = 0;
             }
-            if($req->input('is_today') == true){
+            if ($req->input('is_today') == true) {
                 $model->is_today = 1;
-            }else{
+            } else {
                 $model->is_today = 0;
             }
-            if($req->input('is_morningplate') == true){
+            if ($req->input('is_morningplate') == true) {
                 $model->is_morningplate = 1;
-            }else{
+            } else {
                 $model->is_morningplate = 0;
             }
-            if($req->input('is_stringscene') == true){
+            if ($req->input('is_stringscene') == true) {
                 $model->is_stringscene = 1;
-            }else{
+            } else {
                 $model->is_stringscene = 0;
             }
-            $model->ctime = date('Y-m-d H:i:s',time());
-            $model->utime = date('Y-m-d H:i:s',time());
+            $model->ctime = date('Y-m-d H:i:s', time());
+            $model->utime = date('Y-m-d H:i:s', time());
             $model->save();
             return responseToJson(1);
         }
     }
+
     /**
      *删除赛事
      */
-    public function delete(Req $req) {
+    public function delete(Req $req)
+    {
         $id = $req->input('id');
         if (empty($id)) {
-            return responseToJson(-2001); 
+            return responseToJson(-2001);
         }
         $ids = explode(',', $id);
         if (!is_array($ids) && intval($ids) < 0) {
-            return responseToJson(-2002); 
+            return responseToJson(-2002);
         }
         $id = array();
         $localmatch = \App\Models\Stzqlocalmatch::get();
@@ -359,9 +376,9 @@ class SportsSoccerController extends Controller {
                 if (intval($v) < 1) {
                     unset($ids[$k]);
                 }
-                $match = \App\Models\SportsSoccer::where('id',$v)->first();
-                for($i=0;$i<count($localmatch);$i++){
-                    if($localmatch[$i]->match_id == $match->match_id){
+                $match = \App\Models\SportsSoccer::where('id', $v)->first();
+                for ($i = 0; $i < count($localmatch); $i++) {
+                    if ($localmatch[$i]->match_id == $match->match_id) {
                         $id[] = $localmatch[$i]->id;
                     }
                 }
@@ -370,15 +387,15 @@ class SportsSoccerController extends Controller {
 
         $rows = \App\Models\SportsSoccer::whereIn('id', $ids)->delete();
         if (!$rows) {
-            return responseToJson(-2003); 
+            return responseToJson(-2003);
         }
-        if(count($id)>0) {
+        if (count($id) > 0) {
             $row = \App\Models\Stzqlocalmatch::whereIn('id', $id)->delete();
             if (!$row) {
-                return responseToJson(-2003); 
+                return responseToJson(-2003);
             }
         }
-        return responseToJson(1, trans('menu.delete_success')); 
+        return responseToJson(1, trans('menu.delete_success'));
 
     }
 
@@ -403,19 +420,19 @@ class SportsSoccerController extends Controller {
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $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();
+        $newapp = \App\Models\SportsSoccer::where('id', $request['id'])->first();
 
-        if(empty($newapp)){
+        if (empty($newapp)) {
             $match_id = $req->input('id');
-        }else{
+        } else {
             $match_id = $newapp->id;
         }
         $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\Models\Matchcode::where('p_id', '0')->where('game_code', 'zq')->get();
 
         $request['pcode'] = $data;
         $dt = \App\Lib\DataTable\DataTable::init();
-        $dt->setDataSource('/admin/SportsSoccer/oddsinfo?match_id='.$match_id.'');
+        $dt->setDataSource('/admin/SportsSoccer/oddsinfo?match_id=' . $match_id . '');
         $dt->setLang('sportssoccer');
         $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
         $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
@@ -428,7 +445,7 @@ class SportsSoccerController extends Controller {
         $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
         $dt->addColsFields('expire_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
         $dt->addColsFields('source', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
-        if (checkRriv('/admin/SportsSoccer/oddsedit?id='.$cp_id.'')) {
+        if (checkRriv('/admin/SportsSoccer/oddsedit?id=' . $cp_id . '')) {
             $arr[] = 'oddsedit';
         }
         $dt->setToolBar($arr, array('width' => 150));
@@ -437,13 +454,14 @@ class SportsSoccerController extends Controller {
         return view('sports/soccer_odds', $dt->render($request));
     }
 
-    function oddsinfo(Req $req){
+    function oddsinfo(Req $req)
+    {
         $lange = trans('sportsoddscode');
         $match_id = $req->match_id;
         $p_code = Request::has('p_code') ? Request::get('p_code') : '';
         $status = Request::has('status') ? Request::get('status') : '';
         $where = array();
-        if (!empty($p_code) && $p_code!=-1) {
+        if (!empty($p_code) && $p_code != -1) {
             $where[] = array('st_zq_odds.p_code', '=', $p_code);
         }
         if (!empty($status) && $status != -1) {
@@ -454,44 +472,48 @@ class SportsSoccerController extends Controller {
             return -1;
         }
         $new = new \App\Models\SoccerOdds();
-        $data = $new->getodds($match_id,$where);
+        $data = $new->getodds($match_id, $where);
 
         foreach ($data as $k => $v) {
             $odds_code = trim($data[$k]['odds_code']);
             $p_code = trim($data[$k]['p_code']);
             if (isset($lange[$odds_code])) {
-                $data[$k]['odds_code']=$lange[$odds_code];
+                $data[$k]['odds_code'] = $lange[$odds_code];
             }
             if (isset($lange[$p_code])) {
-                $data[$k]['p_code']=$lange[$p_code];
+                $data[$k]['p_code'] = $lange[$p_code];
             }
         };
 
         return \App\Lib\DataTable\DataTable::init()->toJson($data);
     }
+
     /**
      *根据选择的父级赔率代码获取对应的子级赔率代码
      */
-    function getoddscode() {
+    function getoddscode()
+    {
         $p_code = $_GET["pcode"];
-        $res = \App\Models\Matchcode::where('odds_code',$p_code)->first();
-        $codedata = \App\Models\Matchcode::where('p_id',$res->id)->get();
+        $res = \App\Models\Matchcode::where('odds_code', $p_code)->first();
+        $codedata = \App\Models\Matchcode::where('p_id', $res->id)->get();
         return json_encode($codedata);
     }
+
     /**
      *添加赔率
      */
-    function addodds(Req $req) {
-        $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
-        for($i=0;$i<count($pcodedata);$i++){
+    function addodds(Req $req)
+    {
+        $pcodedata = \App\Models\Matchcode::where('p_id', '0')->where('game_code', 'zq')->get();
+        for ($i = 0; $i < count($pcodedata); $i++) {
             $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
         }
 
         if (!$req->isMethod('post')) {
             $cp_id = $_SERVER['QUERY_STRING'];  //获取url中的参数--赛事id
-            $data = ["match_id"=>$cp_id];
+            $data = ["match_id" => $cp_id];
             $data['pcode'] = $pcodedata;
-            return view('sports.soccer_odds_form',$data);
+            return view('sports.soccer_odds_form', $data);
         } else {
             $model = new \App\Models\SoccerOdds();
             $date = new \App\Models\SoccerOddsRecord();
@@ -499,40 +521,40 @@ class SportsSoccerController extends Controller {
             $model->odds_code = $req->input('code');
             $model->status = $req->input('status');
             $model->p_code = $req->input('pcode');
-            $res = \App\Models\Matchcode::where('odds_code',$model->p_code)->first();
+            $res = \App\Models\Matchcode::where('odds_code', $model->p_code)->first();
             $model->p_id = $res->id;
-            $result = \App\Models\SoccerOdds::where('odds_code',$model->odds_code)->where('p_id',$model->p_id)->orderby('utime','desc')->first();
-            if(!empty($result)){
+            $result = \App\Models\SoccerOdds::where('odds_code', $model->odds_code)->where('p_id', $model->p_id)->orderby('utime', 'desc')->first();
+            if (!empty($result)) {
                 $sort = $result->sort;
-                $model->sort = $sort+1;
-            }else{
+                $model->sort = $sort + 1;
+            } else {
                 $model->sort = 0;
             }
             $model->odds = $req->input('odds');
             $model->condition = $req->input('condition');
             $model->max = $req->input('max');
             $model->min = $req->input('min');
-            $model->ctime = date('Y-m-d H:i:s',time());
-            $model->utime = date('Y-m-d H:i:s',time());
-            $model->sole = md5($model->match_id.$model->odds_code.$model->sort.$model->p_id.$model->ctime);
+            $model->ctime = date('Y-m-d H:i:s', time());
+            $model->utime = date('Y-m-d H:i:s', time());
+            $model->sole = md5($model->match_id . $model->odds_code . $model->sort . $model->p_id . $model->ctime);
             $model->source = 'user-defined';
-            $lg_id = \App\Models\SportsSoccer::where('match_id',$model->match_id)->first();
-            if(!empty($lg_id)){
+            $lg_id = \App\Models\SportsSoccer::where('match_id', $model->match_id)->first();
+            if (!empty($lg_id)) {
                 $model->lg_id = $lg_id->lg_id;
             }
             $model->expire_time = $req->input('expire_time');
-            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+            $model->odds_only = md5($model->match_id . $model->odds_code . $model->ctime);
 
             $date->match_id = $model->match_id;
             $date->odds_code = $model->odds_code;
             $date->status = $model->status;
             $date->p_code = $model->p_code;
             $date->p_id = $model->p_id;
-            $record = \App\Models\SoccerOddsRecord::where('odds_code',$date->odds_code)->where('p_id',$date->p_id)->orderby('utime','desc')->first();
-            if(!empty($record)){
+            $record = \App\Models\SoccerOddsRecord::where('odds_code', $date->odds_code)->where('p_id', $date->p_id)->orderby('utime', 'desc')->first();
+            if (!empty($record)) {
                 $sort = $record->sort;
-                $date->sort = $sort+1;
-            }else{
+                $date->sort = $sort + 1;
+            } else {
                 $date->sort = 0;
             }
             $date->odds = $model->odds;
@@ -550,13 +572,15 @@ class SportsSoccerController extends Controller {
             return responseToJson(1);
         }
     }
+
     /**
      *修改赔率
      */
-    function oddsedit(Req $req) {
+    function oddsedit(Req $req)
+    {
         $lange = trans('sportsoddscode');
-        $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
-        for($i=0;$i<count($pcodedata);$i++){
+        $pcodedata = \App\Models\Matchcode::where('p_id', '0')->where('game_code', 'zq')->get();
+        for ($i = 0; $i < count($pcodedata); $i++) {
             $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
         }
         $id = $req->id;
@@ -571,7 +595,7 @@ class SportsSoccerController extends Controller {
             }
             //$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','zq')->first();
             $res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
-            if(!empty($res)){
+            if (!empty($res)) {
                 $data->odds_name = $res->odds_name;
             }
 //            $res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->first();
@@ -585,7 +609,7 @@ class SportsSoccerController extends Controller {
 
 
             $expire_time = $data->expire_time; //2019-04-15 21:10:00
-            $str1 = str_replace(" ","T",$expire_time);
+            $str1 = str_replace(" ", "T", $expire_time);
             $data->expire_time = $str1;
 
 //            $odds_code = trim($data->odds_code);
@@ -617,20 +641,20 @@ class SportsSoccerController extends Controller {
             $model->condition = $req->input('condition');
             $model->max = $req->input('max');
             $model->min = $req->input('min');
-            $model->ctime = date('Y-m-d H:i:s',time());
-            $model->utime = date('Y-m-d H:i:s',time());
+            $model->ctime = date('Y-m-d H:i:s', time());
+            $model->utime = date('Y-m-d H:i:s', time());
             $model->expire_time = $req->input('expire_time');
-            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+            $model->odds_only = md5($model->match_id . $model->odds_code . $model->ctime);
 
-            $result = \App\Models\SoccerOdds::where('id',$model->id)->first();
+            $result = \App\Models\SoccerOdds::where('id', $model->id)->first();
             $data->match_id = $result->match_id;
             $data->status = $model->status;
             $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)){
+            $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)) {
                 $sort = $record->sort;
-                $data->sort = $sort+1;
-            }else{
+                $data->sort = $sort + 1;
+            } else {
                 $data->sort = 0;
             }
             $data->odds = $model->odds;
@@ -649,17 +673,19 @@ class SportsSoccerController extends Controller {
         }
 
     }
+
     /**
      *删除赔率
      */
-    public function oddsdelete(Req $req) {
+    public function oddsdelete(Req $req)
+    {
         $id = $req->input('id');
         if (empty($id)) {
-            return responseToJson(-2001); 
+            return responseToJson(-2001);
         }
         $ids = explode(',', $id);
         if (!is_array($ids) && intval($ids) < 0) {
-            return responseToJson(-2002); 
+            return responseToJson(-2002);
         }
         if (is_array($ids) && count($ids) > 0) {
             foreach ($ids as $k => $v) {
@@ -671,9 +697,14 @@ class SportsSoccerController extends Controller {
 
         $rows = \App\Models\SoccerOdds::whereIn('id', $ids)->delete();
         if (!$rows) {
-            return responseToJson(-2003); 
+            return responseToJson(-2003);
         }
-        return responseToJson(1, trans('menu.delete_success')); 
+        return responseToJson(1, trans('menu.delete_success'));
 
     }
+
+
+
+
+
 }

+ 16 - 1
app/Http/Controllers/Api/SettlementController.php

@@ -8,6 +8,7 @@ use App\Lib\Settlement\Adapter\ZqRule;
 use App\Lib\Settlement\SettlementOrder;
 use App\Lib\Settlement\Adapter\WqRule;
 
+use Illuminate\Http\Request as Req;
 
 use App\Lib\Settlement\SettlementWinFail;
 use  Illuminate\Routing\Controller as Controller;
@@ -32,9 +33,23 @@ class SettlementController extends Controller
         var_dump($ret);
     }
 
-    public function debug()
+    public function debug(Req $req)
     {
 
+        $order_id = isset($req->order_id) ? $req->order_id : 0;
+        $model  = new  \App\Models\SportsNoteList();
+        $ret = $model->getorder($order_id);
+
+        if ($ret){
+            $ret = $ret->toArray();
+        }
+
+        print_r($ret);exit ;
+
+        return responseToJson(1, '成功',$ret);
+
+
+        return ;
         $match = DB::table('money_buy_match')->where(['batch_id' => '20190916094717519851520'])->first();
         $result = DB::table('st_zq_result')->where(['match_id' => '2115'])->get();
         //$result = DB::table('st_wq_result')->where(['id' => '20'])->get();

+ 32 - 3
app/Http/Model/StWqResult.php

@@ -202,6 +202,7 @@ class StWqResult extends Model
                     $match_score = $result_mark['game_num_H'].':'.$result_mark['game_num_C'];
                    
                     //赛事待写入赛果数据
+                    /*
                     $set_match_r[] = [
                         "match_id"=> $v['id'],
                         "home_player_name"=>$v['home_team'],
@@ -231,13 +232,41 @@ class StWqResult extends Model
                         "match_process"=> $match_process?:'',//比赛进程
                         "inning"=> json_encode($inning)?:'',//每局输赢结果
                     ]; 
+                    */
+                    $set_match_r[] = [
+                        "match_id"=> $v['id'],
+                        "home_player_name"=>$v['home_team'],
+                        "guest_player_name"=>$v['guest_team'],
+                        "lg_id"=>$v['lg_id'],
+                        "status"=>$v['status'],
+                        "tag"=> $v['tag'],
+                        'match_time'=>$resultData['a_time']?:0,
+                        "ctime"=>date('Y-m-d H:i:s'),
+                        "update_time"=>date('Y-m-d H:i:s'),
+                        "start_time"=>date('Y-m-d H:i:s',strtotime($start_time)),
+
+                        "home_player_let_plate"=> $resultData['home_player_let_plate']?:0, //主队让盘
+                        "guest_player_let_plate"=> $resultData['guest_player_let_plate']?:0, //客队让盘
+                        "home_player_let_inning"=> $resultData['home_player_let_inning']?:0, //主队让局
+                        "guest_player_let_inning"=> $resultData['guest_player_let_inning']?:0, //客队让局
+                        "home_player_score"=> $result_mark['game_num_H']?:0, //主队得分
+                        "guest_player_score"=> $result_mark['game_num_C']?:0, //客队得分
+                        "all_inning"=> $resultData['all_inning']?:0, //总局数
+                        // "first_score_player"=> $resultData['first_score']?:'', //最先得分
+                        // "last_score_player"=> $resultData['last_score']?:'', //最后得分
+                        "first_inning_score"=> $resultData['first_inning_score']?:'', //第一局比分
+                        "second_inning_score"=> $resultData['second_inning_score']?:'',//第二局比分
+                        "third_inning_score"=> $resultData['third_inning_score']?:'',//第三局比分
+                        "match_score"=> $match_score?:'',//赛事比分
+                        "match_winer_player"=>  $match_winer?:'',//获胜队员
+                        "match_process"=> $match_process?:'',//比赛进程
+                        "inning"=> json_encode($inning)?:'',//每局输赢结果
+                    ]; 
 
                 }
             }
         }
-
-
-        //写入赛果
+        //写入赛果1
         if(!empty($set_match_r)){
             $ret = $model['model_result']::insert($set_match_r);
             if($ret != true) throw new \Exception( Response::generate('',Response::ADD_MATCH_R_ERROR));

+ 235 - 215
app/Models/SportsNoteList.php

@@ -5,206 +5,215 @@
  * Date: 2019/4/9
  * Time: 9:18
  */
+
 namespace App\Models;
+
 use Illuminate\Support\Facades\DB;
-class SportsNoteList extends BaseModel {
+use App\Models\MoneyBuyMatch;
+
+class SportsNoteList extends BaseModel
+{
     protected $table = "money_buy_simplex";
     public $timestamps = false;
 
-    function getinfo($list = 10, $page, $where = '',$type)
+    public function matchdatas()
+    {
+        return $this->hasMany(MoneyBuyMatch::class, 'order_id', 'order_id');
+    }
+
+
+    function getinfo($list = 10, $page, $where = '', $type)
     {
         $data = $this
-            ->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')
-            ->join('st_'.$type.'_competition','st_'.$type.'_competition.id','=','money_buy_simplex.match_id')
+            ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')
+            ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')
             // ->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')
-            ->join('st_'.$type.'_league','money_buy_simplex.lg_id','=','st_'.$type.'_league.id')
-
-            ->select('money_buy_simplex.id','money_buy_simplex.account_name','money_buy_simplex.is_champion','money_buy_simplex.account_identity','money_buy_simplex.order_id','money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.status','money_buy_simplex.money_time','money_buy_simplex.settle_status','money_buy_simplex.gain_money','money_buy_simplex.game_code','money_buy_simplex.match_id','money_buy_simplex.game_status','st_'.$type.'_competition.home_team','st_'.$type.'_competition.guest_team','st_'.$type.'_competition.match_date','st_'.$type.'_competition.match_time','st_'.$type.'_competition.lg_id','st_'.$type.'_competition.status as match_status','money_details.money_cash','money_buy_simplex.batch_id','st_'.$type.'_league.name_chinese','st_'.$type.'_league.last_time')
+            ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
+            ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
             ->where($where)
-            ->orderby('money_buy_simplex.money_time','desc')
-            ->paginate ($list);
+            ->orderby('money_buy_simplex.money_time', 'desc')
+            ->paginate($list);
         if (!$data < 0) {
             return -2021052003; //
         }
         //反水
-        $water_return_money = \App\Models\Money_details::where('trade_type','7')->get();
+        $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get();
 
         //注单作废
-        $invalid_money = \App\Models\Money_details::where('trade_type','3')->get();
+        $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get();
 
         //订单投注的玩法
-        $content = \App\Models\MoneyBuyMatch::where('bet_type','1')->get();
-        for($d=0;$d<count($content);$d++){
-            if($content[$d]->result==0){
+        $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get();
+        for ($d = 0; $d < count($content); $d++) {
+            if ($content[$d]->result == 0) {
                 $content[$d]->result = '未处理';
             }
-            if($content[$d]->result==1){
+            if ($content[$d]->result == 1) {
                 $content[$d]->result = '赢';
             }
-            if($content[$d]->result==-1){
+            if ($content[$d]->result == -1) {
                 $content[$d]->result = '输';
             }
-            if($content[$d]->result==2){
+            if ($content[$d]->result == 2) {
                 $content[$d]->result = '平';
             }
-            if($content[$d]->result==3){
+            if ($content[$d]->result == 3) {
                 $content[$d]->result = '赢半平半';
             }
-            if($content[$d]->result==4){
+            if ($content[$d]->result == 4) {
                 $content[$d]->result = '输半平半';
             }
         }
 
         //玩法
-        $result = \App\Models\Matchcode::where('game_code',$type)->get();
+        $result = \App\Models\Matchcode::where('game_code', $type)->get();
         //$result = \App\Model\Matchcode::get();
 
 
-        for($i=0;$i<count($data);$i++){
+        for ($i = 0; $i < count($data); $i++) {
             // if($data[$i]->status==1 && $data[$i]->game_status==0){
-                // $data[$i]->order_status = '投注'.'<br>;<a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id='.$data[$i]->id.'\');"> 作废 </a>';
+            // $data[$i]->order_status = '投注'.'<br>;<a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id='.$data[$i]->id.'\');"> 作废 </a>';
             // }else 
-            if($data[$i]->status==1 && $data[$i]->game_status==0){
+            if ($data[$i]->status == 1 && $data[$i]->game_status == 0) {
                 $data[$i]->order_status = '投注';
-            }else if($data[$i]->status==2){
+            } else if ($data[$i]->status == 2) {
                 $data[$i]->order_status = '作废';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已作废 </a>';
-            }else if($data[$i]->status==3){
+            } else if ($data[$i]->status == 3) {
                 $data[$i]->order_status = '撤单';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已撤单 </a>';
             }
-            if($data[$i]->settle_status==1){
+            if ($data[$i]->settle_status == 1) {
                 $data[$i]->settle_status = '未结算';
-            }else if($data[$i]->settle_status==2){
+            } else if ($data[$i]->settle_status == 2) {
                 $data[$i]->settle_status = '已结算';
             }
-            if($data[$i]->game_status==0){
+            if ($data[$i]->game_status == 0) {
                 $data[$i]->game_status = '未处理';
-            }else{
+            } else {
                 $data[$i]->game_status = '已处理';
             }
 
-            if($data[$i]->game_code == 'zq'){
-                $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'zq') {
+                $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
-            if($data[$i]->game_code == 'lq'){
-                $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'lq') {
+                $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
-            if($data[$i]->game_code == 'wq'){
-                $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'wq') {
+                $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
-            if($data[$i]->game_code == 'bq'){
-                $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'bq') {
+                $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
 
             $data[$i]->league = $data[$i]->name_chinese;
 
 
-            if($data[$i]->is_champion == 0){
-                $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
-                $data[$i]->time = '开赛:'.$data[$i]->match_date.' '.$data[$i]->match_time;
-            }else{
+            if ($data[$i]->is_champion == 0) {
+                $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team;
+                $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time;
+            } else {
                 $data[$i]->home_guest = '冠军联赛投注';
-                $data[$i]->time = '结束:'.$data[$i]->last_time;
+                $data[$i]->time = '结束:' . $data[$i]->last_time;
 
             }
-            $data[$i]->money_match_time = '下注:'.$data[$i]->money_time.$data[$i]->time;
+            $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time;
 
             //反水
             $data[$i]->water_return = -1;
-            for($a=0;$a<count($water_return_money);$a++){
-                if($data[$i]->order_id == $water_return_money[$a]->trade_id){
-                    if($data[$i]->status == 2 || $data[$i]->status == 3){
+            for ($a = 0; $a < count($water_return_money); $a++) {
+                if ($data[$i]->order_id == $water_return_money[$a]->trade_id) {
+                    if ($data[$i]->status == 2 || $data[$i]->status == 3) {
                         $data[$i]->water_return = 0;
-                    }else{
+                    } else {
                         $data[$i]->water_return = $water_return_money[$a]->money;
                     }
                     //用户投注后账户金额
                     $data[$i]->frozen_cash = $water_return_money[$a]->money_cash;
                 }
             }
-            if($data[$i]->water_return == -1){
+            if ($data[$i]->water_return == -1) {
                 $data[$i]->water_return = 0;
                 //用户投注后账户金额
                 $data[$i]->frozen_cash = $data[$i]->money_cash;
             }
             //此时结果金额
-            $data[$i]->result = $data[$i]->water_return+$data[$i]->gain_money;
+            $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money;
             //用户投注前账户金额
-            $data[$i]->available_cash = $data[$i]->money_cash+$data[$i]->money;
+            $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money;
             //投注前后账户金额
-            $data[$i]->account_money = $data[$i]->available_cash.'<br><span>'.$data[$i]->money.'</span><br>'.$data[$i]->frozen_cash;
-            if($data[$i]->status == 2 || $data[$i]->status == 3){
-                for($b=0;$b<count($invalid_money);$b++){
-                    if($data[$i]->order_id == $invalid_money[$b]->trade_id){
+            $data[$i]->account_money = $data[$i]->available_cash . '<br><span>' . $data[$i]->money . '</span><br>' . $data[$i]->frozen_cash;
+            if ($data[$i]->status == 2 || $data[$i]->status == 3) {
+                for ($b = 0; $b < count($invalid_money); $b++) {
+                    if ($data[$i]->order_id == $invalid_money[$b]->trade_id) {
                         $data[$i]->available_cash = $invalid_money[$b]->money_cash;
                         $data[$i]->account_money = $data[$i]->available_cash;
                     }
                 }
             }
             $data[$i]->str = 0;
-            for($b=0;$b<count($content);$b++){
+            for ($b = 0; $b < count($content); $b++) {
                 $data[$i]->str1 = 0;
                 $data[$i]->team = '';
-                if(!empty($content[$b]->odds_code)){
-                    if(!empty(stristr($content[$b]->odds_code,'home'))){
+                if (!empty($content[$b]->odds_code)) {
+                    if (!empty(stristr($content[$b]->odds_code, 'home'))) {
                         $data[$i]->team = $data[$i]->home_team;
                     }
-                    if(!empty(stristr($content[$b]->odds_code,'guest'))){
+                    if (!empty(stristr($content[$b]->odds_code, 'guest'))) {
                         $data[$i]->team = $data[$i]->guest_team;
                     }
 
-                    if($content[$b]->p_code == 'half_full'){
-                        $string = str_replace('home',$data[$i]->home_team,$content[$b]->odds_code);
-                        $string = str_replace('guest',$data[$i]->guest_team,$string);
-                        $string = str_replace('dogfall','和局',$string);
-                        $string = explode('_',$string);
-                        $data[$i]->team = $string['2'].'/'.$string['3'];
+                    if ($content[$b]->p_code == 'half_full') {
+                        $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code);
+                        $string = str_replace('guest', $data[$i]->guest_team, $string);
+                        $string = str_replace('dogfall', '和局', $string);
+                        $string = explode('_', $string);
+                        $data[$i]->team = $string['2'] . '/' . $string['3'];
                     }
                 }
 
                 //处理普通赛事玩法详情
-                if($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id &&$data[$i]->is_champion == 0){
+                if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) {
 
-                    if($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal'){
+                    if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
                         $content[$b]->condition = '';
                     }
 
                     $data[$i]->game_status = $data[$i]->game_status;
 
                     //投注详情
-                    if(!empty($data[$i]->match_time)){
-                        $data[$i]->content1 = '['.$data[$i]->match_time.']';
+                    if (!empty($data[$i]->match_time)) {
+                        $data[$i]->content1 = '[' . $data[$i]->match_time . ']';
                         //$data[$i]->match_time = $data[$i]->match_time;
-                    }
-                    else{
-                        if(!empty($data[$i]->last_time)){
-                            $datetime = explode(' ',$data[$i]->last_time);
+                    } else {
+                        if (!empty($data[$i]->last_time)) {
+                            $datetime = explode(' ', $data[$i]->last_time);
                             //$data[$i]->match_time = $datetime[1];
-                            $data[$i]->content1 = '['.$datetime[1].']';
+                            $data[$i]->content1 = '[' . $datetime[1] . ']';
                         }
                     }
-                    for($c=0;$c<count($result);$c++){
-                        if($content[$b]->odds_code == $result[$c]->odds_code){
-                            $data[$i]->str1 = 1;        
-                            if($content[$b]->result=='未处理'){
-                                $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
-                            }else{
-                                $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
+                    for ($c = 0; $c < count($result); $c++) {
+                        if ($content[$b]->odds_code == $result[$c]->odds_code) {
+                            $data[$i]->str1 = 1;
+                            if ($content[$b]->result == '未处理') {
+                                $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
+                            } else {
+                                $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
                             }
                         }
                     }
-                    if($data[$i]->str1 == 0){
-                        if($content[$b]->result=='未处理'){
-                            $data[$i]->content = $data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
-                        }else{
-                            $data[$i]->content = $data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
+                    if ($data[$i]->str1 == 0) {
+                        if ($content[$b]->result == '未处理') {
+                            $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
+                        } else {
+                            $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
                         }
                     }
                 }
                 //处理冠军联赛玩法详情
-                if($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id &&$data[$i]->is_champion == 1){
+                if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) {
                     $content[$b]->condition = '';
 
-                    if($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal'){
+                    if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
                         $content[$b]->condition = '';
                     }
 
@@ -236,19 +245,19 @@ class SportsNoteList extends BaseModel {
                         }
                     }
                     */
-                    if($data[$i]->str1 == 0){
-                        if($content[$b]->result=='未处理'){
-                            $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
-                        }else{
-                            $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
+                    if ($data[$i]->str1 == 0) {
+                        if ($content[$b]->result == '未处理') {
+                            $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
+                        } else {
+                            $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
                         }
                     }
                 }
             }
             // if($data[$i]->status == 1){
-                // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){
-                //     $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
-                // }
+            // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){
+            //     $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
+            // }
             //     if($data[$i]->match_status == 2 || $data[$i]->match_status == 3 || $data[$i]->match_status == 5){
             //         if($data[$i]->settle_status == '已结算'){
             //             $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm resettlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/resettlement/?id=" href="javascript:resettlement(\'/admin/SoccerNoteList/resettlement/?id='.$data[$i]->id.'\');"> 重新结算 </a>';
@@ -260,7 +269,7 @@ class SportsNoteList extends BaseModel {
             //     $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结2算 </a>';
             // }
 
-            $data[$i]->content = $data[$i]->content1.$data[$i]->content;
+            $data[$i]->content = $data[$i]->content1 . $data[$i]->content;
 
         }
         return $data->toArray();
@@ -268,7 +277,8 @@ class SportsNoteList extends BaseModel {
     }
 
     //投注金额汇总统计
-    function MoneyCount($where = '',$type) {
+    function MoneyCount($where = '', $type)
+    {
         $data = array();
 //        $data['all_money'] = $this->sum('money');
 //        $data['all_prize_money'] = $this->sum('prize_money');
@@ -276,17 +286,17 @@ class SportsNoteList extends BaseModel {
         $data['all_money'] = 0;
         $data['all_prize_money'] = 0;
         $data['alraedy_prize_money'] = 0;
-        $all_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where('money_buy_simplex.status','1')->get();
-        for($a=0;$a<count($all_money);$a++){
-            $data['all_money'] = $data['all_money']+$all_money[$a]->money;
+        $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.status', '1')->get();
+        for ($a = 0; $a < count($all_money); $a++) {
+            $data['all_money'] = $data['all_money'] + $all_money[$a]->money;
         }
-        $all_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where('money_buy_simplex.status','1')->get();
-        for($a=0;$a<count($all_prize_money);$a++){
-            $data['all_prize_money'] = $data['all_money']+$all_prize_money[$a]->prize_money;
+        $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.status', '1')->get();
+        for ($a = 0; $a < count($all_prize_money); $a++) {
+            $data['all_prize_money'] = $data['all_money'] + $all_prize_money[$a]->prize_money;
         }
-        $alraedy_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status','2')->where('money_buy_simplex.status','1')->get();
-        for($a=0;$a<count($alraedy_prize_money);$a++){
-            $data['alraedy_prize_money'] = $data['all_money']+$alraedy_prize_money[$a]->gain_money;
+        $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status', '2')->where('money_buy_simplex.status', '1')->get();
+        for ($a = 0; $a < count($alraedy_prize_money); $a++) {
+            $data['alraedy_prize_money'] = $data['all_money'] + $alraedy_prize_money[$a]->gain_money;
         }
 
         if (!empty($where) && is_array($where)) {
@@ -296,103 +306,104 @@ class SportsNoteList extends BaseModel {
             //$data['all_money'] = $this->where($where)->sum('money');
 //            $data['all_prize_money'] = $this->where($where)->sum('prize_money');
 //            $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->sum('gain_money');
-            $all_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_zq_competition','st_zq_competition.id','=','money_buy_simplex.match_id')->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where($where)->where('money_buy_simplex.status','1')->get();
-            for($a=0;$a<count($all_money);$a++){
-                $data['all_money'] = $data['all_money']+$all_money[$a]->money;
+            $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_zq_competition', 'st_zq_competition.id', '=', 'money_buy_simplex.match_id')->join('st_zq_league', 'st_zq_competition.lg_id', '=', 'st_zq_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where($where)->where('money_buy_simplex.status', '1')->get();
+            for ($a = 0; $a < count($all_money); $a++) {
+                $data['all_money'] = $data['all_money'] + $all_money[$a]->money;
             }
-            $all_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where($where)->where('money_buy_simplex.status','1')->get();
-            for($a=0;$a<count($all_prize_money);$a++){
-                $data['all_prize_money'] = $data['all_prize_money']+$all_prize_money[$a]->prize_money;
+            $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where($where)->where('money_buy_simplex.status', '1')->get();
+            for ($a = 0; $a < count($all_prize_money); $a++) {
+                $data['all_prize_money'] = $data['all_prize_money'] + $all_prize_money[$a]->prize_money;
             }
-            $alraedy_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status','2')->where($where)->where('money_buy_simplex.status','1')->get();
-            for($a=0;$a<count($alraedy_prize_money);$a++){
-                $data['alraedy_prize_money'] = $data['alraedy_prize_money']+$alraedy_prize_money[$a]->gain_money;
+            $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status', '2')->where($where)->where('money_buy_simplex.status', '1')->get();
+            for ($a = 0; $a < count($alraedy_prize_money); $a++) {
+                $data['alraedy_prize_money'] = $data['alraedy_prize_money'] + $alraedy_prize_money[$a]->gain_money;
             }
         }
 
         return $data;
     }
 
-     //修改赛事下的所有单式下注 3199308
-    function updatesimplex($ssid,$code){
+    //修改赛事下的所有单式下注 3199308
+    function updatesimplex($ssid, $code)
+    {
         $newapp = new \App\Models\MoneyBuyMatch();
-        $data = $newapp->allsimplexorder($ssid,$code);
-        if($data){
-            for ($i=0; $i < count($data); $i++) { 
+        $data = $newapp->allsimplexorder($ssid, $code);
+        if ($data) {
+            for ($i = 0; $i < count($data); $i++) {
                 $the = array(
                     'status' => 2,
                     'game_status' => 3,
-                    'game_code' =>$code,
+                    'game_code' => $code,
                 );
-                $res = $this->where('order_id',$data[$i]['order_id'])->update($the);
+                $res = $this->where('order_id', $data[$i]['order_id'])->update($the);
             }
-            if($res<0){
+            if ($res < 0) {
                 return -7012000302; //操作失败
             }
             return $res;
-        }else{
+        } else {
             return -111;
         }
     }
 
 
-    function info($list = 10, $page, $where = '',$type)
+    function info($list = 10, $page, $where = '', $type)
     {
         $data = $this
-            ->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')
-            ->join('st_'.$type.'_competition','st_'.$type.'_competition.id','=','money_buy_simplex.match_id')
+            ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')
+            ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')
             // ->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')
-            ->join('st_'.$type.'_league','money_buy_simplex.lg_id','=','st_'.$type.'_league.id')
-            ->select('money_buy_simplex.id','money_buy_simplex.account_name','money_buy_simplex.is_champion','money_buy_simplex.account_identity','money_buy_simplex.order_id','money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.status','money_buy_simplex.money_time','money_buy_simplex.settle_status','money_buy_simplex.gain_money','money_buy_simplex.game_code','money_buy_simplex.match_id','money_buy_simplex.game_status','st_'.$type.'_competition.home_team','st_'.$type.'_competition.guest_team','st_'.$type.'_competition.match_date','st_'.$type.'_competition.match_time','st_'.$type.'_competition.lg_id','st_'.$type.'_competition.status as match_status','money_details.money_cash','money_buy_simplex.batch_id','st_'.$type.'_league.name_chinese','st_'.$type.'_league.last_time')
+            ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
+            ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
             ->where($where)
-            ->orderby('money_buy_simplex.money_time','desc')
-            ->paginate ($list);
+            ->orderby('money_buy_simplex.money_time', 'desc')
+            ->paginate($list);
         if (!$data < 0) {
             return -2021052003; //
         }
 
         //反水
-        $water_return_money = \App\Models\Money_details::where('trade_type','7')->get();
+        $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get();
 
         //注单作废
-        $invalid_money = \App\Models\Money_details::where('trade_type','3')->get();
+        $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get();
 
         //订单投注的玩法
-        $content = \App\Models\MoneyBuyMatch::where('bet_type','1')->get();
-        for($d=0;$d<count($content);$d++){
-            if($content[$d]->result==0){
+        $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get();
+        for ($d = 0; $d < count($content); $d++) {
+            if ($content[$d]->result == 0) {
                 $content[$d]->result = '未处理';
             }
-            if($content[$d]->result==1){
+            if ($content[$d]->result == 1) {
                 $content[$d]->result = '赢';
             }
-            if($content[$d]->result==-1){
+            if ($content[$d]->result == -1) {
                 $content[$d]->result = '输';
             }
-            if($content[$d]->result==2){
+            if ($content[$d]->result == 2) {
                 $content[$d]->result = '平';
             }
-            if($content[$d]->result==3){
+            if ($content[$d]->result == 3) {
                 $content[$d]->result = '赢半平半';
             }
-            if($content[$d]->result==4){
+            if ($content[$d]->result == 4) {
                 $content[$d]->result = '输半平半';
             }
         }
 
         //玩法
-        $result = \App\Models\Matchcode::where('game_code',$type)->get();
+        $result = \App\Models\Matchcode::where('game_code', $type)->get();
         //$result = \App\Model\Matchcode::get();
 
 
-        for($i=0;$i<count($data);$i++){
-            if($data[$i]->status==1 && $data[$i]->game_status==0){
-                $data[$i]->order_status = '投注'.'<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id='.$data[$i]->id.'\');"> 作废 </a>';
-            }else if($data[$i]->status==1 && $data[$i]->game_status!=0){
+        for ($i = 0; $i < count($data); $i++) {
+            if ($data[$i]->status == 1 && $data[$i]->game_status == 0) {
+                $data[$i]->order_status = '投注' . '<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\');"> 作废 </a>';
+            } else if ($data[$i]->status == 1 && $data[$i]->game_status != 0) {
                 $data[$i]->order_status = '投注';
-            }else if($data[$i]->status==2){
+            } else if ($data[$i]->status == 2) {
                 $data[$i]->order_status = '作废';
-            }else if($data[$i]->status==3){
+            } else if ($data[$i]->status == 3) {
                 $data[$i]->order_status = '撤单';
             }
             // if($data[$i]->settle_status==1){
@@ -400,36 +411,36 @@ class SportsNoteList extends BaseModel {
             // }else if($data[$i]->settle_status==2){
             //     $data[$i]->settle_status = '已结算';
             // }
-            if($data[$i]->game_status==0){
+            if ($data[$i]->game_status == 0) {
                 $data[$i]->game_status = '未处理';
-            }else{
+            } else {
                 $data[$i]->game_status = '已处理';
             }
 
-            if($data[$i]->game_code == 'zq'){
-                $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'zq') {
+                $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
-            if($data[$i]->game_code == 'lq'){
-                $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'lq') {
+                $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
-            if($data[$i]->game_code == 'wq'){
-                $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'wq') {
+                $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
-            if($data[$i]->game_code == 'bq'){
-                $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team='.$data[$i]->match_id.'">'.$data[$i]->match_id.'</a> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
+            if ($data[$i]->game_code == 'bq') {
+                $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
             }
 
             $data[$i]->league = $data[$i]->name_chinese;
 
-            if($data[$i]->is_champion == 0){
-                $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
-                $data[$i]->time = '开赛:'.$data[$i]->match_date.' '.$data[$i]->match_time;
-            }else{
+            if ($data[$i]->is_champion == 0) {
+                $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team;
+                $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time;
+            } else {
                 $data[$i]->home_guest = '冠军联赛投注';
-                $data[$i]->time = '结束:'.$data[$i]->last_time;
-    
+                $data[$i]->time = '结束:' . $data[$i]->last_time;
+
             }
-            $data[$i]->money_match_time = '下注:'.$data[$i]->money_time.$data[$i]->time;
+            $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time;
 
             /*
             $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
@@ -439,96 +450,96 @@ class SportsNoteList extends BaseModel {
             */
             //反水
             $data[$i]->water_return = -1;
-            for($a=0;$a<count($water_return_money);$a++){
-                if($data[$i]->order_id == $water_return_money[$a]->trade_id){
-                    if($data[$i]->status == 2 || $data[$i]->status == 3){
+            for ($a = 0; $a < count($water_return_money); $a++) {
+                if ($data[$i]->order_id == $water_return_money[$a]->trade_id) {
+                    if ($data[$i]->status == 2 || $data[$i]->status == 3) {
                         $data[$i]->water_return = 0;
-                    }else{
+                    } else {
                         $data[$i]->water_return = $water_return_money[$a]->money;
                     }
                     //用户投注后账户金额
                     $data[$i]->frozen_cash = $water_return_money[$a]->money_cash;
                 }
             }
-            if($data[$i]->water_return == -1){
+            if ($data[$i]->water_return == -1) {
                 $data[$i]->water_return = 0;
                 //用户投注后账户金额
                 $data[$i]->frozen_cash = $data[$i]->money_cash;
             }
             //此时结果金额
-            $data[$i]->result = $data[$i]->water_return+$data[$i]->gain_money;
+            $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money;
             //用户投注前账户金额
-            $data[$i]->available_cash = $data[$i]->money_cash+$data[$i]->money;
+            $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money;
             //投注前后账户金额
-            $data[$i]->account_money = $data[$i]->available_cash.'<br><span>'.$data[$i]->money.'</span><br>'.$data[$i]->frozen_cash;
-            if($data[$i]->status == 2 || $data[$i]->status == 3){
-                for($b=0;$b<count($invalid_money);$b++){
-                    if($data[$i]->order_id == $invalid_money[$b]->trade_id){
+            $data[$i]->account_money = $data[$i]->available_cash . '<br><span>' . $data[$i]->money . '</span><br>' . $data[$i]->frozen_cash;
+            if ($data[$i]->status == 2 || $data[$i]->status == 3) {
+                for ($b = 0; $b < count($invalid_money); $b++) {
+                    if ($data[$i]->order_id == $invalid_money[$b]->trade_id) {
                         $data[$i]->available_cash = $invalid_money[$b]->money_cash;
                         $data[$i]->account_money = $data[$i]->available_cash;
                     }
                 }
             }
             $data[$i]->str = 0;
-            for($b=0;$b<count($content);$b++){
+            for ($b = 0; $b < count($content); $b++) {
                 $data[$i]->str1 = 0;
                 $data[$i]->team = '';
-                if(!empty($content[$b]->odds_code)){
-                    if(!empty(stristr($content[$b]->odds_code,'home'))){
+                if (!empty($content[$b]->odds_code)) {
+                    if (!empty(stristr($content[$b]->odds_code, 'home'))) {
                         $data[$i]->team = $data[$i]->home_team;
                     }
-                    if(!empty(stristr($content[$b]->odds_code,'guest'))){
+                    if (!empty(stristr($content[$b]->odds_code, 'guest'))) {
                         $data[$i]->team = $data[$i]->guest_team;
                     }
-                    if($content[$b]->p_code == 'half_full'){
-                        $string = str_replace('home',$data[$i]->home_team,$content[$b]->odds_code);
-                        $string = str_replace('guest',$data[$i]->guest_team,$string);
-                        $string = str_replace('dogfall','和局',$string);
-                        $string = explode('_',$string);
-                        $data[$i]->team = $string['2'].'/'.$string['3'];
+                    if ($content[$b]->p_code == 'half_full') {
+                        $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code);
+                        $string = str_replace('guest', $data[$i]->guest_team, $string);
+                        $string = str_replace('dogfall', '和局', $string);
+                        $string = explode('_', $string);
+                        $data[$i]->team = $string['2'] . '/' . $string['3'];
                     }
                 }
                 //处理普通赛事
-                if($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id  &&$data[$i]->is_champion == 0){
-                    if($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal'){
+                if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) {
+                    if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
                         $content[$b]->condition = '';
                     }
                     $data[$i]->game_status = $data[$i]->game_status;
                     //投注详情
-                    if(!empty($data[$i]->match_time)){
-                        $data[$i]->content1 = '['.$data[$i]->match_time.']';
+                    if (!empty($data[$i]->match_time)) {
+                        $data[$i]->content1 = '[' . $data[$i]->match_time . ']';
                         //$data[$i]->match_time = $data[$i]->match_time;
-                    }else{
-                        if(!empty($data[$i]->last_time)){
-                            $datetime = explode(' ',$data[$i]->last_time);
+                    } else {
+                        if (!empty($data[$i]->last_time)) {
+                            $datetime = explode(' ', $data[$i]->last_time);
                             //$data[$i]->match_time = $datetime[1];
-                            $data[$i]->content1 = '['.$datetime[1].']';
+                            $data[$i]->content1 = '[' . $datetime[1] . ']';
                         }
                     }
-                    for($c=0;$c<count($result);$c++){
-                        if($content[$b]->odds_code == $result[$c]->odds_code){
+                    for ($c = 0; $c < count($result); $c++) {
+                        if ($content[$b]->odds_code == $result[$c]->odds_code) {
                             $data[$i]->str1 = 1;
-                            if($content[$b]->result=='未处理'){
-                                $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
-                            }else{
-                                $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
+                            if ($content[$b]->result == '未处理') {
+                                $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
+                            } else {
+                                $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
                             }
                         }
                     }
-                    if($data[$i]->str1 == 0){
-                        if($content[$b]->result=='未处理'){
-                            $data[$i]->content = $data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
-                        }else{
-                            $data[$i]->content = $data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
+                    if ($data[$i]->str1 == 0) {
+                        if ($content[$b]->result == '未处理') {
+                            $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
+                        } else {
+                            $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
                         }
                     }
                 }
-                 //处理冠军联赛玩法详情
-                 if($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id &&$data[$i]->is_champion == 1){
+                //处理冠军联赛玩法详情
+                if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) {
 
                     $content[$b]->condition = '';
 
-                    if($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal'){
+                    if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
                         $content[$b]->condition = '';
                     }
 
@@ -560,25 +571,34 @@ class SportsNoteList extends BaseModel {
                         }
                     }
                     */
-                    if($data[$i]->str1 == 0){
-                        if($content[$b]->result=='未处理'){
-                            $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
-                        }else{
-                            $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$content[$b]->odds_code.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
+                    if ($data[$i]->str1 == 0) {
+                        if ($content[$b]->result == '未处理') {
+                            $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
+                        } else {
+                            $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
                         }
                     }
                 }
             }
             $data[$i]->game_status = $data[$i]->settle_status;
-            $data[$i]->content = $data[$i]->content1.$data[$i]->content;
+            $data[$i]->content = $data[$i]->content1 . $data[$i]->content;
         }
         return $data->toArray();
     }
 
     //查询单订单是否存在
-    function onlyorder($orderid){
+    function onlyorder($orderid)
+    {
         $order = $this->where('order_id', $orderid)->count();
         return $order;
     }
 
+    //查询单订单是否存在
+    function getorder($orderid)
+    {
+        $order = $this->with("matchdatas")->where('order_id', $orderid)->first();
+        return $order;
+    }
+
+
 }