Explorar el Código

追加推送 5/30

彭俊 hace 6 años
padre
commit
315f63cbec
Se han modificado 90 ficheros con 3362 adiciones y 467 borrados
  1. 2 2
      app/Http/Controllers/Admin/AdminrootController.php
  2. 1 1
      app/Http/Controllers/Admin/BaseNoteListController.php
  3. 1 1
      app/Http/Controllers/Admin/BasketNoteListController.php
  4. 3 3
      app/Http/Controllers/Admin/IndexController.php
  5. 5 5
      app/Http/Controllers/Admin/MoneyController.php
  6. 7 7
      app/Http/Controllers/Admin/MoveDataController.php
  7. 2 2
      app/Http/Controllers/Admin/NoticeController.php
  8. 1 1
      app/Http/Controllers/Admin/RedpackController.php
  9. 1 1
      app/Http/Controllers/Admin/ReportController.php
  10. 1 1
      app/Http/Controllers/Admin/ReturnController.php
  11. 66 66
      app/Http/Controllers/Admin/SoccerNoteListController.php
  12. 68 69
      app/Http/Controllers/Admin/SoccerStringNoteListController.php
  13. 1 1
      app/Http/Controllers/Admin/SpecialReportController.php
  14. 15 15
      app/Http/Controllers/Admin/SportsBaseController.php
  15. 15 15
      app/Http/Controllers/Admin/SportsBasketController.php
  16. 18 18
      app/Http/Controllers/Admin/SportsSoccerController.php
  17. 15 15
      app/Http/Controllers/Admin/SportsTennisController.php
  18. 80 9
      app/Http/Controllers/Admin/SportsfootController.php
  19. 1 1
      app/Http/Controllers/Admin/TennisNoteListController.php
  20. 9 9
      app/Http/Controllers/Admin/UserController.php
  21. 555 0
      app/Http/Controllers/Api/WriteSportsController.php
  22. 1 1
      app/Http/Controllers/Controller.php
  23. 1 0
      app/Http/Middleware/VerifyCsrfToken.php
  24. 19 0
      app/Http/Model/StBqLeague.php
  25. 17 0
      app/Http/Model/StBqLeagueResult.php
  26. 17 0
      app/Http/Model/StBqLocalLeague.php
  27. 17 0
      app/Http/Model/StBqLocalMatch.php
  28. 19 0
      app/Http/Model/StBqMatch.php
  29. 17 0
      app/Http/Model/StBqOdds.php
  30. 16 0
      app/Http/Model/StBqOddsRecord.php
  31. 16 0
      app/Http/Model/StBqResult.php
  32. 16 0
      app/Http/Model/StBqResultRecord.php
  33. 19 0
      app/Http/Model/StLqLeague.php
  34. 17 0
      app/Http/Model/StLqLeagueResult.php
  35. 17 0
      app/Http/Model/StLqLocalLeague.php
  36. 17 0
      app/Http/Model/StLqLocalMatch.php
  37. 19 0
      app/Http/Model/StLqMatch.php
  38. 17 0
      app/Http/Model/StLqOdds.php
  39. 16 0
      app/Http/Model/StLqOddsRecord.php
  40. 16 0
      app/Http/Model/StLqResult.php
  41. 16 0
      app/Http/Model/StLqResultRecord.php
  42. 19 0
      app/Http/Model/StWqLeague.php
  43. 17 0
      app/Http/Model/StWqLeagueResult.php
  44. 17 0
      app/Http/Model/StWqLocalLeague.php
  45. 17 0
      app/Http/Model/StWqLocalMatch.php
  46. 19 0
      app/Http/Model/StWqMatch.php
  47. 17 0
      app/Http/Model/StWqOdds.php
  48. 16 0
      app/Http/Model/StWqOddsRecord.php
  49. 16 0
      app/Http/Model/StWqResult.php
  50. 16 0
      app/Http/Model/StWqResultRecord.php
  51. 19 0
      app/Http/Model/StZqLeague.php
  52. 17 0
      app/Http/Model/StZqLeagueResult.php
  53. 17 0
      app/Http/Model/StZqLocalLeague.php
  54. 17 0
      app/Http/Model/StZqLocalMatch.php
  55. 19 0
      app/Http/Model/StZqMatch.php
  56. 16 0
      app/Http/Model/StZqOdds.php
  57. 16 0
      app/Http/Model/StZqOddsRecord.php
  58. 16 0
      app/Http/Model/StZqResult.php
  59. 16 0
      app/Http/Model/StZqResultRecord.php
  60. 35 0
      app/Http/Model/St_area_country.php
  61. 80 0
      app/Http/Response/Response.php
  62. 1021 0
      app/Lib/Biz/Sport/Common.php
  63. 287 130
      app/Lib/Settlement/SettlementOrder.php
  64. 7 5
      app/Lib/Settlement/SettlementWinFail.php
  65. 38 1
      app/Models/MoneyBuyMatch.php
  66. 63 16
      app/Models/MoneyBuyStr.php
  67. 1 1
      app/Models/NagentCountrecord.php
  68. 1 1
      app/Models/Rgame_setting.php
  69. 27 0
      app/Models/SettlementMiddleDetail.php
  70. 5 5
      app/Models/SportsBase.php
  71. 5 5
      app/Models/SportsBasket.php
  72. 72 13
      app/Models/SportsNoteList.php
  73. 5 5
      app/Models/SportsSoccer.php
  74. 5 5
      app/Models/SportsTennis.php
  75. 1 13
      app/Models/Stzqresult.php
  76. 1 1
      app/Models/System_user.php
  77. 19 0
      app/Models/ZqLeagueResult.php
  78. 0 0
      public/admin/frame/echarts/echarts.min.js
  79. 0 0
      public/frame/echarts/echarts.min.js
  80. 1 0
      public/function.php
  81. 0 0
      resources/assets/vip/frame/echarts/echarts.min.js
  82. 2 0
      resources/lang/zh-cn/sportsbk.php
  83. 1 1
      resources/lang/zh-cn/sportsfoot.php
  84. 1 0
      resources/lang/zh-cn/sportsnotelist.php
  85. 7 0
      resources/lang/zh-cn/status.php
  86. 104 15
      resources/views/admin/sportsfoot/outcome.blade.php
  87. 46 7
      resources/views/sports/sports_notelist.blade.php
  88. 38 0
      resources/views/sports/sports_stringnotelist.blade.php
  89. 1 0
      routes/api.php
  90. 4 0
      routes/web.php

+ 2 - 2
app/Http/Controllers/Admin/AdminrootController.php

@@ -140,8 +140,8 @@ class AdminrootController extends Controller {
 		if (empty($id)) {
 			abort(404);
 		}
-		$root_db = new \App\Models\System_root;
-		$menu = new \App\Models\NewMenu;
+		$root_db = new \App\Model\System_root;
+		$menu = new \App\Model\NewMenu;
 		if (!$req->isMethod('post')) {
 			$root = $root_db->getRootDetails($id, 1);
 			$menudata = $menu->getMenuAll();

+ 1 - 1
app/Http/Controllers/Admin/BaseNoteListController.php

@@ -97,7 +97,7 @@ class BaseNoteListController extends Controller
             $odds_only = $data->odds_only;
             $res = DB::table('st_bq_odds_record')->where('odds_only',$odds_only)->first();
             $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
-            //$result = \App\Models\Matchcode::where('odds_code',$res->odds_code)->first();
+            //$result = \App\Model\Matchcode::where('odds_code',$res->odds_code)->first();
             $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
             $data->content = $data->content.$result['odds_name'].  '¥'.$codes[$j]['bet_amount'];
             $data->game = $game->game_name;

+ 1 - 1
app/Http/Controllers/Admin/BasketNoteListController.php

@@ -97,7 +97,7 @@ class BasketNoteListController extends Controller
             $odds_only = $data->odds_only;
             $res = DB::table('st_zq_odds_record')->where('odds_only',$odds_only)->first();
             $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
-            //$result = \App\Models\Matchcode::where('odds_code',$res->odds_code)->first();
+            //$result = \App\Model\Matchcode::where('odds_code',$res->odds_code)->first();
             $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
             $data->content = $data->content.$result['odds_name'].  '¥'.$codes[$j]['bet_amount'];
             $data->game = $game->game_name;

+ 3 - 3
app/Http/Controllers/Admin/IndexController.php

@@ -168,7 +168,7 @@ class IndexController extends Controller {
         } else {
             $return['money_count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->sum('money');
         }
-//		$return['user_count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
+//		$return['user_count'] = \App\Model\Money_return::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
         if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn_user') < 0) {
             $db = new \App\Models\Money_return;
             $return['user_count'] = "*****";
@@ -236,8 +236,8 @@ class IndexController extends Controller {
 
     //当前在线用户饼状图
     function onlineUser() {
-//		$db = new \App\Models\Logfile;
-//		$db=new \App\Models\Account_Token;
+//		$db = new \App\Model\Logfile;
+//		$db=new \App\Model\Account_Token;
         $db = new \App\Models\Account_detailed;
         $data_log = $db->getOnlineUser();
 //		$data_log = $db->getUser();

+ 5 - 5
app/Http/Controllers/Admin/MoneyController.php

@@ -727,7 +727,7 @@ class MoneyController extends Controller
             $where[] = array('money_time', '<=', $end_time);
         }
 
-//        $user= new \App\Models\Account;
+//        $user= new \App\Model\Account;
 //        $users=$user->Accounta($user_where);
         $moneyreturn = new \App\Models\MoneyBuy();
 //		if ($users > 0){
@@ -1152,11 +1152,11 @@ class MoneyController extends Controller
         $data['rimit'] = $model::where('status', 0)->where('recharge_type', '汇款')->count();
         $data['take'] = \App\Models\Money_take::where('status', 0)->count();
         $data['vip'] = \App\Models\Uservip::where('status', 1)->count();
-        // $data['back'] = \App\Models\Oggame_transfer_record::where('type', 3)->count();
-        // $data['lotteryMoney'] = \App\Models\LotteryMoneyLog::where('status', 0)->count();//待审核彩金条数
-        // $msg_db = new \App\Models\MessageRead;
+        // $data['back'] = \App\Model\Oggame_transfer_record::where('type', 3)->count();
+        // $data['lotteryMoney'] = \App\Model\LotteryMoneyLog::where('status', 0)->count();//待审核彩金条数
+        // $msg_db = new \App\Model\MessageRead;
         // $data['msg'] = $msg_db->countNoReade (session ('adminInfo.admin_id'));
-        // $data['agent'] = \App\Models\Agent_detailed::where ('status', 0)->count ('id');
+        // $data['agent'] = \App\Model\Agent_detailed::where ('status', 0)->count ('id');
         return responseToJson($data);
     }
 

+ 7 - 7
app/Http/Controllers/Admin/MoveDataController.php

@@ -58,13 +58,13 @@ class MoveDataController extends Controller
         $sql = 'select * from account';
         $data = $this->select($db,$sql);
         
-        $clslog = '\App\Models\Account_list';
-        $cls = '\App\Models\Account';
-        $bank = '\App\Models\Account_bank';
-        $group = '\App\Models\Account_group';
-        $userpwd = '\App\Models\Account_password';
-        $usertoken = '\App\Models\Account_Token';
-        $uservip = '\App\Models\Uservip';
+        $clslog = '\App\Model\Account_list';
+        $cls = '\App\Model\Account';
+        $bank = '\App\Model\Account_bank';
+        $group = '\App\Model\Account_group';
+        $userpwd = '\App\Model\Account_password';
+        $usertoken = '\App\Model\Account_Token';
+        $uservip = '\App\Model\Uservip';
         if (!$req->isMethod('post')) {
             if($ids=='all'){
                 $unum = $this->select($db,$sql,2);

+ 2 - 2
app/Http/Controllers/Admin/NoticeController.php

@@ -60,7 +60,7 @@ class NoticeController extends Controller{
 			}
 			$datas = new \App\Models\LotteryMoney();
         	$arr = $datas->getlist();
-//        	$admin = \App\Models\TypeName::getAllType();
+//        	$admin = \App\Model\TypeName::getAllType();
         $selectdata = $acticle_type->type();
             $_selectdata =   $this->getTree($selectdata);
             $select =    $data["type"];
@@ -124,7 +124,7 @@ class NoticeController extends Controller{
         	$datas = new \App\Models\LotteryMoney();
         	$arr = $datas->getlist();
 
-        //	$admin = \App\Models\TypeName::getAllType();
+        //	$admin = \App\Model\TypeName::getAllType();
             $selectdata = $acticle_type->type();
 
             //查出优惠活动的子类

+ 1 - 1
app/Http/Controllers/Admin/RedpackController.php

@@ -70,7 +70,7 @@ class RedpackController extends Controller{
         $data=$db->getList($list,$where);
 
         foreach ($data['data'] as $k=>$v){
-            // $user_info=\App\Models\Account::where('identity',$v['account_identity'])->first()->toArray();
+            // $user_info=\App\Model\Account::where('identity',$v['account_identity'])->first()->toArray();
             // $data['data'][$k]['user_name']=$user_info['account'];
             $data['data'][$k]['type_name']=$langinfo['type'][$v['type']];
             // $data['data'][$k]['room_name']='';

+ 1 - 1
app/Http/Controllers/Admin/ReportController.php

@@ -175,7 +175,7 @@ class ReportController extends Controller {
            /* $nodatas=array();
             $effectivemoney=array();
             if (empty($name)) {
-                $gameList=\App\Models\GameType::getGameType();
+                $gameList=\App\Model\GameType::getGameType();
                 foreach ($gameList as $kg=>$vg){
                     $nodata=DB::Select("select info_no from game_".$vg["gameCode"]." where open_time >='".$star_time."' and open_time <='".$end_time."'");
                     $nodatas=array_merge($nodatas,array_column($nodata,'info_no'));

+ 1 - 1
app/Http/Controllers/Admin/ReturnController.php

@@ -67,7 +67,7 @@ class ReturnController extends Controller {
 		if (empty($order_id)) {
 			abort(404);
 		}
-//        $back_db=new \App\Models\Money_return;
+//        $back_db=new \App\Model\Money_return;
 		$money_db = new \App\Models\Money_details;
 		$account_db = new \App\Models\Account;
 		$bank_db = new \App\Models\Account_bank;

+ 66 - 66
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -30,22 +30,24 @@ class SoccerNoteListController extends Controller
         $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';
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SoccerNoteList/info');
         $dt->setLang('sportsnotelist');
         //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
         $dt->addColsFields('match_id_order', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
-        $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
-        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
-        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 240));
+        $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
         $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
-        $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
         $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
-        $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
         $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
-        $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
-        $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
+        $dt->addColsFields('order_status', array('sort' => false, 'width' => 90));
+        $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
+        $dt->addColsFields('game_status', array('sort' => false, 'width' => 80));
         //$arr[] = 'view';
 //        if (checkRriv('/admin/SoccerNoteList/edit')) {
 //            $arr[] = 'edit';
@@ -65,6 +67,7 @@ class SoccerNoteListController extends Controller
         $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') : '';
+        $order_status = Request::has('order_status') ? Request::get('order_status') : '';
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $type = Request::has('type') ? Request::get('type') : 'zq';
         $where = array();
@@ -97,6 +100,9 @@ class SoccerNoteListController extends Controller
         if ($status != -1) {
             $where[] = array('money_buy_simplex.settle_status', '=', $status);
         }
+        if ($order_status != -1) {
+            $where[] = array('money_buy_simplex.status', '=', $order_status);
+        }
         $where[] = array('money_buy_simplex.game_code', $type);
         $newapp = new \App\Models\SportsNoteList();
         $data = $newapp->getinfo($list, $page, $where,$type);
@@ -104,6 +110,59 @@ class SoccerNoteListController extends Controller
         return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
     }
 
+    /**
+     *单式注单作废
+     */
+    public function invalid(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = \App\Models\SportsNoteList::where('id',$id)->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 = $water_return_money->money;
+        }else{
+            $water_return = 0;
+        }
+        //撤单后用户账户金额
+        $available_cash = $account_money->available_cash;
+        $new_available_cash = $available_cash+$order->money-$order->gain_money-$water_return;
+
+        $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_type = '1';
+        }else{
+            $model->money_type = '2';
+        }
+        $model->money_cash = $new_available_cash;
+        $model->trade_type = '3';
+        $model->trade_desc = '管理员作废单式注单';
+        $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]);
+            $model->save();
+
+            DB::commit();//提交
+            return 1;
+        } catch (Exception $e) {
+            DB::rollback();//回滚
+            return -1;
+        }
+    }
+
     /**
      *单式注单结算
      */
@@ -138,64 +197,6 @@ class SoccerNoteListController extends Controller
         $bet_type = 1;//单式注单
         $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
         return $data;
-
-        //获取此订单下包含的赛事玩法
-        $matchs = \App\Models\MoneyBuyMatch::where('batch_id',$order->batch_id)->where('match_id',$order->match_id)->where('bet_type','1')->get()->toArray();
-        $win_money = 0;
-
-        //减本金
-//        for($i=0;$i<count($matchs);$i++){
-//            $money = $matchs[$i]->bet_money;
-//            if($matchs[$i]->result == 0){            //未处理
-//                return "<script>history.go(-1);</script>";
-//            }else if($matchs[$i]->result == -1){     //输
-//                $money = 0-$matchs[$i]->bet_money;
-//            }else if($matchs[$i]->result == 1){      //赢
-//                $odds = $matchs[$i]->odds;
-//                $money = $money*$odds-$matchs[$i]->bet_money;
-//            }else if($matchs[$i]->result == 2){      //平
-//                $money = 0;
-//            }else if($matchs[$i]->result == 3){      //赢半平半
-//                $odds = $matchs[$i]->odds;
-//                $money = $money/2*$odds+$money/2*1-$matchs[$i]->bet_money;
-//            }else if($matchs[$i]->result == 4){      //输半平半
-//                $money = $money/2*1-$matchs[$i]->bet_money;
-//            }
-//            $win_money = $win_money+$money;
-//        }
-
-        //不减本金
-        for($i=0;$i<count($matchs);$i++){
-            $money = $matchs[$i]->bet_money;
-            if($matchs[$i]->result == 0){            //未处理
-                return "<script>history.go(-1);</script>";
-            }else if($matchs[$i]->result == -1){     //输
-                $money = 0;
-            }else if($matchs[$i]->result == 1){      //赢
-                $odds = $matchs[$i]->odds;
-                $money = $money*$odds;
-            }else if($matchs[$i]->result == 2){      //平
-                $money = $money*1;
-            }else if($matchs[$i]->result == 3){      //赢半平半
-                $odds = $matchs[$i]->odds;
-                $money = $money/2*$odds+$money/2*1;
-            }else if($matchs[$i]->result == 4){      //输半平半
-                $money = $money/2*1;
-            }
-            $win_money = $win_money+$money;
-        }
-
-        $model = new \App\Models\SportsNoteList();
-        $model = $model::find($id);
-        if($win_money < $order->money){
-            $model->game_status = 2;
-        }else if($win_money >= $order->money){
-            $model->game_status = 1;
-        }
-        $model->settle_status = 2;
-        $model->gain_money = $win_money;
-        $model->save();
-        return "<script>history.go(-1);</script>";
     }
 
     /**
@@ -214,7 +215,6 @@ class SoccerNoteListController extends Controller
                 $order_ids[] = $orders[$i]->order_id;
             }
         }
-        //return $order_ids;
         $SettlementOrder = new SettlementOrder();
         $bet_type = 1;//单式注单
         $data = $SettlementOrder->reSettlement($order_ids,$bet_type);

+ 68 - 69
app/Http/Controllers/Admin/SoccerStringNoteListController.php

@@ -29,20 +29,22 @@ class SoccerStringNoteListController extends Controller
         $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['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SoccerStringNoteList/info');
         $dt->setLang('sportsnotelist');
         //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
         $dt->addColsFields('order_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
-        $dt->addColsFields('str_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('str_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
         $dt->addColsFields('detail_content', array('sort' => false, 'width' => 150));
         $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
         $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
-        $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
         $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
         $dt->addColsFields('money_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
-        $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 240));
-        $dt->addColsFields('settle_status', array('sort' => false, 'width' => 100));
+        $dt->addColsFields('order_status', array('sort' => false, 'width' => 90));
+        $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 230));
+        $dt->addColsFields('settle_status', array('sort' => false, 'width' => 80));
 //        if (checkRriv('/admin/SoccerStringNoteList/edit')) {
 //            $arr[] ='edit';
 //        }
@@ -60,6 +62,7 @@ class SoccerStringNoteListController extends Controller
         $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
         $order_id = Request::get('order_id') ? Request::get('order_id') : '';
         $status = Request::has('status') ? Request::get('status') : '';
+        $order_status = Request::has('order_status') ? Request::get('order_status') : '';
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $where = array();
         if (!empty($account)) {
@@ -88,6 +91,9 @@ class SoccerStringNoteListController extends Controller
         if ($status != -1) {
             $where[] = array('money_buy_str.settle_status', '=', $status);
         }
+        if ($order_status != -1) {
+            $where[] = array('money_buy_str.status', '=', $order_status);
+        }
         $newapp = new \App\Models\MoneyBuyStr();
         $data = $newapp->getinfo($list, $page, $where);
 
@@ -108,8 +114,8 @@ class SoccerStringNoteListController extends Controller
         $dt->setLang('sportsnotelist');
         $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
         $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
-        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
-        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 220));
         $dt->addColsFields('game_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
         $dt->addColsFields('time', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
         $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
@@ -126,6 +132,61 @@ class SoccerStringNoteListController extends Controller
         return \App\Lib\DataTable\DataTable::init()->toJson($data);
     }
 
+    /**
+     *串关注单作废
+     */
+    public function invalid(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        //return 1;
+        $order = \App\Models\MoneyBuyStr::where('id',$id)->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 = $water_return_money->money;
+        }else{
+            $water_return = 0;
+        }
+        //撤单后用户账户金额
+        $available_cash = $account_money->available_cash;
+        $new_available_cash = $available_cash+$order->money-$order->gain_money-$water_return;
+
+        $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_type = '1';
+        }else{
+            $model->money_type = '2';
+        }
+        $model->money_cash = $new_available_cash;
+        $model->trade_type = '3';
+        $model->trade_desc = '管理员作废串关注单';
+        $model->status = '1';
+        try {
+            DB::beginTransaction();//开启事务
+            \App\Models\MoneyBuyStr::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();//提交
+            return 1;
+        } catch (Exception $e) {
+            DB::rollback();//回滚
+            return -1;
+        }
+
+
+    }
+
     /**
      *串关注单结算
      */
@@ -160,68 +221,6 @@ class SoccerStringNoteListController extends Controller
         $bet_type = 2; //串关注单
         $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
         return  $data;
-
-        $m = explode('串',$order->str_type);
-        //获取此订单下包含的赛事
-        $matchs = \App\Models\MoneyBuyMatch::where('batch_id',$order->batch_id)->where('bet_type',2)->get()->toArray();
-        function combination($a, $m) {
-            $r = array();
-            $n = count($a);
-            if ($m <= 0 || $m > $n) {
-                return $r;
-            }
-            for ($i=0; $i<$n; $i++) {
-                $t = array($a[$i]);
-                if ($m == 1) {
-                    $r[] = $t;
-                } else {
-                    $b = array_slice($a, $i+1);
-                    $c = combination($b, $m-1);
-                    foreach ($c as $v) {
-                        $r[] = array_merge($t, $v);
-                    }
-                }
-            }
-            return $r;
-        }
-        $arr = combination($matchs,$m[0]);
-        $win_money = 0;
-        for($i=0;$i<count($arr);$i++){
-            $money = $order->money/count($arr);
-            for($j=0;$j<count($arr[$i]);$j++){
-                 if($arr[$i][$j]->result == 0){           //未处理
-                     return "<script>history.go(-1);</script>";
-                 }else if($arr[$i][$j]->result == -1){    //输
-                    $win_money = 0;
-                    $model = new \App\Models\MoneyBuyStr();
-                    $model = $model::find($id);
-                    $model->gain_money = $win_money;
-                    $model->save();
-                    return "<script>history.go(-1);</script>";
-                }else if($arr[$i][$j]->result == 1){      //赢
-                    $odds = $arr[$i][$j]->odds;
-                    $money = $money*$odds;
-                }else if($arr[$i][$j]->result == 2){      //平
-                    $money = $money*1;
-                }else if($arr[$i][$j]->result == 3){      //赢半平半
-                    $odds = $arr[$i][$j]->odds;
-                    $money = $money/2*$odds+$money/2*1;
-                }else if($arr[$i][$j]->result == 4){      //输半平半
-                    $money = $money/2*1;
-                }
-            }
-            //减本金
-            //  $win_money = $win_money+$money-$order->money/count($arr);
-
-            //不减本金
-            $win_money = $win_money+$money;
-        }
-        $model = new \App\Models\MoneyBuyStr();
-        $model = $model::find($id);
-        $model->settle_status = 2;
-        $model->gain_money = $win_money;
-        $model->save();
-        return 1;
     }
 
     /**
@@ -250,7 +249,7 @@ class SoccerStringNoteListController extends Controller
     /**
      *删除串关注单
      */
-    public function deletel(Req $req) {
+    public function delete(Req $req) {
         $id = $req->input('id');
         if (empty($id)) {
             return responseToJson(-2001); //id������

+ 1 - 1
app/Http/Controllers/Admin/SpecialReportController.php

@@ -53,7 +53,7 @@ class SpecialReportController extends Controller {
 		$game = Request::has('game') ? Request::get('game') : 'sixlottery';
 		$where[] = array('delstatus','=',1);
 		$cls = '\App\Models\Game' . ucfirst($game);
-		$clsbuy = '\\App\\Models\\' . ucfirst($game) . 'Buy';
+		$clsbuy = '\\App\\Model\\' . ucfirst($game) . 'Buy';
 		if(empty($info_no)){
 			$gameno =new $cls;
 			$gamenofirst = $gameno->getGameno();

+ 15 - 15
app/Http/Controllers/Admin/SportsBaseController.php

@@ -22,11 +22,11 @@ class SportsBaseController extends Controller {
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
-//            $data = \App\Models\BaseLeague::join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')->select('st_bq_league.id','st_bq_league.name_chinese')->where('st_bq_local_league.source',$source->infocontent)->get();
+//            $data = \App\Model\BaseLeague::join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')->select('st_bq_league.id','st_bq_league.name_chinese')->where('st_bq_local_league.source',$source->infocontent)->get();
 //        }else{
-//            $data = \App\Models\BaseLeague::select('id','name_chinese')->get();
+//            $data = \App\Model\BaseLeague::select('id','name_chinese')->get();
 //        }
 
         $data = \App\Models\BaseLeague::select('id','lg_id','name_chinese')->get();
@@ -111,11 +111,11 @@ class SportsBaseController extends Controller {
      */
     function getParent() {
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
-//            $data = \App\Models\BaseLeague::join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')->select('st_bq_league.id','st_bq_league.name_chinese')->where('st_bq_local_league.source',$source->infocontent)->get();
+//            $data = \App\Model\BaseLeague::join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')->select('st_bq_league.id','st_bq_league.name_chinese')->where('st_bq_local_league.source',$source->infocontent)->get();
 //        }else{
-//            $data = \App\Models\BaseLeague::select('id','name_chinese')->get();
+//            $data = \App\Model\BaseLeague::select('id','name_chinese')->get();
 //        }
 
         $data = \App\Models\BaseLeague::select('id','lg_id','name_chinese')->get();
@@ -208,10 +208,10 @@ class SportsBaseController extends Controller {
                 return -2;
             }
             $name_chinese = \App\Models\BaseLeague::where('lg_id', $data->lg_id)->first();
-//            $home_team = \App\Models\Team::where('team_name_cn', $data->home_team)->first();
-//            $guest_team = \App\Models\Team::where('team_name_cn', $data->guest_team)->first();
-//            $home_country = \App\Models\Country::where('country_id', $home_team->country_id)->first();
-//            $guest_country = \App\Models\Country::where('country_id', $guest_team->country_id)->first();
+//            $home_team = \App\Model\Team::where('team_name_cn', $data->home_team)->first();
+//            $guest_team = \App\Model\Team::where('team_name_cn', $data->guest_team)->first();
+//            $home_country = \App\Model\Country::where('country_id', $home_team->country_id)->first();
+//            $guest_country = \App\Model\Country::where('country_id', $guest_team->country_id)->first();
             $data->name_chinese = $name_chinese->name_chinese;
 //            $data->home_country_id = $home_country->country_id;
 //            $data->guest_country_id = $guest_country->country_id;
@@ -240,7 +240,7 @@ class SportsBaseController extends Controller {
 //                $model->lg_id = $req->input('parent_id');
 //            }else{
 //                $model->name_chinese = $req->input('parent_id');
-//                $res = \App\Models\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
 //                $model->lg_id = $res->lg_id;
 //            }
             $model->lg_id = $req->input('parent_id');
@@ -311,7 +311,7 @@ class SportsBaseController extends Controller {
         }
         $request['match_id'] = isset($match_id) ? trim($match_id) : null;
 
-        //$data = \App\Models\Matchcode::where('p_id','0')->get();
+        //$data = \App\Model\Matchcode::where('p_id','0')->get();
 
         $data = \App\Models\Matchcode::where('p_id','0')->where('game_code','bq')->get();
         $request['pcode'] = $data;
@@ -384,7 +384,7 @@ class SportsBaseController extends Controller {
      */
     function addodds(Req $req) {
 
-        //$pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
 
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','bq')->get();
         for($i=0;$i<count($pcodedata);$i++){
@@ -461,7 +461,7 @@ class SportsBaseController extends Controller {
 
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
 
-        //$pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','bq')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->where('game_code','bq')->get();
         for($i=0;$i<count($pcodedata);$i++){
             $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
         }
@@ -478,7 +478,7 @@ class SportsBaseController extends Controller {
 
             $res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
 
-            //$res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->where('game_type','bq')->first();
+            //$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','bq')->first();
             if(!empty($res)){
                 $data->odds_name = $res->odds_name;
             }

+ 15 - 15
app/Http/Controllers/Admin/SportsBasketController.php

@@ -22,11 +22,11 @@ class SportsBasketController extends Controller {
 		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
 		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
-//            $data = \App\Models\BasketLeague::join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')->select('st_lq_league.id','st_lq_league.name_chinese')->where('st_lq_local_league.source',$source->infocontent)->get();
+//            $data = \App\Model\BasketLeague::join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')->select('st_lq_league.id','st_lq_league.name_chinese')->where('st_lq_local_league.source',$source->infocontent)->get();
 //        }else{
-//            $data = \App\Models\BasketLeague::select('id','name_chinese')->get();
+//            $data = \App\Model\BasketLeague::select('id','name_chinese')->get();
 //        }
 
 		$data = \App\Models\BasketLeague::select('id','lg_id','name_chinese')->get();
@@ -113,11 +113,11 @@ class SportsBasketController extends Controller {
 	 */
 	function getParent() {
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
-//            $data = \App\Models\BasketLeague::join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')->select('st_lq_league.id','st_lq_league.name_chinese')->where('st_lq_local_league.source',$source->infocontent)->get();
+//            $data = \App\Model\BasketLeague::join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')->select('st_lq_league.id','st_lq_league.name_chinese')->where('st_lq_local_league.source',$source->infocontent)->get();
 //        }else{
-//            $data = \App\Models\BasketLeague::select('id','name_chinese')->get();
+//            $data = \App\Model\BasketLeague::select('id','name_chinese')->get();
 //        }
 
 		$data = \App\Models\BasketLeague::select('id','lg_id','name_chinese')->get();
@@ -210,10 +210,10 @@ class SportsBasketController extends Controller {
 				return -2;
 			}
 			$name_chinese = \App\Models\BasketLeague::where('lg_id', $data->lg_id)->first();
-//            $home_team = \App\Models\Team::where('team_name_cn', $data->home_team)->first();
-//            $guest_team = \App\Models\Team::where('team_name_cn', $data->guest_team)->first();
-//            $home_country = \App\Models\Country::where('country_id', $home_team->country_id)->first();
-//            $guest_country = \App\Models\Country::where('country_id', $guest_team->country_id)->first();
+//            $home_team = \App\Model\Team::where('team_name_cn', $data->home_team)->first();
+//            $guest_team = \App\Model\Team::where('team_name_cn', $data->guest_team)->first();
+//            $home_country = \App\Model\Country::where('country_id', $home_team->country_id)->first();
+//            $guest_country = \App\Model\Country::where('country_id', $guest_team->country_id)->first();
 			$data->name_chinese = $name_chinese->name_chinese;
 //            $data->home_country_id = $home_country->country_id;
 //            $data->guest_country_id = $guest_country->country_id;
@@ -242,7 +242,7 @@ class SportsBasketController extends Controller {
 //                $model->lg_id = $req->input('parent_id');
 //            }else{
 //                $model->name_chinese = $req->input('parent_id');
-//                $res = \App\Models\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
 //                $model->lg_id = $res->lg_id;
 //            }
 			$model->lg_id = $req->input('parent_id');
@@ -312,7 +312,7 @@ class SportsBasketController extends Controller {
 			$match_id = $newapp->match_id;
 		}
 		$request['match_id'] = isset($match_id) ? trim($match_id) : null;
-		//$data = \App\Models\Matchcode::where('p_id','0')->get();
+		//$data = \App\Model\Matchcode::where('p_id','0')->get();
 		$data = \App\Models\Matchcode::where('p_id','0')->where('game_code','lq')->get();
 		$request['pcode'] = $data;
 		$dt = \App\Lib\DataTable\DataTable::init();
@@ -383,7 +383,7 @@ class SportsBasketController extends Controller {
 	 *添加赔率
 	 */
 	function addodds(Req $req) {
-		//$pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+		//$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
 		$pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','lq')->get();
 		for($i=0;$i<count($pcodedata);$i++){
 			$pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
@@ -456,7 +456,7 @@ class SportsBasketController extends Controller {
 	 *修改赔率
 	 */
 	function oddsedit(Req $req) {
-		//$pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+		//$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
 		$pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','lq')->get();
 		for($i=0;$i<count($pcodedata);$i++){
 			$pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
@@ -471,7 +471,7 @@ class SportsBasketController extends Controller {
 			if (!$data) {
 				return -2;
 			}
-			//$res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->where('game_type','lq')->first();
+			//$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','lq')->first();
 			$res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
 			if(!empty($res)){
 				$data->odds_name = $res->odds_name;

+ 18 - 18
app/Http/Controllers/Admin/SportsSoccerController.php

@@ -22,11 +22,11 @@ class SportsSoccerController extends Controller {
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\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();
+//            $data = \App\Model\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();
+//            $data = \App\Model\SoccerLeague::select('id','name_chinese')->get();
 //        }
 
         $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
@@ -109,11 +109,11 @@ class SportsSoccerController extends Controller {
      *获取所有足球联赛信息
      */
     function getParent() {
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\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();
+//            $data = \App\Model\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();
+//            $data = \App\Model\SoccerLeague::select('id','name_chinese')->get();
 //        }
 
         $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
@@ -208,10 +208,10 @@ class SportsSoccerController extends Controller {
                 return -2;
             }
             $name_chinese = \App\Models\SoccerLeague::where('lg_id', $data->lg_id)->first();
-//            $home_team = \App\Models\Team::where('team_name_cn', $data->home_team)->first();
-//            $guest_team = \App\Models\Team::where('team_name_cn', $data->guest_team)->first();
-//            $home_country = \App\Models\Country::where('country_id', $home_team->country_id)->first();
-//            $guest_country = \App\Models\Country::where('country_id', $guest_team->country_id)->first();
+//            $home_team = \App\Model\Team::where('team_name_cn', $data->home_team)->first();
+//            $guest_team = \App\Model\Team::where('team_name_cn', $data->guest_team)->first();
+//            $home_country = \App\Model\Country::where('country_id', $home_team->country_id)->first();
+//            $guest_country = \App\Model\Country::where('country_id', $guest_team->country_id)->first();
             $data->name_chinese = $name_chinese->name_chinese;
 //            $data->home_country_id = $home_country->country_id;
 //            $data->guest_country_id = $guest_country->country_id;
@@ -228,7 +228,7 @@ class SportsSoccerController extends Controller {
                     $data['parents'][$k]['name_chinese']=$lange[$arr];
                 }
             }
-
+// var_dump($data);die;
             return view('sports.soccer_form', $data);
         } else {
             $model = new \App\Models\SportsSoccer();
@@ -240,7 +240,7 @@ class SportsSoccerController extends Controller {
 //                $model->lg_id = $req->input('parent_id');
 //            }else{
 //                $model->name_chinese = $req->input('parent_id');
-//                $res = \App\Models\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
 //                $model->lg_id = $res->lg_id;
 //            }
             $model->lg_id = $req->input('parent_id');
@@ -311,7 +311,7 @@ class SportsSoccerController extends Controller {
         }
         $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')->get();
+        //$data = \App\Model\Matchcode::where('p_id','0')->get();
         $request['pcode'] = $data;
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SportsSoccer/oddsinfo?match_id='.$match_id.'');
@@ -382,7 +382,7 @@ class SportsSoccerController extends Controller {
      */
     function addodds(Req $req) {
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
-        //$pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
         for($i=0;$i<count($pcodedata);$i++){
             $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
         }
@@ -456,7 +456,7 @@ class SportsSoccerController extends Controller {
     function oddsedit(Req $req) {
         $lange = trans('sportsoddscode');
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
-        //$pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
         for($i=0;$i<count($pcodedata);$i++){
             $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
         }
@@ -470,16 +470,16 @@ class SportsSoccerController extends Controller {
             if (!$data) {
                 return -2;
             }
-            //$res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->where('game_type','zq')->first();
+            //$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)){
                 $data->odds_name = $res->odds_name;
             }
-//            $res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
+//            $res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->first();
 //            if(!empty($res)){
 //                $data->odds_code = $res->odds_name;
 //            }
-//            $res1 = \App\Models\Matchcode::where('odds_code', $data->p_code)->first();
+//            $res1 = \App\Model\Matchcode::where('odds_code', $data->p_code)->first();
 //            if(!empty($res)){
 //                $data->p_code = $res1->odds_name;
 //            }

+ 15 - 15
app/Http/Controllers/Admin/SportsTennisController.php

@@ -22,11 +22,11 @@ class SportsTennisController extends Controller {
         $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
-//            $data = \App\Models\TennisLeague::join('st_wq_local_league','st_wq_league.id','=','st_wq_local_league.lg_id')->select('st_wq_league.id','st_wq_league.name_chinese')->where('st_wq_local_league.source',$source->infocontent)->get();
+//            $data = \App\Model\TennisLeague::join('st_wq_local_league','st_wq_league.id','=','st_wq_local_league.lg_id')->select('st_wq_league.id','st_wq_league.name_chinese')->where('st_wq_local_league.source',$source->infocontent)->get();
 //        }else{
-//            $data = \App\Models\TennisLeague::select('id','name_chinese')->get();
+//            $data = \App\Model\TennisLeague::select('id','name_chinese')->get();
 //        }
 
         $data = \App\Models\TennisLeague::select('id','lg_id','name_chinese')->get();
@@ -112,11 +112,11 @@ class SportsTennisController extends Controller {
      */
     function getParent() {
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
-//            $data = \App\Models\TennisLeague::join('st_wq_local_league','st_wq_league.id','=','st_wq_local_league.lg_id')->select('st_wq_league.id','st_wq_league.name_chinese')->where('st_wq_local_league.source',$source->infocontent)->get();
+//            $data = \App\Model\TennisLeague::join('st_wq_local_league','st_wq_league.id','=','st_wq_local_league.lg_id')->select('st_wq_league.id','st_wq_league.name_chinese')->where('st_wq_local_league.source',$source->infocontent)->get();
 //        }else{
-//            $data = \App\Models\TennisLeague::select('id','name_chinese')->get();
+//            $data = \App\Model\TennisLeague::select('id','name_chinese')->get();
 //        }
 
         $data = \App\Models\TennisLeague::select('id','lg_id','name_chinese')->get();
@@ -209,10 +209,10 @@ class SportsTennisController extends Controller {
                 return -2;
             }
             $name_chinese = \App\Models\TennisLeague::where('lg_id', $data->lg_id)->first();
-//            $home_team = \App\Models\Team::where('team_name_cn', $data->home_team)->first();
-//            $guest_team = \App\Models\Team::where('team_name_cn', $data->guest_team)->first();
-//            $home_country = \App\Models\Country::where('country_id', $home_team->country_id)->first();
-//            $guest_country = \App\Models\Country::where('country_id', $guest_team->country_id)->first();
+//            $home_team = \App\Model\Team::where('team_name_cn', $data->home_team)->first();
+//            $guest_team = \App\Model\Team::where('team_name_cn', $data->guest_team)->first();
+//            $home_country = \App\Model\Country::where('country_id', $home_team->country_id)->first();
+//            $guest_country = \App\Model\Country::where('country_id', $guest_team->country_id)->first();
             $data->name_chinese = $name_chinese->name_chinese;
 //            $data->home_country_id = $home_country->country_id;
 //            $data->guest_country_id = $guest_country->country_id;
@@ -241,7 +241,7 @@ class SportsTennisController extends Controller {
 //                $model->lg_id = $req->input('parent_id');
 //            }else{
 //                $model->name_chinese = $req->input('parent_id');
-//                $res = \App\Models\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
 //                $model->lg_id = $res->lg_id;
 //            }
             $model->lg_id = $req->input('parent_id');
@@ -311,7 +311,7 @@ class SportsTennisController extends Controller {
             $match_id = $newapp->match_id;
         }
         $request['match_id'] = isset($match_id) ? trim($match_id) : null;
-        //$data = \App\Models\Matchcode::where('p_id','0')->get();
+        //$data = \App\Model\Matchcode::where('p_id','0')->get();
         $data = \App\Models\Matchcode::where('p_id','0')->where('game_code','wq')->get();
         $request['pcode'] = $data;
         $dt = \App\Lib\DataTable\DataTable::init();
@@ -383,7 +383,7 @@ class SportsTennisController extends Controller {
      */
     function addodds(Req $req) {
 
-        //$pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
 
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','wq')->get();
         for($i=0;$i<count($pcodedata);$i++){
@@ -458,7 +458,7 @@ class SportsTennisController extends Controller {
      */
     function oddsedit(Req $req) {
 
-        //$pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
 
         $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','wq')->get();
         for($i=0;$i<count($pcodedata);$i++){
@@ -476,7 +476,7 @@ class SportsTennisController extends Controller {
             }
             $res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
 
-            //$res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->where('game_type','wq')->first();
+            //$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','wq')->first();
             if(!empty($res)){
                 $data->odds_name = $res->odds_name;
             }

+ 80 - 9
app/Http/Controllers/Admin/SportsfootController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
 use App\Http\Controllers\Controller;
 use Illuminate\Http\Request as Req;
 use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
 use App\Models;
 use Request;
 
@@ -37,17 +38,66 @@ class SportsfootController extends Controller {
 		$dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 70));
 		$dt->addColsFields('csnum', array('templet' => '#csnum', 'sort' => false, 'width' => 110));
 		$dt->addColsFields('sxalfcourt', array('templet' => '#sxalfcourt', 'sort' => false, 'width' => 300));
+		$dt->addColsFields('operation', array('templet' => '#status', 'sort' => false, 'width' => 300));
         // $dt->addColsFields('status', array('templet' => '#status', 'sort' => false, 'width' => 150,'align' => 'left'));
         // $arr[] = 'view';
-		if (checkRriv('/admin/sportsfoot/edit')) {
-			$arr[] = 'edit';
-		}
-		$dt->setToolBar($arr, array('width' => 200));
+		// if (checkRriv('/admin/sportsfoot/edit')) {
+		// 	$arr[] = 'edit';
+		// }
+		// $dt->setToolBar($arr, array('width' => 200));
         $dt->enableCheckBox();
 		
 		return view('admin.sportsfoot/outcome', $dt->render($request));
 	}
 
+	//结算
+	function Settlement(Req $req){
+		//查询赛事下所有订单
+		$ssid = $req->match_id;//赛事id
+		$type = $req->type;//是否再结算1,首次结算2,再次结算
+		$newapp = new \App\Models\MoneyBuyMatch();
+		$simplex_ids = array_column($newapp->allsimplexorder($ssid),'order_id');
+		$str_ids = array_column($newapp->allstrorder($ssid),'order_id');
+
+		$SettlementOrder = new SettlementOrder();
+        $SettlementOrder->reSettlement($str_ids, 2,$type,'zq',$ssid);//串式
+        $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,'zq',$ssid);//单式注单
+
+        return responseToJson($data);
+	}
+
+	//作废
+	function revoke(Req $req){
+		$match_id = $req->match_id;//赛事id
+		$model = \App\Models\Stzqresult::where('match_id', $match_id)->first();
+		$model->status = 4;
+		$model->save();
+
+		$smodel = \App\Models\SportsSoccer::where('match_id', $match_id)->first();
+		$smodel->status = 4;
+		$smodel->save();
+
+		$upapp = new \App\Models\SportsNoteList();
+        $data = $upapp->updatesimplex($match_id);//修改单式状态
+
+  //       //单式撤单返现
+        $newapp = new \App\Models\MoneyBuyMatch();
+		$all = $newapp->allsimplexorder($match_id);
+        for ($i=0; $i < count($all); $i++) { 
+	        $appgx = new \App\Lib\Settlement\SettlementOrder();
+	        $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'zq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
+        }
+
+        //串式撤单只改状态
+        $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
+        $csapp = new \App\Models\MoneyBuyStr();
+        $ss = $csapp->updatestatus($str_ids);//var_dump($ss);die;
+        //修改money_buy_match 投注结果result=2为平
+        $newapp->updatast($match_id);
+        
+		return responseToJson(1);
+	}
+
 	//赛事结果修改
 	function edit(Req $req) {
 		$id = $req->id;
@@ -114,7 +164,7 @@ class SportsfootController extends Controller {
         if (!empty($end_time)) {
             $end_time = date('Y-m-d H:i:s', strtotime($end_time));
             $where[] = array('st_zq_result.update_time', '<=', $end_time);
-        }//var_dump($where);die;
+        }//var_dump($where);var_dump($orwhere);die;
         $newapp = new \App\Models\Stzqresult();
         $data = $newapp->resultlist($list, $page, $where, $orwhere);
         
@@ -191,10 +241,11 @@ class SportsfootController extends Controller {
 	}
 
 	//更新赛事比分
-	function updatenum(){
-		$type = $_POST['type'];
-		$id = $_POST['id'];
-		$num = $_POST['num'];
+	function updatenum(Req $req){
+		$type = $req->type;
+		$id = $req->id;
+		$num = $req->num;
+		$match_id = $req->match_id;
 		$newapp = new \App\Models\Stzqresult();
 		if($type==1){
 			$data['u_home_score'] = $num;
@@ -208,9 +259,29 @@ class SportsfootController extends Controller {
 		}else{
 			$data['guest_score'] = $num;
 			$res = $newapp->updateInfo($data,$id);//联赛id
+			$this->addcomendnotice($match_id);
 		}
 		return responseToJson($res);
 	}
+
+	//添加赛事结束纪录
+	function addcomendnotice($id){
+		// $id = '3214775';
+		$data = \App\Models\Comendnotice::where('match_id', $id)->first();
+		if(!$data){
+			$model = new \App\Models\Comendnotice();
+			$model->status = 0;//联赛id
+			$model->game_code = 'zq';
+			$model->match_id = $id;//赛事id
+			$model->ctime = date('Y-m-d H:i:s');
+			$bid = $model->save();
+
+			$newapp = new \App\Lib\Settlement\SettlementWinFail();
+			$newapp->doRun($bid);
+		}
+// return $bid;
+		// return responseToJson(1);
+	}
 	
 	
 	

+ 1 - 1
app/Http/Controllers/Admin/TennisNoteListController.php

@@ -97,7 +97,7 @@ class TennisNoteListController extends Controller
             $odds_only = $data->odds_only;
             $res = DB::table('st_wq_odds_record')->where('odds_only',$odds_only)->first();
             $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
-            //$result = \App\Models\Matchcode::where('odds_code',$res->odds_code)->first();
+            //$result = \App\Model\Matchcode::where('odds_code',$res->odds_code)->first();
             $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
             $data->content = $data->content.$result['odds_name'].  '¥'.$codes[$j]['bet_amount'];
             $data->game = $game->game_name;

+ 9 - 9
app/Http/Controllers/Admin/UserController.php

@@ -312,9 +312,9 @@ class UserController extends Controller
         //     $findId[] = $v['agent_identity'];
         //     $data['data'][$k]['online'] = ($v['statuss'] == 0) ? '离线' : '在线';
         //     if($v['statuss']){
-        //         $linetime = \App\Models\Account_Token::where('effective_time','>=',$letime)->where('account_identity',$v['identity'])->first();
+        //         $linetime = \App\Model\Account_Token::where('effective_time','>=',$letime)->where('account_identity',$v['identity'])->first();
         //         if($linetime){}else{
-        //             \App\Models\Account_detailed::where('account_identity',$v['identity'])->update(['statuss'=>'0']);
+        //             \App\Model\Account_detailed::where('account_identity',$v['identity'])->update(['statuss'=>'0']);
         //             if(!empty($statuss) && $statuss==1){
         //                 unset($data['data'][$k]);
         //                 continue;
@@ -343,7 +343,7 @@ class UserController extends Controller
         // }
 
         // if (!empty($findId)){
-        //     $db = new \App\Models\Agent_detailed;
+        //     $db = new \App\Model\Agent_detailed;
         //     $asd = $db->findId($findId);
 
         //     foreach ($data['data'] as $k => $v) {
@@ -553,12 +553,12 @@ class UserController extends Controller
     /*private function updateAgentParent($data,$agent_id){
         if(empty($agent_id))return -4010010102;
         //验证代理是否存在
-        $check_agent = \App\Models\Agent_detailed::select('agent_identity as identity','agent_user')->where('id',$agent_id)->first();
+        $check_agent = \App\Model\Agent_detailed::select('agent_identity as identity','agent_user')->where('id',$agent_id)->first();
         if(!$check_agent || count($check_agent->toArray())<1 || empty($check_agent->identity))return -4010010202;
         $agent_name = $check_agent->agent_user;
         if($agent_name == $data['account'])return -4010010802;
         //验证相同代理关系是否已存在
-        $check_conhas = \App\Models\AgentChild::select('id')->where('agent_name',$agent_name)->where('account_identity',$data['identity'])->first();
+        $check_conhas = \App\Model\AgentChild::select('id')->where('agent_name',$agent_name)->where('account_identity',$data['identity'])->first();
         if($check_conhas && count($check_conhas->toArray())>0 && !empty($check_conhas->id))return -4010010302;
 
         //关联信息处理
@@ -570,9 +570,9 @@ class UserController extends Controller
         );
 
         //获取用户原父级信息
-        $ypinfo = \App\Models\AgentChild::select('agent_name','agent_identity')->where('account_identity',$data['identity'])->first();
+        $ypinfo = \App\Model\AgentChild::select('agent_name','agent_identity')->where('account_identity',$data['identity'])->first();
         if($ypinfo && count($ypinfo->toArray())>0 && !empty($ypinfo->agent_name)){
-            $res = \App\Models\AgentChild::where('account_identity',$data['identity'])->update($coninfo);
+            $res = \App\Model\AgentChild::where('account_identity',$data['identity'])->update($coninfo);
             if($res<0)return -4010010602;
             $log = array(
                 session('adminInfo.admin_name'),
@@ -584,7 +584,7 @@ class UserController extends Controller
             );
             $res = OperationLog(session('adminInfo.admin_id'), 'update_parentagent', $log);
         }else{
-            $res = \App\Models\AgentChild::where('account_identity',$data['identity'])->insert($coninfo);
+            $res = \App\Model\AgentChild::where('account_identity',$data['identity'])->insert($coninfo);
             if($res<0)return -4010010702;
             $log = array(
                 session('adminInfo.admin_name'),
@@ -1008,7 +1008,7 @@ class UserController extends Controller
    // //  		return view('admin.user/export');
    // //  	}else {
    // //  		$password = $req->password;
-   // //  		$admin_info = \App\Models\System_user::where('id', session('adminInfo.admin_id'))->first();
+   // //  		$admin_info = \App\Model\System_user::where('id', session('adminInfo.admin_id'))->first();
 			// // if (!$admin_info) {
 			// // 	return responseToJson(-7010100202);
 			// // }

+ 555 - 0
app/Http/Controllers/Api/WriteSportsController.php

@@ -0,0 +1,555 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jun.peng
+ * Date: 2019/5/13
+ * Time: 10:19
+ */
+namespace App\Http\Controllers\Api;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Routing\Controller as BaseController;
+use Illuminate\Http\Request as Req;
+use App\Http\Response\Response;
+use App\Lib\Biz\Sport\Common as commonFunction;
+use App\Http\Model\St_area_country as St_area_countryModel;
+
+class WriteSportsController extends BaseController{
+
+    /**
+     * 体育数据入库接口
+     */
+    public function setSports(Req $data){
+
+        try {
+            $obt = $data->data;
+            $getData = $this->getAddData($obt);
+            //开启事务
+            DB::beginTransaction();
+            //当只有一个参数时,则写滚球结果
+            if($data->game_code){
+                //将所有进行中的赛事写入结果
+                $ret = $this->match_result($data->game_code);
+                return Response::success();
+
+            }
+            foreach ($getData as $k=>$v){
+                switch ($v['title']){
+                    case 'area'://地区
+                        throw new \Exception(Response::generate(Response::AUTH_ERROR)) ;
+                        break;
+                    case 'country'://国家
+                        throw new \Exception(Response::generate(Response::AUTH_ERROR));
+                        break;
+                    case 'league'://联赛
+                        $ret = $this->league($v);
+                        break;
+                    case 'competition'://赛事
+                        $ret = $this->competition($v);
+                        break;
+                    case 'odds'://赔率
+                        $ret = $this->odds($v);
+                        break;
+                    case 'league_result'://联赛结果
+    //                return Response::generate(Response::AUTH_ERROR);
+                        $ret = $this->league_result($v);
+                        break;
+                    case 'match_result'://赛事结果
+                        throw new \Exception(Response::generate(Response::AUTH_ERROR));
+                        $ret = $this->match_result($v);
+                        break;
+                    case 'match_result_record'://赛事结果记录
+                        $ret = $this->com_result_record($v);
+                        break;
+                    case 'odds_record'://赔率记录
+                        $ret = $this->odds_record($v);
+                        break;
+                    default:
+                        throw new \Exception(Response::generate(Response::ABNORMAL)) ;
+                }
+
+            }
+            //提交事务
+            DB::commit();
+            return Response::success();
+        } catch (\Exception $e) {
+            //回滚事务
+            DB::rollBack();
+            return $e->getMessage();
+        }
+    }
+
+
+    //计算滚球 赛事进行时间
+    private function secTime($sec=0){
+        $min = floor($sec/60);
+        $res = $min.':'.($sec-$min*60);
+        return $res;
+    }
+
+    //将进行中赛事写入 赛事结果
+    public function match_result($game_code = ''){
+        $model =commonFunction::getModels($game_code,1);
+
+        //获取赛事表所有滚球
+        $matchData = $model['model_match']::select('id','home_team','guest_team','lg_id','status','tag','match_time')
+            ->where(['status'=> 1])
+            ->get()
+            ->toarray();
+
+        //没有滚球数据,无需操作
+        if(empty($matchData)) return Response::success();
+        //获取赛事结果表 所有滚球
+        $matchData_r = $model['model_result']::select('match_id')
+            ->where(['status'=> 1])
+            ->get()
+            ->toarray();
+
+        //没有滚球结果,直接插入结果表
+        if(empty($matchData_r)){
+            foreach ($matchData as $k=>$v){
+                $time = time()-strtotime($v['match_time']);
+                $match_time = $this->secTime($time);
+                $set_match_r[] = [
+                    "match_id"=> $v['id'],
+                    "home_team"=>$v['home_team'],
+                    "guest_team"=>$v['guest_team'],
+                    "lg_id"=>$v['lg_id'],
+                    "status"=>$v['status'],
+                    "tag"=> $v['tag'],
+                    'match_time'=>$match_time,
+                    "update_time"=>date('Y-m-d H:m:i')
+                    ];
+            }
+            $ret = $model['model_result']::insert($set_match_r);
+            if($ret != true) return Response::generate(Response::ADD_MATCH_R_ERROR);
+        }
+
+        //如果结果表有数据,则获取结果表没有的赛事
+        foreach ($matchData as $k=>$v){
+            foreach ($matchData_r as $kk=>$vv){
+                if($v['id'] == $vv['match_id']){
+                    unset($matchData[$k]);
+                }
+            }
+        }
+        //如果还有未写入赛事
+        if(!empty($matchData)){
+            //写入结果表不存在赛事
+            foreach ($matchData as $k=>$v){
+                $time = time()-strtotime($v['match_time']);
+                $match_time = $this->secTime($time);
+                $set_match_r[] = [
+                    "match_id"=> $v['id'],
+                    "home_team"=>$v['home_team'],
+                    "guest_team"=>$v['guest_team'],
+                    "lg_id"=>$v['lg_id'],
+                    "status"=>$v['status'],
+                    "tag"=> $v['tag'],
+                    'match_time'=>$match_time,
+                    "update_time"=>date('Y-m-d H:m:i')
+                ];
+            }
+            $ret = $model['model_result']::insert($set_match_r);
+            if($ret != true) return Response::generate(Response::ADD_MATCH_R_ERROR);//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
+        }
+    }
+    //写入地区数据 弃用
+    public function area($opt = []){
+        $ret = lm('st_area','Sports')->insert($opt);
+        return $ret;
+    }
+
+    //写入国家数据 弃用
+    public function country($opt = []){
+        $ret = lm('st_country','Sports')->insert($opt);
+        return $ret;
+    }
+
+    //写入联赛数据
+    public function league($opt = []){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model =commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+        if(empty($data['belong'])) throw new \Exception(Response::generate(Response::COUNTRY_ERROR)) ;//Render([], '10013', lang('Tips','Sports')->get('country_error'));
+        //获取联赛所属 国家/地区id
+        $belong = St_area_countryModel::getID($data['belong']);
+        $set_lg['area_id'] = $belong['area_id'];
+        $set_lg['country_id'] = $belong['country_id'];
+
+        //查询中间表 是否已记录
+        $lg_id = $model['model_local_league']::select('lg_id')
+            ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->value('lg_id');
+
+        //如果没有记录
+        if(empty($lg_id)){
+            //查询联赛是否已存在
+            $id = $model['model_league']::where('name_chinese','=',$data['name_chinese'])
+                ->value('id');
+            if(empty($id)){
+                $set_lg['name_chinese'] = $data['name_chinese'];
+                $set_lg['kind'] = $data['kind'];
+                $set_lg['match_mode'] = $data['match_mode'];
+                $set_lg['if_stop'] = $data['if_stop'];
+                $set_lg['last_time'] = $data['last_time'];
+                $set_lg['utime'] = date('Y-m-d H:m:i');
+
+                $id = $model['model_league']::insertGetId($set_lg);
+                $m_lg_id = $id;
+                if($m_lg_id < 1) throw new \Exception(Response::generate(Response::INSERT_ERROR));
+            }
+            $set_local = [
+                'lg_id'=>$id,
+                'others_lg_id'=>$data['lg_id'],
+                'source'=>$data['source'],
+            ];
+            $ret = $model['model_local_league']::insertGetId($set_local);
+            if($ret < 1) throw new \Exception(Response::generate(Response::LOCAL_LEAGUE_ERROR)) ;//Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
+        }
+        return Response::success();
+    }
+
+    //写入赛事数据
+    public function competition($opt = []){
+
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+        if(empty($data['lg_id'])) throw new \Exception(Response::generate(Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+
+        //根据源联赛ID 获取本地关联id
+        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->value('lg_id');
+        if(empty($lg_id)) throw new \Exception(Response::generate(Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+        //查询关联记录是否存在
+        $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+            ->value('match_id');
+        if(empty($match_id)){
+            //查询赛事是否存在
+            $id = $model['model_match']::where(['home_team'=>$data['home_team'],'guest_team'=>$data['guest_team'],'match_date'=>$data['match_date'],'match_time'=>$data['match_time']])
+                ->value('id');
+
+            $half_match_id = 0;
+            //如果有上半场赛事id 获取上半场赛事是否存在
+            if(!empty($data['half_match_id'])){
+                $half_match_id = $match_id = $model['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$data['source']])
+                    ->value('match_id');
+                if(empty($half_match_id)) throw new \Exception(Response::generate(Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
+            }
+            //写入赛事
+            if(empty($id)){
+                //如果赛事没有开始日期,则为冠军盘口赛事
+                if(empty($data['match_date'])){
+                    //冠军盘口赛事获取所属联赛结束时间
+                    $last_time = $model['model_league']::where(['id'=>$lg_id])
+                        ->value('last_time');
+
+                    if(empty($last_time)) throw new \Exception(Response::generate(Response::LG_LASTTIME_ERROR)) ;//Render([], '10023', lang('Tips','Sports')->get('lg_lastTime_error'));
+                    //给冠军盘口赛事 赋值时间
+                    $time = strtotime($last_time);
+                    $data['match_date'] = date('Y-m-d',$time);
+                    $data['match_time'] = date('H:m:i',$time);
+                }
+
+                $set_match = [
+                    'ctime'=>date('Y-m-d H:m:i'),
+                    'utime'=>date('Y-m-d H:m:i'),
+                    'expire_time'=>date('Y-m-d H:m:i',time()+60),
+                    'home_team'=>$data['home_team']?:'',
+                    'guest_team'=>$data['guest_team']?:'no_team',
+                    'lg_id'=>$lg_id,
+                    'status'=>$data['status'],
+                    'match_date'=>$data['match_date']?:'',
+                    'match_time'=>$data['match_time']?:'',
+                    'tag'=>$data['tag']?:0,
+                    'is_rollball'=>$data['is_rollball']?:0,
+                    'is_today'=>$data['is_today']?:0,
+                    'is_morningplate'=>$data['is_morningplate']?:0,
+                    'is_stringscene'=>$data['is_stringscene']?:0,
+                    'us_time'=>$data['us_time']?:'',
+                    'half_match_id'=>$half_match_id?:0,
+                ];
+                //写入赛事 返回id
+                $id = $model['model_match']::insertGetId($set_match);
+                if($id < 1) throw new \Exception(Response::generate(Response::INSERT_ERROR)) ;//Render([], '10012', lang('Tips','Sports')->get('insert_error'));
+            }
+            $set_local = [
+                'match_id'=>$id,
+                'others_match_id'=>$data['match_id'],
+                'source'=>$data['source'],
+            ];
+            $ret = $model['model_local_match']::insertGetId($set_local);
+            if($ret < 1) throw new \Exception(Response::generate(Response::LOCAL_MATCH_ERROR)) ;//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
+        }
+        return Response::success();
+    }
+
+    //写入赔率数据
+    public function odds($opt){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+
+        $match = $model['model_local_match']::select('match_id','others_match_id')
+            ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+            ->first();
+        if(count($match) < 1) throw new \Exception(Response::generate(Response::MATCH_ERROR)) ;//Render([], '10016', lang('Tips','Sports')->get('match_error'));
+
+        //获取赛事 本地/源ID
+        $others_match_id = $match->others_match_id;
+        $match_id = $match->match_id;
+
+        $lg = $model['model_local_league']::select('lg_id','others_lg_id')
+            ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->first();
+        if(count($lg) < 1) throw new \Exception(Response::generate(Response::LEAGUE_ERROR));//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+
+        //获取联赛 本地/源ID
+        $others_lg_id = $lg->others_lg_id;
+        $lg_id = $lg->lg_id;
+        //查询 赔率数据是否存在
+        $oddsID = $model['model_odds']::where(['lg_id'=>$lg_id,'others_lg_id'=>$others_lg_id,'match_id'=>$match_id,'others_match_id'=>$others_match_id,'odds_code'=>$data['odds_code'],'sort'=>$data['sort']])
+            ->value('id');
+
+        $set_odds = [
+            'match_id'=> $match_id,
+            'others_match_id'=> $others_match_id,
+            'odds_code'=> $data['odds_code'],
+            'status'=> $data['status'],
+            'sort'=> $data['sort'],
+            'p_code'=> $data['p_code'],
+            'odds'=> $data['odds'],
+            'condition'=> $data['condition'],
+            'odds_only'=> $data['odds_only'],
+            'sole'=> $data['sole'],
+            'source'=> $data['source'],
+            'type'=> $data['type'],
+            'team'=> $data['team'],
+            'lg_id'=> $lg_id,
+            'others_lg_id'=> $others_lg_id,
+            'ctime'=> date('Y-m-d H:m:i'),
+            'utime'=> date('Y-m-d H:m:i'),
+            'expire_time'=>date('Y-m-d H:m:i',time()+60),
+        ];
+        //更新或写入赔率数据
+        if(!empty($oddsID)){
+            $ret = $model['model_odds']::where(['id'=>$oddsID])
+                -> update($set_odds);
+            if($ret < 1) throw new \Exception(Response::generate(Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
+        }else{
+            $ret = $model['model_odds']::insert($set_odds);
+            if($ret != true) throw new \Exception(Response::generate(Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
+        }
+        return Response::success();
+    }
+
+    //写入联赛结果
+    public function league_result($opt){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+
+        //验证结果所属联赛
+        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->value('lg_id');
+        if($lg_id < 1) throw new \Exception(Response::generate(Response::LEAGUE_ERROR));//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+
+        $lg_result_id = $model['model_league_result']::where(['lg_id'=>$lg_id,'game_name'=>$data['game_name']])
+            ->value('id');
+        $set_lg_result = [
+            'lg_id'=>$lg_id,
+            'game_name'=>$data['game_name'],
+            'result'=>json_encode($data['result'],JSON_UNESCAPED_UNICODE),
+            'status'=>$data['status'],
+            'ctime'=> date('Y-m-d H:m:i'),
+            'utime'=> date('Y-m-d H:m:i'),
+        ];
+        //联赛结果数据处理
+        if(!empty($lg_result_id)){
+            $ret = $model['model_league_result']::where(['id'=>$lg_result_id])
+                -> update($set_lg_result);
+            if($ret < 1) throw new \Exception(Response::generate(Response::ADD_LG_R_ERROR)) ;//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
+        }else{
+            $ret = $model['model_league_result']::insert($set_lg_result);
+            if($ret != true) throw new \Exception(Response::generate(Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
+        }
+        return Response::success();
+    }
+
+    //写入赛事结果
+    public function com_result($opt){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+        //验证结果所属联赛
+        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->value('lg_id');
+        if($lg_id < 1) throw new \Exception(Response::generate(Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+        //验证结果所属赛事
+        $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+            ->value('match_id');
+        if($match_id < 1) throw new \Exception(Response::generate(Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
+        //查询结果是否存在
+        $match_r_id = $model['model_result']::where(['match_id'=>$match_id])
+            ->value('id');
+
+        $set_match_r = [
+            "home_team"=>$data['home_team'],
+            "guest_team"=>$data['guest_team'],
+            "lg_id"=>$lg_id,
+            "home_rate"=> $data['home_rate'],
+            "guest_rate"=> $data['guest_rate'],
+            "home_score"=> $data['home_score'],
+            "guest_score"=> $data['guest_score'],
+            "all_goal"=> $data['all_goal'],
+            "status"=>$data['status'],
+            "first_score"=>$data['first_score'],
+            "last_score"=> $data['last_score'],
+            "match_score"=> $data['match_score'],
+            "match_winer"=> $data['match_winer'],
+            "match_time"=> $data['match_time'],
+            "match_process"=> $data['match_process'],
+            "tag"=> $data['tag'],
+            "match_id"=> $match_id,
+            "u_home_score"=> $data['u_home_score'],
+            "u_guest_score"=> $data['u_guest_score'],
+            "p_code"=> $data['p_code'],
+            "update_time"=>date('Y-m-d H:m:i')
+        ];
+        //赛事结果数据处理
+        if(!empty($match_r_id)){
+            $ret = $model['model_result']::where(['id'=>$match_r_id])
+                -> update($set_match_r);
+            if($ret < 1) throw new \Exception(Response::generate(Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
+        }else{
+            $ret = $model['model_result']::insert($set_match_r);
+            if($ret != true) throw new \Exception(Response::generate(Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
+        }
+        return Response::success();
+    }
+
+    //写入赛事结果记录
+    public function com_result_record($opt){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+        //验证结果所属联赛
+        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->value('lg_id');
+        if($lg_id < 1) throw new \Exception(Response::generate(Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+        //验证结果所属赛事
+        $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+            ->value('match_id');
+        if($match_id < 1) throw new \Exception(Response::generate(Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
+
+        $match_r_id = $model['model_result_record']::where(['match_id'=>$match_id,'match_time'=>$data['match_time']])
+            ->value('id');
+        $set_match_r = [
+            "home_team"=>$data['home_team'],
+            "guest_team"=>$data['guest_team'],
+            "lg_id"=>$lg_id,
+            "home_rate"=> $data['home_rate'],
+            "guest_rate"=> $data['guest_rate'],
+            "home_score"=> $data['home_score'],
+            "guest_score"=> $data['guest_score'],
+            "all_goal"=> $data['all_goal'],
+            "status"=>$data['status'],
+            "first_score"=>$data['first_score'],
+            "last_score"=> $data['last_score'],
+            "match_score"=> $data['match_score'],
+            "match_winer"=> $data['match_winer'],
+            "match_time"=> $data['match_time'],
+            "match_process"=> $data['match_process'],
+            "tag"=> $data['tag'],
+            "match_id"=> $match_id,
+            "p_code"=> $data['p_code'],
+            "update_time"=>date('Y-m-d H:m:i')
+        ];
+        //赛事结果记录处理
+        if($match_r_id > 0){
+            $ret = $model['model_result_record']::where(['id'=>$match_r_id])
+                ->update($set_match_r);
+            if($ret < 1) throw new \Exception(Response::generate(Response::ADD_MATCH_R_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
+        }else{
+            $ret = $model['model_result_record']::insert($set_match_r);
+            if($ret != true) throw new \Exception(Response::generate(Response::ADD_MATCH_R_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
+        }
+        return Response::success();
+    }
+
+    //写入赔率记录
+    public function odds_record($opt){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+
+        $match = $model['model_local_match']::select('match_id','others_match_id')
+            ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+            ->first();
+        if(count($match) < 1) throw new \Exception(Response::generate(Response::MATCH_ERROR)) ;//Render([], '10016', lang('Tips','Sports')->get('match_error'));
+
+        //获取赛事 本地/源ID
+        $others_match_id = $match->others_match_id;
+        $match_id = $match->match_id;
+
+        $lg = $model['model_local_league']::select('lg_id','others_lg_id')
+            ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->first();
+        if(count($lg) < 1) throw new \Exception(Response::generate(Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+
+        //获取联赛 本地/源ID
+        $others_lg_id = $lg->others_lg_id;
+        $lg_id = $lg->lg_id;
+        //查询 赔率数据是否存在
+        $oddsID = $model['model_odds_record']::where(['odds_only'=>$data['odds_only']])
+            ->value('id');
+
+        $set_odds = [
+            'match_id'=> $match_id,
+            'others_match_id'=> $others_match_id,
+            'odds_code'=> $data['odds_code'],
+            'status'=> $data['status'],
+            'sort'=> $data['sort'],
+            'p_code'=> $data['p_code'],
+            'odds'=> $data['odds'],
+            'condition'=> $data['condition'],
+            'odds_only'=> $data['odds_only'],
+            'source'=> $data['source'],
+            'type'=> $data['type'],
+            'team'=> $data['team'],
+            'lg_id'=> $lg_id,
+            'others_lg_id'=> $others_lg_id,
+            'ctime'=> date('Y-m-d H:m:i'),
+            'utime'=> date('Y-m-d H:m:i'),
+        ];
+        //更新或写入赔率记录
+        if(!empty($oddsID)){
+            $ret = $model['model_odds_record']::where(['id'=>$oddsID])
+                -> update($set_odds);
+            if($ret < 1) throw new \Exception(Response::generate(Response::ADD_ODDS_R_ERROR)) ;//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }else{
+            $ret = $model['model_odds_record']::insert($set_odds);
+            if($ret != true) throw new \Exception(Response::generate(Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }
+        return Response::success();
+    }
+
+    /**
+     * @param $data
+     * @return mixed
+     * json转数组
+     */
+    public function getAddData($data){
+
+        $data = json_decode($data,true);
+
+        return $data;
+    }
+}

+ 1 - 1
app/Http/Controllers/Controller.php

@@ -41,7 +41,7 @@ class Controller extends BaseController {
 		if (!$model) {
 			return responseToJson(-20006);
 		}
-		$model = resolve('\\App\\Models\\' . $model)->find($id);
+		$model = resolve('\\App\\Model\\' . $model)->find($id);
 		$model->$field = $value;
 		$re = $model->save();
 		return responseToJson(1);

+ 1 - 0
app/Http/Middleware/VerifyCsrfToken.php

@@ -12,6 +12,7 @@ class VerifyCsrfToken extends Middleware
      * @var array
      */
     protected $except = [
+        'setSports',
         //
     ];
 }

+ 19 - 0
app/Http/Model/StBqLeague.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StBqLeague extends Model
+{
+
+    protected $table = 'st_bq_league';
+    public $timestamps = false;
+
+
+}

+ 17 - 0
app/Http/Model/StBqLeagueResult.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StBqLeagueResult extends Model
+{
+
+    protected $table = 'st_bq_league_result';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StBqLocalLeague.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 联赛 关联
+ */
+class StBqLocalLeague extends Model
+{
+
+    protected $table = 'st_bq_local_league';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StBqLocalMatch.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 赛事关联
+ */
+class StBqLocalMatch extends Model
+{
+
+    protected $table = 'st_bq_local_match';
+    public $timestamps = false;
+
+}

+ 19 - 0
app/Http/Model/StBqMatch.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StBqMatch extends Model
+{
+
+    protected $table = 'st_bq_competition';
+    public $timestamps = false;
+
+
+}

+ 17 - 0
app/Http/Model/StBqOdds.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StBqOdds extends Model
+{
+    protected $table = 'st_bq_odds';
+    public $timestamps = false;
+
+
+}

+ 16 - 0
app/Http/Model/StBqOddsRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StBqOddsRecord extends Model
+{
+    protected $table = 'st_bq_odds_record';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StBqResult.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StBqResult extends Model
+{
+    protected $table = 'st_bq_result';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StBqResultRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StBqResultRecord extends Model
+{
+    protected $table = 'st_bq_result_record';
+    public $timestamps = false;
+
+}

+ 19 - 0
app/Http/Model/StLqLeague.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StLqLeague extends Model
+{
+
+    protected $table = 'st_lq_league';
+    public $timestamps = false;
+
+
+}

+ 17 - 0
app/Http/Model/StLqLeagueResult.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StLqLeagueResult extends Model
+{
+
+    protected $table = 'st_lq_league_result';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StLqLocalLeague.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 联赛 关联
+ */
+class StLqLocalLeague extends Model
+{
+
+    protected $table = 'st_lq_local_league';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StLqLocalMatch.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 赛事关联
+ */
+class StLqLocalMatch extends Model
+{
+
+    protected $table = 'st_lq_local_match';
+    public $timestamps = false;
+
+}

+ 19 - 0
app/Http/Model/StLqMatch.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StLqMatch extends Model
+{
+
+    protected $table = 'st_lq_competition';
+    public $timestamps = false;
+
+
+}

+ 17 - 0
app/Http/Model/StLqOdds.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StLqOdds extends Model
+{
+    protected $table = 'st_lq_odds';
+    public $timestamps = false;
+
+
+}

+ 16 - 0
app/Http/Model/StLqOddsRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StLqOddsRecord extends Model
+{
+    protected $table = 'st_lq_odds_record';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StLqResult.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StLqResult extends Model
+{
+    protected $table = 'st_lq_result';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StLqResultRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StLqResultRecord extends Model
+{
+    protected $table = 'st_lq_result_record';
+    public $timestamps = false;
+
+}

+ 19 - 0
app/Http/Model/StWqLeague.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StWqLeague extends Model
+{
+
+    protected $table = 'st_Wq_league';
+    public $timestamps = false;
+
+
+}

+ 17 - 0
app/Http/Model/StWqLeagueResult.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StWqLeagueResult extends Model
+{
+
+    protected $table = 'st_wq_league_result';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StWqLocalLeague.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 联赛 关联
+ */
+class StWqLocalLeague extends Model
+{
+
+    protected $table = 'st_wq_local_league';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StWqLocalMatch.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 赛事关联
+ */
+class StWqLocalMatch extends Model
+{
+
+    protected $table = 'st_wq_local_match';
+    public $timestamps = false;
+
+}

+ 19 - 0
app/Http/Model/StWqMatch.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StWqMatch extends Model
+{
+
+    protected $table = 'st_wq_competition';
+    public $timestamps = false;
+
+
+}

+ 17 - 0
app/Http/Model/StWqOdds.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StWqOdds extends Model
+{
+    protected $table = 'st_wq_odds';
+    public $timestamps = false;
+
+
+}

+ 16 - 0
app/Http/Model/StWqOddsRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StWqOddsRecord extends Model
+{
+    protected $table = 'st_wq_odds_record';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StWqResult.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StWqResult extends Model
+{
+    protected $table = 'st_wq_result';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StWqResultRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StWqResultRecord extends Model
+{
+    protected $table = 'st_wq_result_record';
+    public $timestamps = false;
+
+}

+ 19 - 0
app/Http/Model/StZqLeague.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StZqLeague extends Model
+{
+
+    protected $table = 'st_zq_league';
+    public $timestamps = false;
+
+
+}

+ 17 - 0
app/Http/Model/StZqLeagueResult.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StZqLeagueResult extends Model
+{
+
+    protected $table = 'st_zq_league_result';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StZqLocalLeague.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 联赛 关联
+ */
+class StZqLocalLeague extends Model
+{
+
+    protected $table = 'st_zq_local_league';
+    public $timestamps = false;
+
+}

+ 17 - 0
app/Http/Model/StZqLocalMatch.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 足球 赛事关联
+ */
+class StZqLocalMatch extends Model
+{
+
+    protected $table = 'st_zq_local_match';
+    public $timestamps = false;
+
+}

+ 19 - 0
app/Http/Model/StZqMatch.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StZqMatch extends Model
+{
+
+    protected $table = 'st_zq_competition';
+    public $timestamps = false;
+
+
+}

+ 16 - 0
app/Http/Model/StZqOdds.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StZqOdds extends Model
+{
+    protected $table = 'st_zq_odds';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StZqOddsRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StZqOddsRecord extends Model
+{
+    protected $table = 'st_zq_odds_record';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StZqResult.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StZqResult extends Model
+{
+    protected $table = 'st_zq_result';
+    public $timestamps = false;
+
+}

+ 16 - 0
app/Http/Model/StZqResultRecord.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class StZqResultRecord extends Model
+{
+    protected $table = 'st_zq_result_record';
+    public $timestamps = false;
+
+}

+ 35 - 0
app/Http/Model/St_area_country.php

@@ -0,0 +1,35 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class St_country
+ * @package App\Sports\Model
+ * 国家 地区 关系
+ */
+class St_area_country extends Model
+{
+
+    protected $table = 'st_area_country';
+    public $timestamps = false;
+
+
+    //获取国家或地区 id
+    public static function getID($opt = ''){
+        $name = $opt;//国家或地区名称
+        $ret = self::select('id','pid')
+            ->where(['name'=>$name])
+            ->first();
+
+        if($ret->pid > 0){
+            $data['area_id'] = $ret->pid;
+            $data['country_id'] = $ret->id;
+        }else{
+            $data['area_id'] = $ret->id;
+            $data['country_id'] = 0;
+        }
+
+        return $data;
+    }
+}

+ 80 - 0
app/Http/Response/Response.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace App\Http\Response;
+
+class Response
+{
+
+    const SUCCESS = 1;
+    //体育数据入库操作
+    const HANDLE_ERRORS = 10010;
+    const ABNORMAL = 10011;
+    const UPDATE_ERROR = 10012;
+    const INSERT_ERROR = 10013;
+    const COUNTRY_ERROR = 10014;
+    const AREA_ERROR = 10015;
+    const LEAGUE_ERROR = 10016;
+    const MATCH_ERROR = 10017;
+    const LOCAL_LEAGUE_ERROR = 10018;
+    const ADD_ODDS_ERROR = 10019;
+    const ADD_ODDS_R_ERROR = 10020;
+    const ADD_LG_R_ERROR = 10021;
+    const ADD_MATCH_R_ERROR = 10022;
+    const ADD_MATCH_R_R_ERROR = 10023;
+    const LG_LASTTIME_ERROR = 10024;
+    const HALF_MATCH_ERROR = 10025;
+    const AUTH_ERROR = 10026;
+    const LOCAL_MATCH_ERROR = 10027;
+
+    private static $errorMsgs = [
+        self::SUCCESS           => '成功',
+        //===体育数据写入===
+        self::HANDLE_ERRORS =>'数据处理失败',
+        self::ABNORMAL =>'提交数据异常',
+        self::UPDATE_ERROR =>'有数据更新失败',
+        self::INSERT_ERROR =>'有数据插入失败',
+        self::COUNTRY_ERROR =>'国家不存在',
+        self::AREA_ERROR =>'地区不存在',
+        self::LEAGUE_ERROR =>'联赛不存在',
+        self::MATCH_ERROR =>'赛事不存在',
+        self::LOCAL_LEAGUE_ERROR =>'写入联赛关联记录失败',
+        self::ADD_ODDS_ERROR =>'赛事赔率写入失败',
+        self::ADD_ODDS_R_ERROR =>'赛事赔率记录写入失败',
+        self::ADD_LG_R_ERROR =>'联赛结果写入失败',
+        self::ADD_MATCH_R_ERROR =>'赛事结果写入失败',
+        self::ADD_MATCH_R_R_ERROR =>'赛事结果记录写入失败',
+        self::LG_LASTTIME_ERROR =>'联赛赛季结束时间不存在',
+        self::HALF_MATCH_ERROR =>'所属上半场赛事不存在',
+        self::AUTH_ERROR => '无权操作',
+        self::LOCAL_MATCH_ERROR =>'写入赛事关联记录失败',
+    ];
+
+    public static function getMsg($code)
+    {
+        return isset(static::$errorMsgs[$code]) ? static::$errorMsgs[$code] : '';
+    }
+
+    public static function generate($errCode, $data = [], $errMsg = '')
+    {
+        $rs['status'] = $errCode;
+        $rs['msg'] = $errMsg;
+        $rs['msg'] OR $rs['msg'] = static::getMsg($errCode) ?: static::$errorMsgs[static::FAILED];
+        $rs['data'] = $data;
+//        return response()->json($rs, 200, ['Content-Type' => 'application/json; charset=UTF-8'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
+        return json_encode($rs,JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+    public static function success($data = [])
+    {
+        return static::generate(Response::SUCCESS, $data);
+        exit();
+    }
+
+    public static function throwError($errCode, $errMsg = '',$data = [])
+    {
+        $errMsg OR $errMsg = static::getMsg($errCode);
+        throw new BusinessException($errMsg, $errCode,$data);
+    }
+
+}

+ 1021 - 0
app/Lib/Biz/Sport/Common.php

@@ -0,0 +1,1021 @@
+<?php
+namespace App\Lib\Biz\Sport;
+use App\Http\Response\Response;
+
+use App\Http\Model\StZqMatch;
+use App\Http\Model\StZqLeague;
+use App\Http\Model\StZqLeagueResult;
+use App\Http\Model\StZqLocalLeague;
+use App\Http\Model\StZqLocalMatch;
+use App\Http\Model\StZqOdds;
+use App\Http\Model\StZqOddsRecord;
+use App\Http\Model\StZqResult;
+use App\Http\Model\StZqResultRecord;
+
+use App\Http\Model\StLqMatch;
+use App\Http\Model\StLqLeague;
+use App\Http\Model\StLqLeagueResult;
+use App\Http\Model\StLqLocalLeague;
+use App\Http\Model\StLqLocalMatch;
+use App\Http\Model\StLqOdds;
+use App\Http\Model\StLqOddsRecord;
+use App\Http\Model\StLqResult;
+use App\Http\Model\StLqResultRecord;
+
+use App\Http\Model\StWqResultRecord;
+use App\Http\Model\StWqMatch;
+use App\Http\Model\StWqLeague;
+use App\Http\Model\StWqLeagueResult;
+use App\Http\Model\StWqLocalLeague;
+use App\Http\Model\StWqLocalMatch;
+use App\Http\Model\StWqOdds;
+use App\Http\Model\StWqOddsRecord;
+use App\Http\Model\StWqResult;
+
+use App\Http\Model\StBqResultRecord;
+use App\Http\Model\StBqMatch;
+use App\Http\Model\StBqLeague;
+use App\Http\Model\StBqLeagueResult;
+use App\Http\Model\StBqLocalLeague;
+use App\Http\Model\StBqLocalMatch;
+use App\Http\Model\StBqOdds;
+use App\Http\Model\StBqOddsRecord;
+use App\Http\Model\StBqResult;
+
+
+class Common {
+    function checkDebug()
+    {
+        return (isset($_GET['debug']) && intval($_GET['debug'])==-99999) || APP_DEBUG==1?1:0;
+    }
+    function View($Path = "") {
+        if (!$Path) {
+            global $ViewPath;
+            $ViewPath = explode("\\", $ViewPath);
+            $ViewPath[3] = explode("Controller", $ViewPath[3]);
+            $ViewPath[3] = $ViewPath[3][0];
+            return APP_PATH . "/" . $ViewPath[1] . "/View/" . $ViewPath[3] . "/" . $ViewPath[4] . ".blade.php";
+        } else {
+            return APP_PATH . "/" . $Path . ".blade.php";
+        }
+    }
+
+    function arrayToOptions($data, $key, $val)
+    {
+        $options = array();
+        if (is_array($data) && count($data)) {
+            foreach ($data as $k => $value) {
+                $options[$value[$key]] = $value[$val];
+            }
+        }
+        return $options;
+    }
+
+
+
+    function M($TABLE_NAME = "") {
+        return new DB($TABLE_NAME);
+    }
+
+    function checkClose() {
+        if (file_exists(ROOT_PATH . '/Cache/system.lock')) {
+            if (is_mobile()) {
+                return appExec("Mobile", "Weihu", "index");
+            } else {
+                return appExec("home", "weihu", "index");
+            }
+        }
+    }
+    /**
+     * 发布消息
+     *
+     * @param integer $status
+     * @param string $msg
+     * @param string $data
+     * @return void
+     */
+    function publishNotify($channel, $status = 1, $data = '') {
+        // toLog('publishNotify-'.$channel.'+++'.$data);
+        C()->get('msg')->publish($channel, $data);
+    }
+    /**
+     * 数组分类排序
+     * @param [array] $columnsArr [需要进行排序的数组]
+     * @param [int] $plmid [所属分类ID]
+     */
+    function getColumns($columnsArr, $plmid) {
+        $menu = array();
+
+        foreach ($columnsArr as $v) {
+            if ($v['plmid'] == $plmid) {
+                $menu[] = $v;
+
+                $a = getColumns($columnsArr, $v['lmid']);
+                foreach ($a as $vv) {
+                    $menu[] = $vv;
+                }
+            }
+        }
+        return $menu;
+    }
+
+    /**
+     * 获取客户端真实IP
+     */
+    function GETIP() {
+        global $ip;
+
+        if (getenv("HTTP_CLIENT_IP")) {
+            $ip = getenv("HTTP_CLIENT_IP");
+        } else if (getenv("HTTP_X_FORWARDED_FOR")) {
+            $ip = getenv("HTTP_X_FORWARDED_FOR");
+        } else if (getenv("REMOTE_ADDR")) {
+            $ip = getenv("REMOTE_ADDR");
+        } else {
+            $ip = "Unknow";
+        }
+
+        return $ip;
+
+    }
+
+    function dump($data, $exit = 1) {
+        echo "<pre>";
+        print_r($data);
+        echo "</pre>";
+        if ($exit) {
+            exit;
+        }
+
+    }
+
+    function OrderID($prefix = '') {
+        $num = mt_rand(100, 999);
+        list($s, $m) = explode(' ', microtime());
+        $order = date("YmdHis") . ($s * 1000000) . $num;
+        return $prefix . $order;
+    }
+    /**
+     * 容器
+     */
+    function C() {
+        static $c = array();
+        if (!isset($c['container'])) {
+            $c['container'] = new \System\Di();
+        }
+        return $c['container'];
+    }
+
+    /**
+     * 全局变量快捷操作
+     * @param [type] $key   [description]
+     * @param [type] $value [description]
+     */
+    function S($key, $value = null) {
+        if ($value != null) {
+            $GLOBALS[$key] = $value;
+        }
+        if (isset($GLOBALS[$key])) {
+            return $GLOBALS[$key];
+        }
+    }
+    /**
+     * 载入模型
+     * @param  [type] $name [description]
+     * @param  string $proj [description]
+     * @return [type]       [description]
+     */
+    function lm($name, $proj = '') {
+        $proj = empty($proj) ? S('CUR_PROJECT') : $proj;
+        if (empty($proj)) {
+            throw new \Exception("项目{$proj}不存在", 1);
+        }
+        $cls = "\\App\\" . ucfirst($proj) . "\\Model\\" . ucfirst($name);
+        if(!class_exists($cls)){
+            return;
+        }
+        $key = 'model_' . $name . $proj;
+        C()->shared($key, $cls);
+        return C()->get($key);
+    }
+    /**
+     * 载入语言包
+     * @param  string $key  语言项
+     * @param  string $file 语言文件名
+     * @param  string $proj 项目名称
+     * @return [type]       [description]
+     */
+    function lang($file = '', $proj = '') {
+        $proj = empty($proj) ? S('CUR_PROJECT') : $proj;
+        $file = empty($file) ? S('CUR_CONTROLLER') : $file;
+        $ckey = "Lang_{$proj}_{$file}";
+        if (C()->has($ckey)) {
+            return C()->get($ckey);
+        } else {
+            C()->shared($ckey, function () use ($proj, $file) {
+                $file = ucfirst($file);
+                $proj = ucfirst($proj);
+                $lang = new \System\Lang();
+                $lang_files = array();
+                if (S('CUR_PROJECT') == $proj && S('CUR_CONTROLLER') == $file) {
+                    $lang_files[] = ROOT_PATH . "/Application/Commons/Lang/Common.php";
+                    $lang_files[] = ROOT_PATH . "/Application/{$proj}/Lang/Common.php";
+                }
+                $lang_files[] = ROOT_PATH . "/Application/{$proj}/Lang/{$file}.php";
+                $data = array();
+                foreach ($lang_files as $v) {
+                    if (file_exists($v)) {
+                        $data2 = include $v;
+                        if (is_array($data2)) {
+                            $data = array_merge($data, $data2);
+                        }
+                    }
+                }
+                $lang->load($data);
+                return $lang;
+            });
+            return C()->get($ckey);
+        }
+    }
+
+    /**
+     * 标签替换
+     *
+     * @param [type] $message
+     * @param array $data
+     * @param string $tag
+     * @return void
+     */
+    function parseTag($message,$data=array(),$tag='#'){
+        if(is_array($data) && count($data)>0){
+            foreach ($data as $k => $v) {
+                $message = str_replace($tag . $k . $tag, $v, $message);
+            }
+        }
+
+        return $message;
+    }
+
+    function appExec($proj, $ctrl, $method, $exec = 0) {
+        $proj = ucfirst($proj);
+        $ctrl = ucfirst($ctrl);
+        $method = ucfirst($method);
+        S('CUR_PROJECT', $proj);
+        S('CUR_CONTROLLER', $ctrl);
+        S('CUR_METHOD', $method);
+        checkPlatform();
+        toDomain();
+        //设置REMOTE_KEY
+        lm('setinfo','commons')->setKey();
+
+        $cls = "\\App\\{$proj}\\Controller\\{$ctrl}";
+        C()->set($ctrl, $cls);
+        $cls = C()->get($ctrl);
+        if (!$cls) {
+            exit("404 NOT FOUND");
+        }
+        if ($exec) {
+            $result = $cls->$method();
+            if (!empty($result)) {
+                Render($result);
+            }
+        }
+        if (method_exists($cls, $method)) {
+            $result = $cls->$method();
+            if (!empty($result)) {
+                Render($result);
+            }
+        } else {
+            exit("404 METHOD NOT FOUND");
+        }
+
+    }
+
+    /**
+     * UUID 生成
+     */
+    function UUID() {
+        $prefix = '';
+        $uuid = '';
+        $str = md5(uniqid(mt_rand(), true));
+        $uuid = substr($str, 0, 8) . '-';
+        $uuid .= substr($str, 8, 4) . '-';
+        $uuid .= substr($str, 12, 4) . '-';
+        $uuid .= substr($str, 16, 4) . '-';
+        $uuid .= substr($str, 20, 12);
+        return $prefix . $uuid;
+    }
+
+    /**
+     *密码加密码
+     */
+    function GenEncryption() {
+        srand((double) microtime() * 1000000); //create a random number feed.
+        $ychar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
+        $list = explode(",", $ychar);
+        $authnum = "";
+        for ($i = 0; $i < 6; $i++) {
+            $randnum = rand(0, 61); // 10+26;
+            $authnum .= $list[$randnum];
+        }
+        return $authnum;
+    }
+
+//密码加密
+    function GenPassword($password) {
+        $Enc = GenEncryption();
+        $Pwd = md5(md5($Enc . $password));
+        return array("encryption" => $Enc, "password" => $Pwd);
+
+    }
+
+//密码验证
+    function VerPassword($identity, $password) {
+        $account = M("account_password")->where("account_identity = '$identity' and", "status = ", '1')->select("encryption,account_password")->find();
+        $VerPwd = md5(md5($account["encryption"] . $password));
+        if ($VerPwd == $account["account_password"]) {
+            unset($account);
+            unset($VerPwd);
+            return true;
+        } else {
+            unset($account);
+            unset($VerPwd);
+            return false;
+        }
+
+    }
+    /**
+     * Json return
+     * @param string $data   [description]
+     * @param string $status [description]
+     * @param string $msg    [description]
+     * @param string $method [description]
+     */
+    function JsonReturn($data = "", $status = "200", $msg = "", $method = "") {
+        // header("Content-type:application/json;charset:utf-8");
+        // header('content-type:text/html; charset=utf-8');
+        if(isset($_REQUEST['crossdomain']) && !empty($_REQUEST['crossdomain'])){
+            header("Access-Control-Allow-Origin:{$_REQUEST['crossdomain']}");
+        }else{
+            header("Access-Control-Allow-Origin:*");
+        }
+        header('Access-Control-Allow-Methods:POST,GET,PUT,DELETE,OPTIONS');
+        header('Access-Control-Allow-Credentials:true');
+        $retdata=array("status" => $status, "msg" => $msg, "data" =>$data);
+
+        $devicetype=isset($_REQUEST['devicetype'])?trim($_REQUEST['devicetype']):'';
+        if(!empty($devicetype) && in_array($devicetype,array('ios','android'))){
+            $path=S('CUR_PROJECT').'/'.S('CUR_CONTROLLER').'/'.	S('CUR_METHOD');
+            $retdata=C()->get($devicetype."Result")->update($path,$retdata);
+        }
+
+        if ($method == '') {
+            //dump($devicetype);
+            echo (json_encode($retdata,JSON_UNESCAPED_UNICODE));
+        } else {
+            echo ($method . "(" . json_encode($retdata,JSON_UNESCAPED_UNICODE) . ")");
+        }
+    }
+    function XmlReturn($data = "", $status = 200, $msg = '') {
+        // header("Content-type:text/xml;charset:utf-8");
+        $xml = '<?xml version="1.0" encoding="utf-8"?>';
+        $xml .= "<root>";
+        $xml .= '<status>' . $status . '</status>';
+        $xml .= '<msg>' . $msg . '</msg>';
+        $xml .= "<rows>";
+        $xml .= toXml($data);
+        $xml .= "</rows>";
+        $xml .= "</root>";
+        echo($xml);
+    }
+    function toXml($data) {
+        // print_r($data);
+        $xml = '';
+        if (is_array($data) && count($data) > 0) {
+            foreach ($data as $k => $v) {
+                $key = $k;
+                if (is_numeric($k)) {
+                    $key = 'data';
+                }
+                if (is_array($v)) {
+                    $xml .= "<{$key}>" . toXml($v) . "</{$key}>";
+                    continue;
+                }
+                if (is_string($v)) {
+                    $xml .= "<{$key}>{$v}</{$key}>";
+                }
+            }
+        }
+        return $xml;
+    }
+
+    function WriteLog($Log) {
+        $logger = new Logger('LOGGS');
+        $logURI = "Cache/log/" . date("Y-m-d-H-i") . ".log";
+        $logger->pushHandler(new StreamHandler($logURI, Logger::DEBUG));
+        $logger->pushHandler(new FirePHPHandler());
+        $logger->addInfo(var_export($Log,1));
+
+    }
+    /**
+     * 计算当前用时
+     *
+     * @param string $runName
+     * @param integer $return
+     * @return void
+     */
+    function computeTime($runName='',$return=0,$start=1){
+        $curTime= get_millisecond();
+        $numTime=$curTime-(intval($GLOBALS['startTime'])*1000);
+        if($return){
+            return array('curTime'=>$curTime,'numTime'=>$numTime,'runName'=>$runName);
+        }else{
+            echo "<pre>执行{$runName} 功能,当前时间为:{$curTime},累积用时: {$numTime}</pre>";
+            return;
+        }
+
+    }
+
+    function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        $msec = round($usec * 1000);
+        return $sec . $msec;
+
+    }
+
+    function toLog($text, $rewrite = 0) {
+        $data = "=============" . date("Y-m-d H:i", time()) . "==========================================" . chr(13);
+        $data .= var_export($text, 1) . chr(13);
+        $data .= "======================================================================================" . chr(13);
+        $data = iconv('utf-8', 'gb2312', $data);
+        if ($rewrite) {
+            file_put_contents(ROOT_PATH . '/logs.txt', $data);
+        } else {
+            file_put_contents(ROOT_PATH . '/logs.txt', $data, FILE_APPEND);
+        }
+    }
+
+    /**
+     * 发送数据到前台,根据请求的数据格式返回相应的数据
+     * @param [type] $data   [description]
+     * @param string $status [description]
+     * @param string $msg    [description]
+     */
+    function Render($data, $status = "1", $msg = "", $method = '') {
+        $format = S('CUR_RETURN_FORMAT');
+        $msg = empty($msg) ? lang('errors', 'api')->get('error' . $status) : $msg;
+
+        if (empty($format) || $format == 'json') {
+            JsonReturn($data, $status, $msg);
+        }
+        if ($format == 'xml') {
+            XmlReturn($data, $status, $msg);
+        }
+        exit;
+    }
+
+
+
+    function _beginTransaction() {
+        S('DB')->beginTransaction();
+    }
+    function _rollBack() {
+        S('DB')->rollBack();
+    }
+    function _commit() {
+        S('DB')->commit();
+    }
+    /**
+     * 服务
+     *
+     * @param string 服务名称
+     * @param array $params
+     * @return void
+     */
+    function SRV($name, $params = array()) {
+        return C()->get($name)->update($params);
+    }
+    /**
+     * 是否验证token过期
+     *
+     * @return bool
+     */
+    function isCheckToken() {
+        $result = true;
+        $allowMethod = include ROOT_PATH . "/Config/AllowMethod.php";
+        $key = S('CUR_PROJECT') . '/' . S('CUR_CONTROLLER') . '/' . S('CUR_METHOD');
+        if ($allowMethod[$key] == 1) {
+            $result = false;
+        }
+        return $result;
+    }
+    function checkPlatform(){
+
+        if(isset($_GET['platform'])){
+            $_SESSION['platform']=$_GET['platform']=='wap'?1:0;
+        }
+        if(isset($_GET['clearPlatform']) && intval($_GET['clearPlatform'])==1){
+            $_SESSION['platform']=null;
+        }
+
+    }
+    function is_mobile() {
+        if(isset($_SESSION['platform']) && $mobile=intval($_SESSION['platform'])>0 ){
+            return $mobile==1?true:false;
+        }
+        $user_agent = $_SERVER['HTTP_USER_AGENT'];
+        $mobile_agents = Array("240x320", "acer", "acoon", "acs-", "abacho", "ahong", "airness", "alcatel", "amoi", "android", "anywhereyougo.com", "applewebkit/525", "applewebkit/532", "asus", "audio", "au-mic", "avantogo", "becker", "benq", "bilbo", "bird", "blackberry", "blazer", "bleu", "cdm-", "compal", "coolpad", "danger", "dbtel", "dopod", "elaine", "eric", "etouch", "fly ", "fly_", "fly-", "go.web", "goodaccess", "gradiente", "grundig", "haier", "hedy", "hitachi", "htc", "huawei", "hutchison", "inno", "ipad", "ipaq", "ipod", "jbrowser", "kddi", "kgt", "kwc", "lenovo", "lg ", "lg2", "lg3", "lg4", "lg5", "lg7", "lg8", "lg9", "lg-", "lge-", "lge9", "longcos", "maemo", "mercator", "meridian", "micromax", "midp", "mini", "mitsu", "mmm", "mmp", "mobi", "mot-", "moto", "nec-", "netfront", "newgen", "nexian", "nf-browser", "nintendo", "nitro", "nokia", "nook", "novarra", "obigo", "palm", "panasonic", "pantech", "philips", "phone", "pg-", "playstation", "pocket", "pt-", "qc-", "qtek", "rover", "sagem", "sama", "samu", "sanyo", "samsung", "sch-", "scooter", "sec-", "sendo", "sgh-", "sharp", "siemens", "sie-", "softbank", "sony", "spice", "sprint", "spv", "symbian", "tablet", "talkabout", "tcl-", "teleca", "telit", "tianyu", "tim-", "toshiba", "tsm", "up.browser", "utec", "utstar", "verykool", "virgin", "vk-", "voda", "voxtel", "vx", "wap", "wellco", "wig browser", "wii", "windows ce", "wireless", "xda", "xde", "zte");
+        $is_mobile = false;
+        foreach ($mobile_agents as $device) {
+            if (stristr($user_agent, $device)) {
+                $is_mobile = true;
+                break;
+            }
+        }
+        return $is_mobile;
+    }
+
+    function toDomain() {
+
+        $domain = $_SERVER['HTTP_HOST'];
+        $config = include ROOT_PATH . '/Config/Domain.php';
+        $is_mobile = is_mobile();
+        $curDomain = $old_domain = $domain;
+        if (is_array($config) && count($config) > 0) {
+            $domains = array();
+            $domains[] = $domain;
+            if ($is_mobile) {
+                $domains[] = str_replace('www.', 'm.', $domain);
+                $domains[] = 'm.' . $domain;
+            } else {
+                $domains[] = str_replace('m.', '', $domain);
+                $domains[] = str_replace('m.', 'www.', $domain);
+            }
+            foreach ($domains as $key => $value) {
+                if (isset($config[$value])) {
+                    $v = $config[$value];
+                    if ($v == 'pay') {
+                        return;
+                    }
+                    if ($is_mobile) {
+                        if ($v == 'pc') {
+                            continue;
+                        }
+                    } else {
+                        if ($v != 'pc') {
+                            continue;
+                        }
+                    }
+
+                    $curDomain = $value;
+                    // $_SESSION['domain']=$value;
+                }
+            }
+        }
+        // echo $curDomain;
+        if ($is_mobile) {
+            if (S('CUR_PROJECT') == 'Home') {
+                header("Location:http://" . $curDomain . "/m");
+                //header("Location:http://" . $curDomain . "/mobile-index/index");
+            }
+        } else {
+            if (S('CUR_PROJECT') == 'Mobile') {
+                header("Location:http://" . $curDomain . "/home-index/index");
+            }
+        }
+        /**
+         * 数据签名认证
+         * @param  array  $data 被认证的数据
+         * @return string       签名
+         */
+        function data_auth_sign($data) {
+            //数据类型检测
+            if (!is_array($data)) {
+                $data = (array) $data;
+            }
+            ksort($data); //排序
+            $code = http_build_query($data); //url编码并生成query字符串
+            $sign = sha1($code); //生成签名
+            return $sign;
+        }
+        /*
+         * 判断用户是否登录
+         * */
+        function isLogin($str = '',$type='agent') {
+            $session = $_SESSION[$type.'Info'];
+            if(empty($session)){
+                return null;
+            }
+            if($type=='agent'){
+                if($str=='name'){
+                    return $session['agent_user'];
+                }
+                if($str=='uid'){
+                    return $session['user_identity'];
+                }
+            }
+        }
+    }
+
+    function jump($url){
+        header('Location:'.$url);
+    }
+
+//手机中间星号
+    function phoneHide($phone)
+    {
+        if (!empty($phone)) {
+            $phone = substr_replace($phone, '****', 3, 4);
+        }
+        return $phone;
+    }
+
+    /**
+     * @param $game_code 球类代码
+     * @param int $isJoin 是否用于join
+     * @return array
+     * @throws Exception
+     * 根据球类代码 定义相关model
+     */
+    static function getModels($game_code,$isJoin=1){
+//        $game_type = lm('GameType', 'Sports')->where('game_code',$game_code)->select('game_code')->first();
+        // 获取不同球类model
+        if($isJoin == 1){
+            switch ($game_code){
+                case 'zq':
+                    $model_league = new StZqLeague;
+                    $model_match = new StZqMatch;
+                    $model_odds = new StZqOdds;
+                    $model_odds_record = new StZqOddsRecord;
+                    $model_result = new StZqResult;
+                    $model_result_record = new StZqResultRecord;
+                    $model_league_result = new StZqLeagueResult;
+                    $model_local_league = new StZqLocalLeague;
+                    $model_local_match = new StZqLocalMatch;
+                    break;
+                case 'lq':
+                    $model_league = new StLqLeague;
+                    $model_match = new StLqMatch;
+                    $model_odds = new StLqOdds;
+                    $model_odds_record = new StLqOddsRecord;
+                    $model_result = new StLqResult;
+                    $model_result_record = new StLqResultRecord;
+                    $model_league_result = new StLqLeagueResult;
+                    $model_local_league = new StLqLocalLeague;
+                    $model_local_match = new StLqLocalMatch;
+                    break;
+                case 'wq':
+                    $model_league = new StWqLeague;
+                    $model_match = new StWqMatch;
+                    $model_odds = new StWqOdds;
+                    $model_odds_record = new StWqOddsRecord;
+                    $model_result = new StWqResult;
+                    $model_result_record = new StWqResultRecord;
+                    $model_league_result = new StWqLeagueResult;
+                    $model_local_league = new StWqLocalLeague;
+                    $model_local_match = new StWqLocalMatch;
+                    break;
+                case 'bq':
+                    $model_league = new StBqLeague;
+                    $model_match = new StBqMatch;
+                    $model_odds = new StBqOdds;
+                    $model_odds_record = new StBqOddsRecord;
+                    $model_result = new StBqResult;
+                    $model_result_record = new StBqResultRecord;
+                    $model_league_result = new StBqLeagueResult;
+                    $model_local_league = new StBqLocalLeague;
+                    $model_local_match = new StBqLocalMatch;
+                    break;
+                default:
+                    throw new \Exception(Response::generate(Response::ABNORMAL));
+            }
+        }
+        $data = [
+            'model_league'=>$model_league,//联赛
+            'model_match'=>$model_match,//赛事
+            'model_odds'=>$model_odds,//赔率
+            'model_result' =>$model_result,//赛事结果
+            'model_odds_record' => $model_odds_record,//赔率记录
+            'model_result_record' =>$model_result_record,//赛事结果记录
+            'model_league_result'=>$model_league_result,//联赛结果
+            'model_local_league'=>$model_local_league,//本地关联联赛
+            'model_local_match'=>$model_local_match,//本地关联赛事
+        ];
+        return $data;
+    }
+
+    /**
+     * @param $type_code
+     * @return array
+     * @throws \Exception
+     * 获取不同状态下的 查询条件
+     */
+    function getState($type_code,$model_match = ''){
+        if($model_match == ''){
+            switch ($type_code){
+                case 'StRollBall'://滚球 正在进行
+                    $where = [
+                        ['status','=','1'],
+                    ];
+                    break;
+                case 'StSoon'://即将 今日两小时内开始
+                    $where = [
+                        ['status','=','0'],
+                        ['match_date','=',date("Y-m-d")],
+                        ['match_time','<',date("H:i:s", strtotime("+2 hour"))],
+                        ['match_time','>',date("H:i:s", time())]
+                    ];
+                    break;
+                case 'StToday'://今日 今日未开始未结束
+                    $where = [
+                        ['match_date','=',date("Y-m-d")],
+                        ['match_time','>',date("H:i:s", time())],
+                    ];
+                    break;
+                case 'StMorningPlate'://早盘
+                    $where = [
+                        ['is_morningplate', '=', 1],
+                        ['us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
+                    ];
+                    break;
+                case 'StStringScene'://串场
+                    $where = [
+                        ['is_stringscene', '=', 1],
+                        ['us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
+                    ];
+                    break;
+                case 'StChampion'://冠军
+                    $where = [
+                        'type'=>1
+                    ];
+                    break;
+                default:
+                    throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
+            }
+        }else{
+            switch ($type_code){
+                case 'StRollBall'://滚球 正在进行
+                    $where = [
+                        [$model_match.'.status','=','1'],
+                    ];
+                    break;
+                case 'StSoon'://即将 今日两小时内开始
+                    $where = [
+                        [$model_match.'.status','=','0'],
+                        [$model_match.'.match_date','=',date("Y-m-d")],
+                        [$model_match.'.match_time','<',date("H:i:s", strtotime("+2 hour"))],
+                        [$model_match.'.match_time','>',date("H:i:s", time())]
+                    ];
+                    break;
+                case 'StToday'://今日 今日未开始未结束
+                    $where = [
+                        [$model_match.'.match_date','=',date("Y-m-d")],
+                        [$model_match.'.match_time','>',date("H:i:s", time())],
+                    ];
+                    break;
+                case 'all'://所有赛事
+                    $where = [
+                        [$model_match.'.status', '<', '2'],
+                    ];
+                    break;
+                case 'StMorningPlate'://早盘
+                    $where = [
+                        [$model_match.'.is_morningplate','=',1],
+                        [$model_match.'.us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
+                    ];
+                    break;
+                case 'StStringScene'://串场 查询串场状态为1 开赛时间大于当前时间
+                    $where = [
+                        [$model_match.'.is_stringscene','=',1],
+                        [$model_match.'.us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
+                    ];
+                    break;
+                case 'StChampion'://冠军
+                    $where = [
+                        'type'=>1
+                    ];
+                    break;
+                default:
+                    throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
+            }
+        }
+
+        return $where;
+    }
+
+    /**
+     * @param $data
+     * @return array
+     * 处理当国家下无联赛数据 删除该数组
+     */
+    function handleArr($data){
+        $hData = [];
+        foreach ($data as $key =>$v){
+            if(empty($v['league_count'])){
+                $v = [];
+            }
+            $hData[]=$v;
+        }
+        foreach($hData as $k=>$v){
+            if(empty($v)){
+                unset($hData[$k]);
+            }
+        }
+        foreach ($hData as $k=>$v){
+            $v['league_count'] = array_values($v['league_count']);
+            $hData[$k]=$v;
+        }
+
+        return array_values($hData);
+    }
+
+
+    /**
+     * @param $arr
+     * @param $key
+     * @return array
+     * 去除二维数组重复项
+     */
+    function array_unset_tt($arr,$key){
+        //建立一个目标数组
+        $res = array();
+        foreach ($arr as $value) {
+            //查看有没有重复项
+            if(isset($res[$value[$key]])){
+                unset($value[$key]);  //有:销毁
+            }else{
+                $res[$value[$key]] = $value;
+            }
+        }
+        return $res;
+    }
+
+    /**
+     * 处理冠军盘口 数组结构
+     */
+    function array_gj_tt($data,$oddsData){
+        foreach ($data as $k=>&$v){
+            foreach ($v['league_count'] as $kk=>&$vv){
+                foreach ($oddsData as $kkk=>$vvv){
+                    if($vv['lg_id'] == $vvv['lg_id']){
+                        $vv['oddsData'][]=$vvv;
+                    }
+                }
+
+                if($vv['oddsData']){
+                    $vv['oddsData'] = $this->array_unset_tt($vv['oddsData'],'p_code');
+                    $vv['count'] = count($vv['oddsData']);
+                    unset($vv['oddsData']);
+                }
+
+                if(count($vv) == 5){
+                    unset($v['league_count'][$kk]);
+                }
+            }
+            $v['league_count'] =  array_values($v['league_count']);
+            if(empty($v['league_count'])){
+                unset($data[$k]);
+            }
+        }
+
+        return array_values($data);
+    }
+
+    /**
+     * 处理冠军以外 数组结构
+     */
+    function array_other_tt($data,$matchData){
+        foreach ($data as $k=>&$v){
+            foreach ($v['league_count'] as $kk=>&$vv){
+                foreach ($matchData as $kkk=>$vvv){
+                    if($vv['lg_id'] == $vvv['lg_id']){
+                        $vv['matchData'][]=$vvv;
+                    }
+                }
+
+                if($vv['matchData']){
+                    $vv['matchData'] = $this->array_unset_tt($vv['matchData'],'match_id');
+                    $vv['count'] = count($vv['matchData']);
+                    unset($vv['matchData']);
+                }
+
+                if(count($vv) == 5){
+                    unset($v['league_count'][$kk]);
+                }
+            }
+            $v['league_count'] =  array_values($v['league_count']);
+            if(empty($v['league_count'])){
+                unset($data[$k]);
+            }
+        }
+
+        return array_values($data);
+    }
+
+    /**
+     * 时间格式化
+     * @param string $dateformat 时间格式
+     * @param int $timestamp 时间戳
+     * @param int $timeoffset 时区偏差 默认8 北京时间 -4美东时间
+     * @return string
+     */
+    function qgmdate($dateformat = 'Y-m-d H:i:s', $timestamp = '', $timeoffset = 8,$type = '') {
+        if(empty($timestamp)) {
+            $timestamp = time();
+        }
+        $result = gmdate($dateformat, $timestamp + $timeoffset * 3600);
+        return $result;
+    }
+
+    /**
+     * 判断二维数组是否包含一维数组
+     * @param mixed $arr 查询条件
+     * @param mixed $arrs 运动类型
+     * @return string
+     */
+    function judgeEqual($arr, $arrs){
+        foreach ($arrs as $value) {
+            if (count($value) === count($arr)) {
+                $a = 0;
+                foreach ($value as $key => $v) {
+                    $a++;
+                    if ($v != $arr[$key]) {
+                        break;
+                    }
+                    if ($a == count($key)) {    // 到最后一个元素都没有出现不相等,就说明这两个数组相等。
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+// 排列
+    function arrangement($a, $m) {
+        $r = array();
+
+        $n = count($a);
+        if ($m <= 0 || $m > $n) {
+            return $r;
+        }
+
+        for ($i=0; $i<$n; $i++) {
+            $b = $a;
+            $t = array_splice($b, $i, 1);
+            if ($m == 1) {
+                $r[] = $t;
+            } else {
+                $c = $this->arrangement($b, $m-1);
+                foreach ($c as $v) {
+                    $r[] = array_merge($t, $v);
+                }
+            }
+        }
+
+        return $r;
+    }
+
+// 组合
+    function combination($a, $m) {
+        $r = array();
+
+        $n = count($a);
+        if ($m <= 0 || $m > $n) {
+            return $r;
+        }
+
+        for ($i=0; $i<$n; $i++) {
+            $t = array($a[$i]);
+            if ($m == 1) {
+                $r[] = $t;
+            } else {
+                $b = array_slice($a, $i+1);
+                $c = $this->combination($b, $m-1);
+                foreach ($c as $v) {
+                    $r[] = array_merge($t, $v);
+                }
+            }
+        }
+
+        return $r;
+    }
+
+// 阶乘
+    function factorial($n) {
+        return array_product(range(1, $n));
+    }
+
+// 排列数
+    function A1($n, $m) {
+        return factorial($n)/factorial($n-$m);
+    }
+
+// 组合数
+    function C1($n, $m) {
+        return A1($n, $m)/factorial($m);
+    }
+}
+
+?>

+ 287 - 130
app/Lib/Settlement/SettlementOrder.php

@@ -11,113 +11,153 @@ set_time_limit(600);
 ini_set('memory_limit', '256M');
 
 use Illuminate\Support\Facades\DB;
-use App\Lib\Settlement\SettlementBase ;
+use App\Lib\Settlement\SettlementBase;
+use App\Models\SettlementMiddleDetail as SettlementMiddleDetailModel;
 
 
 /**
-   按订单结算或重结算
+ * 按订单结算或重结算
  */
 class SettlementOrder extends SettlementBase
 {
-    private  $orderId = '' ;   //订单ID
-    private  $orderType =  1 ; //订单类型  1单式  2串式;
-    private  $BuyDatasMainModel = [] ;  //订单豪华版  单式一条   串式可能多条
-    private  $BuyDatas = [] ;  //订单豪华版  单式一条   串式可能多条
+    private $orderId = '';   //订单ID
+    private $orderType = 1; //订单类型  1单式  2串式;
+    private $BuyDatasMainModel = [];  //订单豪华版  单式一条   串式可能多条
+    private $BuyDatas = [];  //订单豪华版  单式一条   串式可能多条
+    private $match_id = 0;
+    private $game_code = '';
+    private $SN = 0;    //结算批次号
+    private $hissettlementDetail = [];
+    private $set_type = 0;
 
 
     //返回数据
-    public static function  makeData($status=1,$message='success',$data=''){
+    public static function makeData($status = 1, $message = 'success', $data = '')
+    {
         return [
-            'status' => $status ,
-            'message' =>$message,
-            'data' => $data ,
-        ] ;
+            'status' => $status,
+            'message' => $message,
+            'data' => $data,
+        ];
     }
 
 
-    public function  reSettlement($order_ids,$bettype=2){
-          if (empty($order_ids)){                return  self::makeData(5,'订单号不能为空');        }
-
-          try{
-              DB::beginTransaction ();
-              foreach ($order_ids as $order_id){
-                  $this->BuyDatasMainModel = $this->orderTypeGet($order_id,$bettype);
-                  if ( $this->BuyDatasMainModel->settle_status==2 ){  continue ;  }
-                  if ($this->orderType==1){
-                      $this->SingOrder($order_id);
-                  }else{
-                      $this->ChuanOrder($order_id);
-                  }
-              }
-
-              DB::commit();
-          }catch (\Exception $e){
-              DB::rollBack();
-              return    self::makeData(-2,$e->getMessage());  ;
-          }
-
-            return self::makeData();
+    ///$order_ids 某场比塞全部订单数组, $bettype=2 订单类型: 1单式  2串式(默认),    $settype = 1 结算次数:1首次(默认)  2非首次或重结算
+    public function reSettlement($order_ids, $bettype = 2, $settype = 1, $game_code = 0, $match_id = 0)
+    {
+        if (!in_array($bettype, [1, 2])) {
+            return self::makeData(6, '订单类型参数错误!');
+        }
+        $this->orderType = $bettype;
+
+        if (!in_array($settype, [1, 2])) {
+            return self::makeData(6, '结算参数错误');
+        }
+        $this->set_type = $settype;
+
+        if (empty($order_ids)) {
+            return self::makeData(5, '订单号不能为空');
+        }
+
+        if ($bettype == 1) {
+            $chekArr = $this->Match_check($order_ids, $bettype);
+            if (empty($chekArr) || count($chekArr) != 1) {
+                return self::makeData(10, '不同场比赛不能同时结算!');
+            }
+        }
+        $this->match_id = $game_code;
+        $this->game_code = $match_id;
+
+
+        try {
+            DB::beginTransaction();
+
+            $this->UndoSettlement($this->game_code, $this->match_id, $order_ids, $bettype);
+
+            foreach ($order_ids as $order_id) {
+                $this->BuyDatasMainModel = $this->orderTypeGet($order_id, $bettype);
+
+                if ($this->BuyDatasMainModel->settle_status == 2) {
+                   continue;
+                }
+                if ($bettype == 1) {
+                    $this->SingOrder($order_id);
+                } else {
+                    $this->ChuanOrder($order_id);
+                }
+            }
+            DB::commit();
+        } catch (\Exception $e) {
+            DB::rollBack();
+            return self::makeData(-2, $e->getMessage());
+        }
+        return self::makeData();
+
     }
 
-    public function  orderTypeGet($order_id,$bettype){
-        if ($bettype==1){
-            $datas = DB::table('money_buy_simplex')->where('order_id',$order_id)->first();
-            $this->orderType = 1 ;
-        }else{
-            $datas = DB::table('money_buy_str')->where('order_id',$order_id)->first();
-            $this->orderType = 2 ;
+    public function orderTypeGet($order_id, $bettype)
+    {
+        if ($bettype == 1) {
+            $datas = DB::table('money_buy_simplex')->where('order_id', $order_id)->first();
+            $this->orderType = 1;
+        } else {
+            $datas = DB::table('money_buy_str')->where('order_id', $order_id)->first();
+            $this->orderType = 2;
         }
 
-        if (!$datas){
-               throw  new  \Exception('没有主订单信息');
+        if (!$datas) {
+            throw  new  \Exception('没有主订单信息');
         }
 
-        return $datas ;
+        return $datas;
     }
 
     /**
      * 单式注单结算
      * @param mixed $order_id 注单ID
      */
-    public function singOrder($order_id) {
+    public function singOrder($order_id)
+    {
         // 查询订单下所有的单式注单
-        $simplexData = DB :: table('money_buy_simplex')
-            -> select('batch_id', 'account_identity', 'order_id', 'money', 'game_code', 'info_identity','match_id')
-            -> where(['order_id' => $order_id])
-            -> first();
+        $simplexData = DB:: table('money_buy_simplex')
+            ->select('batch_id', 'account_identity', 'order_id', 'money', 'game_code', 'info_identity', 'match_id')
+            ->where(['order_id' => $order_id])
+            ->first();
         // 查询单式注单下的所有玩法
-        $matchData = DB :: table('money_buy_match') -> select('odds', 'result', 'batch_id', 'bet_money') -> where(['bet_type' => 1, 'batch_id' => $simplexData -> batch_id, 'match_id' => $simplexData->match_id]);
-        $matchData = $matchData -> where(function($query) {
-            $query = $query -> where(['result' => 1])
-                -> orWhere(['result' => 2])
-                -> orWhere(['result' => 3])
-                -> orWhere(['result' => 4]);
+        $matchData = DB:: table('money_buy_match')->select('odds', 'result', 'batch_id', 'bet_money')->where(['bet_type' => 1, 'batch_id' => $simplexData->batch_id, 'match_id' => $simplexData->match_id]);
+        $matchData = $matchData->where(function ($query) {
+            $query = $query->where(['result' => 1])
+                ->orWhere(['result' => 2])
+                ->orWhere(['result' => 3])
+                ->orWhere(['result' => 4]);
         });
-        $matchData = $matchData -> get() -> toArray();
+        $matchData = $matchData->get()->toArray();
         // 计算总回款
         $settlementBase = new \App\Lib\Settlement\SettlementBase;
         $returnMoney = 0;
         foreach ($matchData as $k => $v) {
-            $oddsResult[0]['winOrLose'] = $v -> result;
-            $oddsResult[0]['odds'] = $v -> odds;
-            $getReturnMoney = $settlementBase -> stringOdds($oddsResult);
-            $returnMoney += $getReturnMoney['returnMoney'] * $v -> bet_money;
+            $oddsResult[0]['winOrLose'] = $v->result;
+            $oddsResult[0]['odds'] = $v->odds;
+            $getReturnMoney = $settlementBase->stringOdds($oddsResult);
+            $returnMoney += $getReturnMoney['returnMoney'] * $v->bet_money;
         }
-        $returnMoney = sprintf("%.2f",substr(sprintf("%.3f", $returnMoney), 0, -1));
+        $returnMoney = sprintf("%.2f", substr(sprintf("%.3f", $returnMoney), 0, -1));
         // 判断盈亏  1 赢  2 输  3 平
-        $game_status = $returnMoney > $simplexData -> money ? 1 : ($returnMoney == $simplexData -> money ? 3 : 2);
+        $game_status = $returnMoney > $simplexData->money ? 1 : ($returnMoney == $simplexData->money ? 3 : 2);
         // 修改投注表状态及盈亏
-        DB :: table('money_buy_simplex')
-            -> where(['order_id' => $order_id])
-            -> update(['settle_status' => 2, 'game_status' => $game_status, 'gain_money' => $returnMoney, 'settlementTime' => date('Y-m-d H:i:s')]);
-        $this -> insertData(
+        DB:: table('money_buy_simplex')
+            ->where(['order_id' => $order_id])
+            ->update(['settle_status' => 2, 'game_status' => $game_status, 'gain_money' => $returnMoney, 'settlementTime' => date('Y-m-d H:i:s')]);
+        $this->WriteOrAddSettlement($this->game_code, $this->match_id, $this->orderType, $order_id, $this->BuyDatasMainModel->account_identity, $returnMoney);
+        $this->insertData(
             $order_id,
             $returnMoney,
-            $simplexData -> account_identity,
+            $simplexData->account_identity,
             1,
-            $simplexData -> game_code,
-            $simplexData -> info_identity,
-            $simplexData -> money
+            $simplexData->game_code,
+            $simplexData->info_identity,
+            $simplexData->money,
+            $this->match_id
         );
     }
 
@@ -130,27 +170,29 @@ class SettlementOrder extends SettlementBase
      * @param mixed $game_name 游戏名(zq,lq)
      * @param mixed $buy_identity 游戏投注id
      * @param mixed $money 投注金额
+     * @param mixed $match_id 赛场ID
      */
-    public function insertData($order_id, $returnMoney, $account_identity, $type, $game_name, $buy_identity, $money) {
+    public function insertData($order_id, $returnMoney, $account_identity, $type, $game_name, $buy_identity, $money,$match_id=0)
+    {
         // 查询用户当前剩余金额
-        $accountInfo = DB :: table('account_detailed')
-            -> join('account', 'account_detailed.account_identity', 'account.identity')
-            -> select(['available_cash', 'cash', 'account', 'account_identity'])
-            -> where(['account_identity' => $account_identity])
-            -> first();
+        $accountInfo = DB:: table('account_detailed')
+            ->join('account', 'account_detailed.account_identity', 'account.identity')
+            ->select(['available_cash', 'cash', 'account', 'account_identity'])
+            ->where(['account_identity' => $account_identity])
+            ->first();
         // 计算用户回账后余额
-        $available_cash = $accountInfo -> available_cash + $returnMoney;
-        $cash = $accountInfo -> cash + $returnMoney;
+        $available_cash = $accountInfo->available_cash + $returnMoney;
+        $cash = $accountInfo->cash + $returnMoney;
         // 添加流水记录
         $info_identity = UUID();
         $money_time = date('Y-m-d H:i:s', time());
         $trade_desc = $type == 1 ? '单式投注订单回款' : '串式投注订单回款';
         $reason = $type == 1 ? '单式投注订单回款' : '串式投注订单回款';
-        DB :: table('money_details') -> insert([
+        DB:: table('money_details')->insert([
             'info_identity' => $info_identity,
             'trade_id' => $order_id,
-            'account_name' => $accountInfo -> account,
-            'account_identity' => $accountInfo -> account_identity,
+            'account_name' => $accountInfo->account,
+            'account_identity' => $accountInfo->account_identity,
             'money' => $returnMoney,
             'money_time' => $money_time,
             'money_type' => 1,
@@ -163,12 +205,12 @@ class SettlementOrder extends SettlementBase
         ]);
         // 修改用余额
         DB:: table('account_detailed')
-            -> where(['account_identity' => $account_identity])
-            -> update(['available_cash' => $available_cash, 'cash' => $cash]);
+            ->where(['account_identity' => $account_identity])
+            ->update(['available_cash' => $available_cash, 'cash' => $cash]);
         // 新增用户中奖信息
         $content = $type == 1 ? '您的单式投注订单' . $order_id . '于' . $money_time . '成功回款' . $returnMoney . '该次投注流程结束,如有疑问请联系客服'
             : '您的串式投注订单' . $order_id . '于' . $money_time . '成功回款' . $returnMoney . '该次投注流程结束,如有疑问请联系客服';
-        DB:: table('account_news') -> insert([
+        DB:: table('account_news')->insert([
             'identity' => $info_identity,
             'account_identity' => $account_identity,
             'title' => '投注订单回款通知',
@@ -179,60 +221,175 @@ class SettlementOrder extends SettlementBase
             'type' => 1,
         ]);
         // 新增中奖记录表
-        DB:: table('money_prize') -> insert([
-            'info_identity' => $info_identity,
-            'order_id' => $order_id,
-            'account_identity' => $account_identity,
-            'account_name' => $accountInfo -> account,
-            'game_name' => $game_name,
-            'buy_identity' => $buy_identity,
-            'money' => $money,
-            'money_time' => $money_time,
-            'status' => 1,
-            'prize_money' => $returnMoney,
-            'get_money' => $returnMoney - $money,
-        ]);
+        $old = DB:: table('money_prize')->where(['buy_identity' => $buy_identity])->first();
+        if ($old) {
+            DB:: table('money_prize')->where(['buy_identity' => $buy_identity])->update(['money' => $money, 'prize_money' => $returnMoney, 'get_money' => $returnMoney - $money]);
+        } else {
+            DB:: table('money_prize')->insert([
+                'info_identity' => $info_identity,
+                'order_id' => $order_id,
+                'account_identity' => $account_identity,
+                'account_name' => $accountInfo->account,
+                'game_name' => $game_name,
+                'buy_identity' => $buy_identity,
+                'money' => $money,
+                'money_time' => $money_time,
+                'status' => 1,
+                'prize_money' => $returnMoney,
+                'get_money' => $returnMoney - $money,
+            ]);
+        }
+
+        DB::table("st_".$game_name."_result")->where(['match_id'=>$match_id])->update(['status'=>3]);
+        DB::table("st_".$game_name."_competition")->where(['match_id'=>$match_id])->update(['status'=>3]);
+
     }
 
 
     //单个串式订单的处理
-    public function  ChuanOrder($order_id){
-              $batch_id = $this->BuyDatasMainModel->batch_id ;
-              $matchModels = DB::table('money_buy_match')->where(['batch_id'=>$batch_id,'bet_type' => 2])->get();
-              if (empty($matchModels)) {   throw  new  \Exception('match 数据异常');}
-
-              $in_array = [] ;
-              foreach ($matchModels as $val){
-                  if (!in_array($val->result,[-1,1,2,3,4])){  throw  new  \Exception('match 比赛结果异常->'.$val->id); }
-
-                  if ($val->result == -1){
-                      /*
-                       $ret = DB::table('money_buy_str')->where('id',$this->BuyDatasMainModel->id)->update(['wait_match_num'=>0,'prize_note'=>0,'settle_status'=>2,'gain_money'=>0]);
-                       if (!$ret){ throw  new \Exception('更新数据出错1!');   }
-                       $ret = DB::update('update money_buy_str  set settle_status=2,game_status=3,gain_money=0  where batch_id = ?', [$batch_id]);
-                       */
-                       DB::table('money_buy_str')->where('batch_id',$batch_id)->update(['wait_match_num'=>0,'prize_note'=>0,'game_status'=>3,'settle_status'=>2,'gain_money'=>0,'settlementTime'=>date('Y-m-d H:i:s')]);
-                       //if(!($ret || $ret===0)){        throw  new \Exception('更新数据出错2!');      }
-                       return true ;
-                  }
-
-                  $in_array[] = ['odds'=>$val->odds,'winOrLose'=>$val->result] ;
-              }
-
-               $chuanNum = intval(substr($this->BuyDatasMainModel->str_type,0,1));
-               $lasPeilv  = $this->stringComputing([$in_array,$chuanNum]);
-               $money = floatPointDigit($this->BuyDatasMainModel->money *  $lasPeilv ) ;
-               $newTime = date('Y-m-d H:i:s');
-               $ret = DB::update('update money_buy_str  set settle_status=2 , game_status=1 , "settlementTime"=? , gain_money=?  where order_id = ?', [$newTime,$money,$order_id]);
-               if(!($ret || $ret===0)){                     throw  new \Exception('更新数据出错3!');             }
-
-               $this->insertData($order_id,$money,$this->BuyDatasMainModel->account_identity,2,$val->game_code,$this->BuyDatasMainModel->info_identity,$money);
-
-               return true ;
+    public function ChuanOrder($order_id)
+    {
+        $batch_id = $this->BuyDatasMainModel->batch_id;
+        $matchModels = DB::table('money_buy_match')->where(['batch_id' => $batch_id, 'bet_type' => 2])->get();
+        if (empty($matchModels)) {
+            throw  new  \Exception('match 数据异常');
+        }
+
+
+        $newTime = date('Y-m-d H:i:s');
+        if ($this->BuyDatasMainModel->status==1){
+            $in_array = [];
+            foreach ($matchModels as $val) {
+                if (!in_array($val->result, [-1, 1, 2, 3, 4])) {
+                    throw  new  \Exception('match 比赛结果异常或还没有输赢结果->' . $val->id);
+                }
+
+                if ($val->result == -1) {
+                    DB::table('money_buy_str')->where('batch_id', $batch_id)->update(['wait_match_num' => 0, 'prize_note' => 0, 'game_status' => 3, 'settle_status' => 2, 'gain_money' => 0, 'settlementTime' => date('Y-m-d H:i:s')]);
+                    return true;
+                }
+
+                $in_array[] = ['odds' => $val->odds, 'winOrLose' => $val->result];
+            }
+
+            $chuanNum = intval(substr($this->BuyDatasMainModel->str_type, 0, 1));
+            $lasPeilv = $this->stringComputing([$in_array, $chuanNum]);
+            $money = floatPointDigit($this->BuyDatasMainModel->money * $lasPeilv);
+
+        }else{
+            $money = $this->BuyDatasMainModel->money;
+        }
 
+        $ret = DB::update('update money_buy_str  set settle_status=2 , game_status=1 , "settlementTime"=? , gain_money=?  where order_id = ?', [$newTime, $money, $order_id]);
+        if (!($ret || $ret === 0)) {
+            throw  new \Exception('更新数据出错3!');
+        }
+
+        $this->WriteOrAddSettlement($this->game_code, $this->match_id, $this->orderType, $order_id, $this->BuyDatasMainModel->account_identity, $money);
+        $this->insertData($order_id, $money, $this->BuyDatasMainModel->account_identity, 2, $val->game_code, $this->BuyDatasMainModel->info_identity, $money,$this->match_id);
+
+        return true;
+
+    }
+
+    //校验是否同一场比赛的订单处理
+    private function Match_check($idsArray, $betType)
+    {
+        array_walk($idsArray, function (&$item, $key) {
+            $item = "'" . $item . "'";
+        });
+
+        $idString = implode(",", $idsArray);
+
+        $table = "money_buy_simplex";
+        $sql = "select game_code,match_id   from  $table  where  status=1 and  order_id in ($idString)  group by  game_code,match_id ";
+        $ret = DB::select($sql);
+        return $ret;
+
+    }
+
+    //取消某个赛事订单的结算数据
+    public function UndoSettlement($game_code, $match_id, $order_ids, $bettype)
+    {
+        if ($this->set_type == 1) {
+            return;
+        }
+        $modelSMD = new SettlementMiddleDetailModel();
+        $hisData = $modelSMD->getSettledatas($game_code, $match_id, $bettype);
+
+        if (empty($hisData)) {
+            return true;
+        }
+
+        array_walk($order_ids, function (&$item, $key) {
+            $item = "'" . $item . "'";
+        });
+
+        $this->hissettlementDetail = $hisData;
+        $orderList = [];
+
+        if ($bettype == 1) {
+            $order_list = DB::table('money_buy_simplex')->where(['game_code' => $game_code, 'match_id' => $match_id, 'status' => 1])->whereIn('order_id', $order_ids)->get();
+            foreach ($order_list as $val) {
+                $orderList[$val->order_id] = $val;
+            }
+        } else {
+            $order_list = DB::table('money_buy_str') > where(['status' => 1])->whereIn('order_id', $order_ids)->get();
+            foreach ($order_list as $val) {
+                $orderList[$val->order_id] = $val;
             }
+        }
+
+        foreach ($hisData as $oid => $val) {
+            if (!isset($orderList[$oid])) {
+                throw  new  \Exception("订单数据缺失异常!($game_code,$match_id,$oid)");
+            }
+            $money = $val->money * (-1);
+            if (intval($money) * 100 == 0) {
+                continue;
+            }
+            $this->insertData($oid, $money, $val->account_identity, $bettype, $game_code, $orderList[$oid]->info_identity, $money,$this->match_id);
+        }
+        $table = $bettype == 1 ? 'money_buy_simplex' : 'money_buy_str';
+        if ($bettype == 1) {
+            $ret1 = DB::table($table)->where(['game_code' => $game_code, 'match_id' => $match_id, 'status' => 1])->whereIn('order_id', $order_ids)->update(['settle_status' => 1, 'gain_money' => 0]);
+        } else {
+            $ret1 = DB::table($table)->where(['status' => 1])->whereIn('order_id', $order_ids)->update(['settle_status' => 1, 'gain_money' => 0]);
+        }
 
+        $ret2 = DB::table('settlement_middle_detail')->where(['game_code' => $game_code, 'match_id' => $match_id, 'bet_type' => $bettype])->whereIn('order_id', $order_ids)->update(['money' => 0]);
 
+        if ($ret1 && $ret2) {
+            return true;
+        } else {
+            throw new \Exception("取消结算更新数据状态出错操作中止($ret1 $ret2)!");
+        }
+
+    }
+
+    private function WriteOrAddSettlement($game_code, $match_id, $bet_type, $order_id, $account_ident, $money)
+    {
+
+        if (isset($this->hissettlementDetail[$order_id])) {
+            $ret = DB::table('settlement_middle_detail')
+                ->where(['game_code' => $game_code, 'match_id' => $match_id, 'bet_type' => $bet_type, 'order_id' => $order_id])
+                ->update(['money' => $money]);
+        } else {
+            $ret = DB::table('settlement_middle_detail')
+                ->insertGetId([
+                    'game_code' => $game_code,
+                    'match_id' => $match_id,
+                    'account_identity' => $account_ident,
+                    'bet_type' => $bet_type,
+                    'order_id' => $order_id,
+                    'money' => $money
+                ]);
+        }
+        if (!$ret) {
+            throw  new  \Exception("更新数据异常(bt:$bet_type  od:$order_id  ret:$ret)");
+        }
+        return true;
+    }
 
 
-    }
+}

+ 7 - 5
app/Lib/Settlement/SettlementWinFail.php

@@ -61,8 +61,10 @@ class SettlementWinFail
             $this->writeStatusBegin($ComendNoticModel);
 
             $allmatchs = DB::table('money_buy_match')->where(['game_code' => $ComendNoticModel->game_code, 'match_id' => $ComendNoticModel->match_id, 'result' => 0])->get();
-            if (empty($allmatchs)) {
+            if (count($allmatchs)==0) {
                 $this->writeStatusEndOk($ComendNoticModel);
+                DB::table("st_".$ComendNoticModel->game_code."_result")->where(['match_id'=>$ComendNoticModel->match_id])->update(['status'=>3]);
+                DB::table("st_".$ComendNoticModel->game_code."_competition")->where(['match_id'=>$ComendNoticModel->match_id])->update(['status'=>3]);
                 DB::commit();
                 return $this->makeData(1, '本赛事无订单数据,退出');
             }
@@ -94,11 +96,11 @@ class SettlementWinFail
     private function Settlement_simplex($game_type, $match_id)
     {
         $buyModels = DB::table('money_buy_simplex')->where(['match_id' => $match_id, 'game_status' => 0])->get();
-        if (empty($buyModels)) {
+        if (count($buyModels)==0) {
             return true;
         }
         $buymatchModles = DB::table('money_buy_match')->where(['match_id' => $match_id, 'bet_type' => 1, 'result' => 0, 'game_code' => $game_type])->orderby('batch_id', 'asc')->get();
-        if (empty($buymatchModles)) {
+        if (count($buymatchModles)==0) {
             return true;
         }
 
@@ -129,7 +131,7 @@ class SettlementWinFail
     private function Settlement_str($game_type, $match_id)
     {
         $matchModels = DB::table('money_buy_match')->where(['match_id' => $match_id, 'bet_type' => 2, 'game_code' => $game_type])->get();
-        if (empty($matchModels)) {
+        if (count($matchModels)==0) {
             return true;
         }
 
@@ -144,7 +146,7 @@ class SettlementWinFail
 
         $buyModels = DB::table('money_buy_str')->whereIn('batch_id', $batch_ids_array)->get();
         $buyKeyModels = [];
-        if (empty($buyModels)) {
+        if (count($buyModels)==0) {
             return true;
         }
         foreach ($buyModels as $val) {

+ 38 - 1
app/Models/MoneyBuyMatch.php

@@ -24,7 +24,44 @@ class MoneyBuyMatch extends Model
         return $datas ;
     }
 
-    
+  	//赛事下所有下注单式下单
+    function allsimplexorder($ssid){ 
+        //单式下单
+        $where = array();
+        $where[] = array('money_buy_match.match_id', '=', $ssid);
+        $where[] = array('money_buy_match.bet_type', '=', 1);
+        $data = $this->join('money_buy_simplex','money_buy_match.batch_id','=','money_buy_simplex.batch_id')->select('money_buy_simplex.order_id','money_buy_simplex.money','money_buy_simplex.account_identity','money_buy_simplex.info_identity','money_buy_simplex.match_id')->where($where)->get()->toArray();
+        return $data;
+    }
+
+    //赛事下所有下注串式下单
+    function allstrorder($ssid){ 
+        //串式下单
+        $where = array();
+        $where[] = array('money_buy_match.match_id', '=', $ssid);
+        $where[] = array('money_buy_match.bet_type', '=', 2);
+        $data = $this->join('money_buy_str','money_buy_match.batch_id','=','money_buy_str.batch_id')->select('money_buy_str.order_id')->where($where)->get()->toArray();
+        return $data;
+    }
+
+    //修改串式下注状态
+    function updatast($match_id){
+        $the = array(
+            'updated_at'=>date('Y-m-d H:i:s'),
+            'result'=>2,
+        );
+        $where = array(
+        	'match_id'=>$match_id,
+        	'bet_type'=>2,
+        );
+
+        $res = $this->where($where)->update($the);
+          
+        if (!$res) {
+            return -4010000102; //更新失败
+        }
+        return $res;
+    }
 
 
 }

+ 63 - 16
app/Models/MoneyBuyStr.php

@@ -16,14 +16,14 @@ class MoneyBuyStr extends BaseModel {
         if (is_array ($where) && count ($where) > 0) {
             $data = $this
                 ->join('money_details','money_details.info_identity','=','money_buy_str.info_identity')
-                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
+                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.account_identity','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
                 ->where($where)
                 ->orderby('money_buy_str.money_time','desc')
                 ->paginate ($list);
         } else {
             $data = $this
                 ->join('money_details','money_details.info_identity','=','money_buy_str.info_identity')
-                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
+                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.account_identity','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
                 ->orderby('money_buy_str.money_time','desc')
                 ->paginate ($list);
         }
@@ -34,16 +34,19 @@ class MoneyBuyStr extends BaseModel {
         //反水
         $water_return_money = \App\Models\Money_details::where('trade_type','7')->get();
 
+        //注单作废
+        $invalid_money = \App\Models\Money_details::where('trade_type','3')->get();
+
         //订单投注的玩法
         $content = \App\Models\MoneyBuyMatch::where('bet_type','2')->get();
 
         for($i=0;$i<count($data);$i++){
             if($data[$i]->status==1){
-                $data[$i]->status = '投注';
+                $data[$i]->order_status = '投注'.'<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerStringNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerStringNoteList/invalid/?id='.$data[$i]->id.'\');"> 作废 </a>';
             }else if($data[$i]->status==2){
-                $data[$i]->status = '追号';
-            }else if($data[$i]->status==4){
-                $data[$i]->status = '撤单';
+                $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){
+                $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){
                 $data[$i]->settle_status = '未结算';
@@ -67,7 +70,11 @@ class MoneyBuyStr 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){
-                    $data[$i]->water_return = $water_return_money[$a]->money;
+                    if($data[$i]->status == 2 || $data[$i]->status == 3){
+                        $data[$i]->water_return = 0;
+                    }else{
+                        $data[$i]->water_return = $water_return_money[$a]->money;
+                    }
                     //用户投注后账户金额
                     $data[$i]->frozen_cash = $water_return_money[$a]->money_cash;
                 }
@@ -83,8 +90,16 @@ class MoneyBuyStr extends BaseModel {
             $data[$i]->money_time = '下注:'.$data[$i]->money_time;
             //用户投注前账户金额
             $data[$i]->available_cash = $data[$i]->money_cash+$data[$i]->money;
-
             $data[$i]->account_money = $data[$i]->available_cash.' <span>'.$data[$i]->money.' </span> '.$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]->settle_status = $data[$i]->settle_status;
 
@@ -113,13 +128,13 @@ class MoneyBuyStr extends BaseModel {
     //投注金额汇总统计
     function MoneyCount($where = '') {
         $data = array();
-        $data['all_money'] = $this->sum('money');
-        $data['all_prize_money'] = $this->sum('prize_money');
-        $data['alraedy_prize_money'] = $this->where('settle_status','2')->sum('gain_money');
+        $data['all_money'] = $this->where('status','1')->sum('money');
+        $data['all_prize_money'] = $this->where('status','1')->sum('prize_money');
+        $data['alraedy_prize_money'] = $this->where('settle_status','2')->where('status','1')->sum('gain_money');
         if (!empty($where) && is_array($where)) {
-            $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');
+            $data['all_money'] = $this->where($where)->where('status','1')->sum('money');
+            $data['all_prize_money'] = $this->where($where)->where('status','1')->sum('prize_money');
+            $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->where('status','1')->sum('gain_money');
         }
 
         return $data;
@@ -132,7 +147,11 @@ class MoneyBuyStr extends BaseModel {
         $game_type = \App\Models\StGameType::get();
         $odds_code = \App\Models\Matchcode::get();
         for($i=0;$i<count($data);$i++){
-            $league = DB::table('st_'.$data[$i]->game_code.'_league')->join('st_'.$data[$i]->game_code.'_competition','st_'.$data[$i]->game_code.'_competition.lg_id','=','st_'.$data[$i]->game_code.'_league.lg_id')->where('st_'.$data[$i]->game_code.'_league.lg_id',$data[$i]->lg_id)->first();
+
+            if($data[$i]->p_code == 'first_last_ball' || $data[$i]->p_code == 'half_full' || $data[$i]->p_code == 'capot' || $data[$i]->p_code == 'two_sides' ){
+                $data[$i]->condition = '';
+            }
+            
             $league = DB::table('st_'.$data[$i]->game_code.'_league')->join('st_'.$data[$i]->game_code.'_competition','st_'.$data[$i]->game_code.'_competition.lg_id','=','st_'.$data[$i]->game_code.'_league.lg_id')->where('st_'.$data[$i]->game_code.'_league.lg_id',$data[$i]->lg_id)->first();
             if(!empty($league)){
                 $data[$i]->league = $league->name_chinese;
@@ -149,6 +168,17 @@ class MoneyBuyStr extends BaseModel {
                 $data[$i]->team = $data[$i]->guest_team;
             }
 
+            if($data[$i]->p_code == 'half_full'){
+                $string = explode('_',$data[$i]->odds_code);
+                if($string[2] == 'home')$string[2]=$data[$i]->home_team;
+                if($string[2] == 'guest')$string[2]=$data[$i]->guest_team;
+                if($string[2] == 'dogfall')$string[2]='和局';
+                if($string[3] == 'home')$string[3]=$data[$i]->home_team;
+                if($string[3] == 'guest')$string[3]=$data[$i]->guest_team;
+                if($string[3] == 'dogfall')$string[3]='和局';
+                $data[$i]->team = $string['2'].'/'.$string['3'];
+            }
+
             for($j=0;$j<count($odds_code);$j++){
                 if($data[$i]->game_code == $odds_code[$j]->game_code && $data[$i]->odds_code == $odds_code[$j]->odds_code){
                     $data[$i]->odds_code = $odds_code[$j]->odds_name;
@@ -159,7 +189,7 @@ class MoneyBuyStr extends BaseModel {
             }
 
             $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
-            $data[$i]->content = $data[$i]->p_code.'<br>'.$data[$i]->odds_code.$data[$i]->condition.'<br>'.$data[$i]->team.' @'.$data[$i]->odds;
+            $data[$i]->content = $data[$i]->p_code.'<br><span>'.$data[$i]->odds_code.$data[$i]->condition.'<br>'.$data[$i]->team.' @'.$data[$i]->odds.'</span>';
 
             for($j=0;$j<count($game_type);$j++){
                 if($data[$i]->game_code == $game_type[$j]->game_code){
@@ -190,4 +220,21 @@ class MoneyBuyStr extends BaseModel {
         return $data->toArray();
     }
 
+    //串式撤单修改状态
+    function updatestatus($data){
+        if($data){
+            for ($i=0; $i < count($data); $i++) { 
+                $the = array(
+                    'status' => 2,
+                );
+                $res = $this->where('order_id',$data[$i])->update($the);
+            }
+            if (!$res) {
+                return -4010000102; //更新失败
+            }
+            return $res;
+        }
+    }
+
+
 }

+ 1 - 1
app/Models/NagentCountrecord.php

@@ -129,7 +129,7 @@ class NagentCountrecord extends BaseModel {
     protected function getRealData($game,$arr,$stime,$etime,$uid=''){
         $date = date('Y-m-d',strtotime($stime));
 
-        $buyobj = '\\App\\Models\\' . ucfirst($game) . '_betting_ogrbv'; //游戏注单表模型
+        $buyobj = '\\App\\Model\\' . ucfirst($game) . '_betting_ogrbv'; //游戏注单表模型
 
         $stime = strtotime($stime);
         $etime = strtotime($etime);

+ 1 - 1
app/Models/Rgame_setting.php

@@ -90,7 +90,7 @@ class Rgame_setting extends BaseModel
             $account = $this->setGameName($gdata['user_prefix'],$account,$gdata['game_type']);
             if($account<0)return $a;
         }
-        $betobj = '\\App\\Models\\' .ucfirst($gdata['game_type']) . '_betting_ogrbv';
+        $betobj = '\\App\\Model\\' .ucfirst($gdata['game_type']) . '_betting_ogrbv';
         $jump_url = $betobj::transferGame($agent,$gdata,$account);
         $arr =  $this->curl_get_content($jump_url);
         $array = json_decode($arr, 1);

+ 27 - 0
app/Models/SettlementMiddleDetail.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Models;
+class SettlementMiddleDetail extends BaseModel
+{
+    protected $table = "settlement_middle_detail";
+    public $timestamps = false;
+
+    public function getSettledatas($gametype, $matchid, $bettype)
+    {
+        $ret = [];
+        $his = $this->where([
+            'game_code' => $gametype,
+            'match_id' => $matchid,
+            'bet_type' => $bettype
+        ])->get();
+
+        if ($his) {
+            foreach ($his as $val) {
+                $ret[$val->order_id] = $val;
+            }
+        }
+        return $ret;
+    }
+
+
+}

+ 5 - 5
app/Models/SportsBase.php

@@ -19,9 +19,9 @@ class SportsBase extends BaseModel {
                 if($bqmatch[$b]->match_date < date("Y-m-d",time()) && strtotime($bqmatch[$b]->match_time.' '.$bqmatch[$b]->match_time)+10800 < time()){
                     \App\Models\SportsBase::where('match_id',$bqmatch[$b]->match_id)->update(['status'=>'2']);
                     \App\Models\Stbqresultrecord::where('match_id',$bqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$bqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$bqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'bq';
 //                        $db->match_id = $bqmatch[$b]->match_id;
@@ -33,9 +33,9 @@ class SportsBase extends BaseModel {
                 if($bqmatch[$b]->match_date == date("Y-m-d",time()) && strtotime($bqmatch[$b]->match_date.' '.$bqmatch[$b]->match_time)+10800 < time()){
                     \App\Models\SportsBase::where('match_id',$bqmatch[$b]->match_id)->update(['status'=>'2']);
                     \App\Models\Stbqresultrecord::where('match_id',$bqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$bqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$bqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'bq';
 //                        $db->match_id = $bqmatch[$b]->match_id;
@@ -49,7 +49,7 @@ class SportsBase extends BaseModel {
         
         $where[] = array('st_bq_league.name_chinese','<>','');
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
 //            $where[] = array('st_bq_local_match.source', '=', $source->infocontent);
 //            $where[] = array('st_bq_local_league.source', '=', $source->infocontent);

+ 5 - 5
app/Models/SportsBasket.php

@@ -19,9 +19,9 @@ class SportsBasket extends BaseModel {
                 if($lqmatch[$b]->match_date < date("Y-m-d",time()) && strtotime($lqmatch[$b]->match_time.' '.$lqmatch[$b]->match_time)+4200 < time()){
                     \App\Models\SportsBasket::where('id',$lqmatch[$b]->id)->update(['status'=>'2']);
                     \App\Models\Stlqresultrecord::where('match_id',$lqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$lqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$lqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'lq';
 //                        $db->match_id = $lqmatch[$b]->match_id;
@@ -33,9 +33,9 @@ class SportsBasket extends BaseModel {
                 if($lqmatch[$b]->match_date == date("Y-m-d",time()) && strtotime($lqmatch[$b]->match_date.' '.$lqmatch[$b]->match_time)+4200 < time()){
                     \App\Models\SportsBasket::where('id',$lqmatch[$b]->id)->update(['status'=>'2']);
                     \App\Models\Stlqresultrecord::where('match_id',$lqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$lqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$lqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'lq';
 //                        $db->match_id = $lqmatch[$b]->match_id;
@@ -49,7 +49,7 @@ class SportsBasket extends BaseModel {
 
         $where[] = array('st_lq_league.name_chinese','<>','');
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
 //            $where[] = array('st_lq_local_match.source', '=', $source->infocontent);
 //            $where[] = array('st_lq_local_league.source', '=', $source->infocontent);

+ 72 - 13
app/Models/SportsNoteList.php

@@ -17,7 +17,7 @@ class SportsNoteList extends BaseModel {
             ->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')
             ->join('st_'.$type.'_competition','st_'.$type.'_competition.match_id','=','money_buy_simplex.match_id')
             ->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_id')
-            ->select('money_buy_simplex.id','money_buy_simplex.account_name','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','money_details.money_cash','money_buy_simplex.batch_id','st_'.$type.'_league.name_chinese','st_'.$type.'_league.last_time')
+            ->select('money_buy_simplex.id','money_buy_simplex.account_name','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','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);
@@ -28,15 +28,25 @@ class SportsNoteList extends BaseModel {
         //反水
         $water_return_money = \App\Models\Money_details::where('trade_type','7')->get();
 
+        //注单作废
+        $invalid_money = \App\Models\Money_details::where('trade_type','3')->get();
+
         //订单投注的玩法
         $content = \App\Models\MoneyBuyMatch::where('bet_type','1')->get();
 
         //玩法
         $result = \App\Models\Matchcode::where('game_code','zq')->get();
-        //$result = \App\Models\Matchcode::get();
+        //$result = \App\Model\Matchcode::get();
 
 
         for($i=0;$i<count($data);$i++){
+            if($data[$i]->status==1){
+                $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==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){
+                $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){
                 $data[$i]->settle_status = '未结算';
             }else if($data[$i]->settle_status==2){
@@ -51,6 +61,7 @@ class SportsNoteList extends BaseModel {
             }else if($data[$i]->game_status==3){
                 $data[$i]->game_status = '平';
             }
+
             $data[$i]->match_id_order = '<span>'.$data[$i]->match_id.'</span> (<span>'.$data[$i]->account_name.'</span>)<br>'.$data[$i]->order_id;
             $data[$i]->league = $data[$i]->name_chinese;
 
@@ -62,7 +73,11 @@ 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){
-                    $data[$i]->water_return = $water_return_money[$a]->money;
+                    if($data[$i]->status == 2 || $data[$i]->status == 3){
+                        $data[$i]->water_return = 0;
+                    }else{
+                        $data[$i]->water_return = $water_return_money[$a]->money;
+                    }
                     //用户投注后账户金额
                     $data[$i]->frozen_cash = $water_return_money[$a]->money_cash;
                 }
@@ -76,12 +91,21 @@ class SportsNoteList extends BaseModel {
             $data[$i]->result = $data[$i]->water_return+$data[$i]->gain_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]->available_cash = $invalid_money[$b]->money_cash;
+                        $data[$i]->account_money = $data[$i]->available_cash;
+                    }
+                }
+            }
 
             for($b=0;$b<count($content);$b++){
                 $data[$i]->str = 0;
                 $data[$i]->str1 = 0;
+                $data[$i]->team = '';
                 if(!empty($content[$b]->odds_code)){
                     if(!empty(stristr($content[$b]->odds_code,'home'))){
                         $data[$i]->team = $data[$i]->home_team;
@@ -89,9 +113,23 @@ class SportsNoteList extends BaseModel {
                     if(!empty(stristr($content[$b]->odds_code,'guest'))){
                         $data[$i]->team = $data[$i]->guest_team;
                     }
-                }
 
+                    if($content[$b]->p_code == 'half_full'){
+                        $string = explode('_',$content[$b]->odds_code);
+                        if($string[2] == 'home')$string[2]=$data[$i]->home_team;
+                        if($string[2] == 'guest')$string[2]=$data[$i]->guest_team;
+                        if($string[2] == 'dogfall')$string[2]='和局';
+                        if($string[3] == 'home')$string[3]=$data[$i]->home_team;
+                        if($string[3] == 'guest')$string[3]=$data[$i]->guest_team;
+                        if($string[3] == 'dogfall')$string[3]='和局';
+                        $data[$i]->team = $string['2'].'/'.$string['3'];
+                    }
+                }
                 if($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id){
+                    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]->condition = '';
+                    }
+
 //                    if($content[$b]->result == '0'){
 //                        $data[$i]->str = 1;
 //                    }else{
@@ -117,11 +155,11 @@ class SportsNoteList extends BaseModel {
                     for($c=0;$c<count($result);$c++){
                         if($content[$b]->odds_code == $result[$c]->odds_code){
                             $data[$i]->str1 = 1;
-                            $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.' '.$content[$b]->condition.'<br>'.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
+                            $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>';
                         }
                     }
                     if($data[$i]->str1 == 0){
-                        $data[$i]->content = $data[$i]->content.$content[$b]->odds_code.' '.$content[$b]->condition.'<br>'.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
+                        $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>';
                     }
                 }
             }
@@ -150,15 +188,15 @@ 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.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->get();
+        $all_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_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.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->get();
+        $all_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_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.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status','2')->get();
+        $alraedy_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_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;
         }
@@ -170,15 +208,15 @@ 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.match_id','=','money_buy_simplex.match_id')->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.lg_id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where($where)->get();
+            $all_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_zq_competition','st_zq_competition.match_id','=','money_buy_simplex.match_id')->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.lg_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.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_id')->select('money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.gain_money')->where($where)->get();
+            $all_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_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.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_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)->get();
+            $alraedy_prize_money = $this->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')->join('st_'.$type.'_competition','st_'.$type.'_competition.match_id','=','money_buy_simplex.match_id')->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.lg_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;
             }
@@ -187,5 +225,26 @@ class SportsNoteList extends BaseModel {
         return $data;
     }
 
+     //修改赛事下的所有单式下注 3199308
+    function updatesimplex($ssid){
+        $newapp = new \App\Models\MoneyBuyMatch();
+        $data = $newapp->allsimplexorder($ssid);
+        if($data){
+            for ($i=0; $i < count($data); $i++) { 
+                $the = array(
+                    'status' => 2,
+                );
+                $res = $this->where('order_id',$data[$i]['order_id'])->update($the);
+            }
+            if($res<0){
+                return -7012000302; //操作失败
+            }
+            return $res;
+        }else{
+            return -111;
+        }
+    }
+
+
 
 }

+ 5 - 5
app/Models/SportsSoccer.php

@@ -19,9 +19,9 @@ class SportsSoccer extends BaseModel {
                 if($zqmatch[$b]->match_date < date("Y-m-d",time()) && strtotime($zqmatch[$b]->match_time.' '.$zqmatch[$b]->match_time)+7200 < time()){
                     \App\Models\SportsSoccer::where('id',$zqmatch[$b]->id)->update(['status'=>'2']);
                     \App\Models\Stzqresultrecord::where('match_id',$zqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$zqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$zqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'zq';
 //                        $db->match_id = $zqmatch[$b]->match_id;
@@ -33,9 +33,9 @@ class SportsSoccer extends BaseModel {
                 if($zqmatch[$b]->match_date == date("Y-m-d",time()) && strtotime($zqmatch[$b]->match_date.' '.$zqmatch[$b]->match_time)+7200 < time()){
                     \App\Models\SportsSoccer::where('id',$zqmatch[$b]->id)->update(['status'=>'2']);
                     \App\Models\Stzqresultrecord::where('match_id',$zqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$zqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$zqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'zq';
 //                        $db->match_id = $zqmatch[$b]->match_id;
@@ -49,7 +49,7 @@ class SportsSoccer extends BaseModel {
         
         $where[] = array('st_zq_league.name_chinese','<>','');
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
 //            $where[] = array('st_zq_local_match.source', '=', $source->infocontent);
 //            $where[] = array('st_zq_local_league.source', '=', $source->infocontent);

+ 5 - 5
app/Models/SportsTennis.php

@@ -19,9 +19,9 @@ class SportsTennis extends BaseModel {
                 if($wqmatch[$b]->match_date < date("Y-m-d",time()) && strtotime($wqmatch[$b]->match_time.' '.$wqmatch[$b]->match_time)+10800 < time()){
                     \App\Models\SportsTennis::where('match_id',$wqmatch[$b]->match_id)->update(['status'=>'2']);
                     \App\Models\Stwqresultrecord::where('match_id',$wqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$wqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$wqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'wq';
 //                        $db->match_id = $wqmatch[$b]->match_id;
@@ -33,9 +33,9 @@ class SportsTennis extends BaseModel {
                 if($wqmatch[$b]->match_date == date("Y-m-d",time()) && strtotime($wqmatch[$b]->match_date.' '.$wqmatch[$b]->match_time)+10800 < time()){
                     \App\Models\SportsTennis::where('match_id',$wqmatch[$b]->match_id)->update(['status'=>'2']);
                     \App\Models\Stwqresultrecord::where('match_id',$wqmatch[$b]->match_id)->update(['status'=>'2']);
-//                    $comendnotice = \App\Models\Comendnotice::where('match_id',$wqmatch[$b]->match_id)->first();
+//                    $comendnotice = \App\Model\Comendnotice::where('match_id',$wqmatch[$b]->match_id)->first();
 //                    if(empty($comendnotice)){
-//                        $db = new \App\Models\Comendnotice();
+//                        $db = new \App\Model\Comendnotice();
 //                        $db->status = 0;
 //                        $db->game_code = 'wq';
 //                        $db->match_id = $wqmatch[$b]->match_id;
@@ -49,7 +49,7 @@ class SportsTennis extends BaseModel {
         
         $where[] = array('st_wq_league.name_chinese','<>','');
 
-//        $source = \App\Models\Setinfo::where('id','1000')->first();
+//        $source = \App\Model\Setinfo::where('id','1000')->first();
 //        if($source->infocontent != '混合数据'){
 //            $where[] = array('st_wq_local_match.source', '=', $source->infocontent);
 //            $where[] = array('st_wq_local_league.source', '=', $source->infocontent);

+ 1 - 13
app/Models/Stzqresult.php

@@ -12,19 +12,7 @@ class Stzqresult extends BaseModel
         if (is_array ($where) && count ($where) > 0) {
             $data = $this->join('st_zq_league','st_zq_result.lg_id','=','st_zq_league.lg_id')->join('st_zq_competition','st_zq_competition.match_id','=','st_zq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_zq_result.guest_team','st_zq_result.home_rate','st_zq_result.guest_rate','st_zq_result.first_score','st_zq_result.status','st_zq_result.last_score','st_zq_result.match_score','st_zq_result.match_winer','st_zq_result.update_time','st_zq_competition.match_time','st_zq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score','st_zq_league.name_chinese as saisname')->orderby('st_zq_result.id','desc')->where($where)->orwhere($orwhere)->paginate ($list);
         } else { 
-            $this->join('st_zq_league','st_zq_result.lg_id','=','st_zq_league.lg_id')->join('st_zq_competition','st_zq_competition.match_id','=','st_zq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_zq_result.guest_team','st_zq_result.home_rate','st_zq_result.guest_rate','st_zq_result.first_score','st_zq_result.status','st_zq_result.last_score','st_zq_result.match_score','st_zq_result.match_winer','st_zq_result.update_time','st_zq_competition.match_time','st_zq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score','st_zq_league.name_chinese as saisname')->orderby('st_zq_result.id','desc')->paginate ($list);
-        }
-
-        for($i=0;$i<count($data);$i++){
-            if($data[$i]->status==0){
-                $data[$i]->status = '未开始';
-            }else if($data[$i]->status==1){
-                $data[$i]->status = '进行中';
-            }else if($data[$i]->status==2){
-                $data[$i]->status = '已结束';
-            }
-            $data[$i]->home_guest = $data[$i]->home_rate.' <br> '.$data[$i]->guest_rate;
-            $data[$i]->shome_guest = $data[$i]->home_score.' <br> '.$data[$i]->guest_score;
+            $data = $this->join('st_zq_league','st_zq_result.lg_id','=','st_zq_league.lg_id')->join('st_zq_competition','st_zq_competition.match_id','=','st_zq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_zq_result.guest_team','st_zq_result.home_rate','st_zq_result.guest_rate','st_zq_result.first_score','st_zq_result.status','st_zq_result.last_score','st_zq_result.match_score','st_zq_result.match_winer','st_zq_result.update_time','st_zq_competition.match_time','st_zq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score','st_zq_league.name_chinese as saisname')->orderby('st_zq_result.id','desc')->paginate ($list);
         }
 
         return $data->toArray ();

+ 1 - 1
app/Models/System_user.php

@@ -209,7 +209,7 @@ class System_user extends BaseModel {
     }
     //检测token
     function checkToken($admin_id,$token){
-//        if(\App\Models\Role::hasRoot('passToken')){
+//        if(\App\Model\Role::hasRoot('passToken')){
 //            return 1;
 //        }
         $res=$this->where('id',$admin_id)->where('token',$token)->first();

+ 19 - 0
app/Models/ZqLeagueResult.php

@@ -0,0 +1,19 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: scstf
+ * Date: 2018/9/28
+ * Time: 20:05
+ */
+
+namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\Model;
+
+class ZqLeagueResult extends Model
+{
+    protected $table='st_zq_league_result';
+
+
+}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
public/admin/frame/echarts/echarts.min.js


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
public/frame/echarts/echarts.min.js


+ 1 - 0
public/function.php

@@ -307,3 +307,4 @@ function  floatPointDigit($data,$long=2){
     return  sprintf($for1,substr(sprintf($for2, $data), 0, -1));
 }
 
+

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
resources/assets/vip/frame/echarts/echarts.min.js


+ 2 - 0
resources/lang/zh-cn/sportsbk.php

@@ -33,6 +33,8 @@ return array(
 	'name_chinese' => '联赛',
 	'status' => '比赛状态',
 	'select_status' => '请选择比赛状态',
+	'dsnum' => '单式注单数',
+	'csnum' => '串式注单数',
 	
 	
 );

+ 1 - 1
resources/lang/zh-cn/sportsfoot.php

@@ -58,7 +58,7 @@ return array(
     'guest_team' => '客队',
     'lg_id' => '联赛ID',
     'sg_id' => '子联赛ID',
-    'status'=>'比赛状态',
+    'operation'=>'操作',
 	'select_status'=>'请选择比赛状态',
     'recommend' => '推荐默认',
     'match_id' => '赛事id',

+ 1 - 0
resources/lang/zh-cn/sportsnotelist.php

@@ -31,6 +31,7 @@ return array(
     'member_type' => '会员类型',
     'edit' => '修改',
     'ifsettlement' => '结算状态',
+    'order_status' => '注单状态',
 
     'str_type' => '模式',
     'detail_content' => '结算详细信息',

+ 7 - 0
resources/lang/zh-cn/status.php

@@ -362,6 +362,13 @@ return array(
 			'2' => '已结算',
 		),
 	),
+	'order_status' => array(
+		'status' => array(
+			'1' => '投注',
+			'2' => '作废',
+			'3' => '撤销',
+		),
+	),
 	'notelist_type' => array(
 		'type' => array(
 			'zq' => '足球',

+ 104 - 15
resources/views/admin/sportsfoot/outcome.blade.php

@@ -41,13 +41,28 @@
         <span><a href="/admin/SoccerNoteList/notelist?match_id=@{{d.match_id}}"> 单式</a></span>
     </script>
 
+    <script type="text/html" id="status">
+        @{{#if(d.status==1 || d.status==2){ }}
+            <span><li class="layui-btn layui-btn-sm lay-btn-diy" onclick="settlement(@{{d.match_id}},1)">结算</li></span>
+        @{{#} }}
+        @{{#if(d.status==3){ }}
+            <span><li class="layui-btn   layui-btn-sm layui-btn-normal reset" onclick="settlement(@{{d.match_id}},2)">再结算</li></span>
+        @{{#} }}
+        @{{#if(d.status!=4 && d.status!=3){ }}
+        <span><li class="layui-btn layui-btn-sm  layui-btn-danger" onclick="revoke(@{{d.match_id}})">作废</li></span>
+        @{{#} }}
+        @{{#if(d.status==4){ }}
+        <span><li class="layui-btn layui-btn-sm  layui-btn-danger" onclick="revoke(@{{d.match_id}})">已作废</li></span>
+        @{{#} }}
+    </script>
+
     <script type="text/html" id="sxalfcourt">
       @{{#if(d.match_time!=null){ }}
         <!-- <span>@{{ d.match_time}}</span> -->
         <input type="text" style="width:30px;heigth:20px" id="u_home_score" name="u_home_score" value="@{{d.u_home_score}}" onchange="inputFunc(@{{d.id}}, event.target.value)"> 
         <input type="text" style="width:30px;heigth:20px" id="u_guest_score" name="u_guest_score" value="@{{d.u_guest_score}}" onchange="inputTunc(@{{d.id}}, event.target.value)"> / 
         <input type="text" style="width:30px;heigth:20px" id="home_score" name="home_score" value="@{{d.home_score}}" onchange="inputSunc(@{{d.id}}, event.target.value)">
-        <input type="text" style="width:30px;heigth:20px" id="guest_score" name="guest_score" value="@{{d.guest_score}}" onchange="inputAunc(@{{d.id}}, event.target.value)">
+        <input type="text" style="width:30px;heigth:20px" id="guest_score" name="guest_score" value="@{{d.guest_score}}" onchange="inputAunc(@{{d.id}}, event.target.value,@{{d.match_id}})">
 
       @{{#} }}
     </script>
@@ -138,7 +153,7 @@
                     <div class="layui-inline">
                         <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
                         <a  class="layui-btn   layui-btn-sm layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
-                        <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
+                        <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon" onclick="refreshall('zq')">ဂ</i></a>
                         @if(checkRriv('/admin/sportsfoot/addoutcome'))<a href="/admin/sportsfoot/addoutcome" class="layui-btn layui-btn-sm ">添加</a>@endif
                         @if(checkRriv('/admin/sportsfoot/deleteoutcome'))<a href="javascript:delWin('/admin/sportsfoot/deleteoutcome?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a>@endif
                     </div>
@@ -146,6 +161,7 @@
             </form>
         </div>
     </div>
+
     <script type="text/javascript">
         $(function () {
             $('body').on('click', 'a[eventtype="event-delete"]', function () {
@@ -163,6 +179,42 @@
             })
         })
 
+        //刷新赛事数据
+        function refreshall(game_code){
+            var game_code = game_code;
+            $.ajax({
+                type: 'POST',
+                dataType: 'json',
+                url: '/setSports',
+                data: {game_code:game_code},
+                success: function(data) {
+                    alert(data);
+                    if(data.status==1){
+                        layer.msg('刷新成功');
+                        reloadDataTable();
+                        location. reload()//刷新当前页面
+                    }
+                }
+            })
+        }
+
+        //撤销
+        function revoke(match_id){
+            var match_id = match_id;
+            $.ajax({
+                type: 'POST',
+                dataType: 'json',
+                url: '/admin/Sportsfoot/revoke',
+                data: {match_id:match_id},
+                success: function(data) {
+                    if(data.status==1){
+                        layer.msg(data.msg);
+                        location. reload()//刷新当前页面
+                    }
+                }
+            })
+        }
+
         //上半场主队
         function inputFunc(id,num){
             var id = id;
@@ -170,9 +222,11 @@
             var reg = /^[0-99]\d*$/;
             var home_score = $("#home_score").val();
             if(reg.test(num)==false){ 
-                return;
+                layer.msg('不能为空值');
+                reloadDataTable();return;
             }else if(home_score<num){
-                return;
+                layer.msg('请输入正确的全场比分');
+                reloadDataTable();return;
             }
 
             $.ajax({
@@ -181,7 +235,10 @@
                 url: '/admin/Sportsfoot/updatenum',
                 data: {id:id,num:num,type:1},
                 success: function(data) {
-                    location. reload()//刷新当前页面
+                    if(data.status==1){
+                        layer.msg(data.msg);
+                        location. reload()//刷新当前页面
+                    }
                 }
             })
         }
@@ -192,9 +249,11 @@
             var reg = /^[0-99]\d*$/;
             var guest_score = $("#guest_score").val();
             if(reg.test(num)==false){ 
-                return;
+                layer.msg('不能为空值');
+                reloadDataTable();return;
             }else if(guest_score<num){
-                return;
+                layer.msg('请输入正确的全场比分');
+                reloadDataTable();return;
             }
             $.ajax({
                 type: 'POST',
@@ -202,7 +261,10 @@
                 url: '/admin/Sportsfoot/updatenum',
                 data: {id:id,num:num,type:2},
                 success: function(data) {
-                    location. reload()//刷新当前页面
+                    if(data.status==1){
+                        layer.msg(data.msg);
+                        location. reload()//刷新当前页面
+                    }
                 }
             })
         }
@@ -212,7 +274,8 @@
             var num = num;
             var u_home_score = $("#u_home_score").val();
             if(u_home_score>num){ 
-                return;
+                layer.msg('请输入正确的全场比分');
+                reloadDataTable();return;
             }
             $.ajax({
                 type: 'POST',
@@ -220,29 +283,55 @@
                 url: '/admin/Sportsfoot/updatenum',
                 data: {id:id,num:num,type:3},
                 success: function(data) {
-                    location. reload()//刷新当前页面
+                    if(data.status==1){
+                        layer.msg(data.msg);
+                        location. reload()//刷新当前页面
+                    }
                 }
             })
         }
         //全场客队
-        function inputAunc(id,num){
+        function inputAunc(id,num,match_id){
             var id = id;
             var num = num;
             var u_guest_score = $("#u_guest_score").val();
             if(u_guest_score>num){ 
-                return;
+                layer.msg('请输入正确的全场比分');
+                reloadDataTable();return;
             }
             $.ajax({
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/Sportsfoot/updatenum',
-                data: {id:id,num:num,type:4},
+                data: {id:id,num:num,type:4,match_id:match_id},
+                success: function(data) {
+                    if(data.status==1){
+                        layer.msg(data.msg);
+                        location. reload()//刷新当前页面
+                    }
+                }
+            })
+        }
+
+        //结算 
+        function settlement(match_id,type){
+            var match_id = match_id;
+            var type = type;
+            $.ajax({
+                type: 'POST',
+                dataType: 'json',
+                url: '/admin/Sportsfoot/Settlement',
+                data: {match_id:match_id,type:type},
                 success: function(data) {
-                    location. reload()//刷新当前页面
+                    // alert(data);
+                    if(data.status==1){
+                        layer.msg(data.msg);
+                        location. reload()//刷新当前页面
+                    }
                 }
             })
         }
-        
+
 	</script>
 @push('dataTableJS')
 /*var active = {

+ 46 - 7
resources/views/sports/sports_notelist.blade.php

@@ -62,6 +62,9 @@
         .settlement{
             background-color: #FF5722;
         }
+        .invalid{
+            background-color: #FF5722;
+        }
     </style>
 
     <script type="text/html" id="status">
@@ -75,7 +78,7 @@
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.notelist_type') }}</label>
-                        <div class="layui-input-inline" style="width: 70px">
+                        <div class="layui-input-inline" style="">
                             <select name="type"  id="form_type"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                 <option value="-1"></option>
                                 @foreach(trans('status.notelist_type.type') as $k=>$v):
@@ -91,7 +94,7 @@
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.account') }}</label>
-                        <div class="layui-input-inline" style="width: 80px">
+                        <div class="layui-input-inline" style="">
                             <input type="text" name="account" id="account" eventType="event-query"  value="{{ $account }}" lay-verify="required" autocomplete="off" class="layui-input">
                         </div>
                         <div class="layui-input-inline checkbox">
@@ -102,34 +105,34 @@
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.date') }}</label>
-                        <div class="layui-input-inline" style="width: 90px">
+                        <div class="layui-input-inline" style="">
                             <input type="text" name="star_time" value="{{ $star_time }}" id="form_star_time" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item" eventType=event-query>
                         </div>
                     </div>~
                     <div class="layui-inline">
                         {{--<label class="layui-form-label">{{ trans('sportsnotelist.end_time') }}</label>--}}
-                        <div class="layui-input-inline" style="width: 90px">
+                        <div class="layui-input-inline" style="">
                             <input type="text" name="end_time" value="{{ $end_time }}" id="end_time" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item" eventType=event-query>
                         </div>
                     </div>
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.order_id') }}</label>
-                        <div class="layui-input-inline" style="width: 80px">
+                        <div class="layui-input-inline" style="">
                             <input type="text" name="order_id" id="order_id" eventType="event-query"  value="{{ $order_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                         </div>
                     </div>
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.match_id') }}</label>
-                        <div class="layui-input-inline" style="width: 60px">
+                        <div class="layui-input-inline" style="">
                             <input type="text" name="match_id" id="match_id" eventType="event-query"  value="{{ $match_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                         </div>
                     </div>
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.ifsettlement') }}</label>
-                        <div class="layui-input-inline" style="width: 90px">
+                        <div class="layui-input-inline" style="">
                             <select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                 <option value="-1"></option>
                                 @foreach(trans('status.ifsettlement.status') as $k=>$v):
@@ -143,6 +146,22 @@
                         </div>
                     </div>
 
+                    <div class="layui-inline">
+                        <label class="layui-form-label">{{ trans('sportsnotelist.order_status') }}</label>
+                        <div class="layui-input-inline" style="">
+                            <select name="order_status"  id="form_order_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
+                                <option value="-1"></option>
+                                @foreach(trans('status.order_status.status') as $k=>$v):
+                                @if($order_status==$k))
+                                <option value="{{$k}}" selected="selected">{{$v}}</option>
+                                @else
+                                    <option value="{{$k}}">{{$v}}</option>
+                                @endif
+                                @endforeach
+                            </select>
+                        </div>
+                    </div>
+
                     <div class="layui-inline">
                         <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
                         <a  class="layui-btn   layui-btn-sm layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
@@ -313,6 +332,26 @@
             });
 
         }
+
+        //单式注单作废
+        function invalid(url,ids) {
+            layer.confirm('是否确认作废?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    //console.log(data);
+                    if (data == '1') {
+                        reloadDataTable();
+                        layer.msg('作废成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
     </script>
 
     @include('vip.datatable')

+ 38 - 0
resources/views/sports/sports_stringnotelist.blade.php

@@ -63,6 +63,9 @@
         .settlement{
             background-color: #FF5722;
         }
+        .invalid{
+            background-color: #FF5722;
+        }
     </style>
 
     <script type="text/html" id="status">
@@ -120,6 +123,21 @@
                             </select>
                         </div>
                     </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">{{ trans('sportsnotelist.order_status') }}</label>
+                        <div class="layui-input-inline" style="width: 100px">
+                            <select name="order_status"  id="form_order_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
+                                <option value="-1"></option>
+                                @foreach(trans('status.order_status.status') as $k=>$v):
+                                @if($order_status==$k))
+                                <option value="{{$k}}" selected="selected">{{$v}}</option>
+                                @else
+                                    <option value="{{$k}}">{{$v}}</option>
+                                @endif
+                                @endforeach
+                            </select>
+                        </div>
+                    </div>
 
                     <div class="layui-inline">
                         <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
@@ -290,6 +308,26 @@
             });
 
         }
+
+        //串关注单作废
+        function invalid(url,ids) {
+            layer.confirm('是否确认作废?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    //console.log(data);
+                    if (data == '1') {
+                        reloadDataTable();
+                        layer.msg('作废成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
     </script>
 
     @include('vip.datatable')

+ 1 - 0
routes/api.php

@@ -42,6 +42,7 @@ $routes=array(
     'hjgame'=>exeApi('api', 'HjGame','getPipelineRecord'),
     'ogsports'=>exeApi('api', 'Oggame_sport','getPipelineRecord'),
     'fygame'=>exeApi('api', 'fyGame','getBetting'),
+    'setSports'=>exeApi('api', 'WriteSports','setSports'),
 );
 
 

+ 4 - 0
routes/web.php

@@ -24,6 +24,10 @@ Route::get('/', function () {
  Route::get('api/Settlement/index', function () {
      return appExec('api', 'Settlement', 'index');
  });
+//写入赛事数据接口
+Route::post('/setSports', function () {
+    return appExec('api', 'WriteSports', 'setSports');
+});
 
 
 /**

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio