浏览代码

追加推送 6/4

彭俊 6 年之前
父节点
当前提交
3b672ef5c7

+ 53 - 1
README.md

@@ -1,2 +1,54 @@
-# sports_admin
+<p align="center"><img src="https://laravel.com/assets/img/components/logo-laravel.svg"></p>
 
+<p align="center">
+<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
+</p>
+
+## About Laravel
+
+Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as:
+
+- [Simple, fast routing engine](https://laravel.com/docs/routing).
+- [Powerful dependency injection container](https://laravel.com/docs/container).
+- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
+- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
+- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
+- [Robust background job processing](https://laravel.com/docs/queues).
+- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
+
+Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation give you tools you need to build any application with which you are tasked.
+
+## Learning Laravel
+
+Laravel has the most extensive and thorough documentation and video tutorial library of any modern web application framework. The [Laravel documentation](https://laravel.com/docs) is thorough, complete, and makes it a breeze to get started learning the framework.
+
+If you're not in the mood to read, [Laracasts](https://laracasts.com) contains over 900 video tutorials on a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.
+
+## Laravel Sponsors
+
+We would like to extend our thanks to the following sponsors for helping fund on-going Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](http://patreon.com/taylorotwell):
+
+- **[Vehikl](http://vehikl.com)**
+- **[Tighten Co.](https://tighten.co)**
+- **[British Software Development](https://www.britishsoftware.co)**
+- **[Styde](https://styde.net)**
+- [Fragrantica](https://www.fragrantica.com)
+- [SOFTonSOFA](https://softonsofa.com/)
+- [User10](https://user10.com)
+- [Soumettre.fr](https://soumettre.fr/)
+- [CodeBrisk](https://codebrisk.com)
+
+## Contributing
+
+Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
+
+## Security Vulnerabilities
+
+If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
+
+## License
+
+The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

+ 24 - 5
app/Http/Controllers/Admin/SportsBaseController.php

@@ -35,11 +35,11 @@ class SportsBaseController extends Controller {
         $dt->setDataSource('/admin/SportsBase/info');
         $dt->setLang('sportsbase');
         $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
-        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
-        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
-        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 220));
-        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
-        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
+        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
         $dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
         $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
         //$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
@@ -182,7 +182,12 @@ class SportsBaseController extends Controller {
             $model->tag = mt_rand(0,100) ;
             $model->source = 'user-defined';
 
+            $db = new \App\Models\Stbqlocalmatch();
+            $db->source = 'user-defined';
+            $db->match_id = $model->match_id;
+
             $model->save();
+            $db->save();
             return responseToJson(1);
 
         }
@@ -265,11 +270,19 @@ class SportsBaseController extends Controller {
         if (!is_array($ids) && intval($ids) < 0) {
             return responseToJson(-2002); //id����
         }
+        $id = array();
+        $localmatch = \App\Models\Stbqlocalmatch::get();
         if (is_array($ids) && count($ids) > 0) {
             foreach ($ids as $k => $v) {
                 if (intval($v) < 1) {
                     unset($ids[$k]);
                 }
+                $match = \App\Models\SportsBase::where('id',$v)->first();
+                for($i=0;$i<count($localmatch);$i++){
+                    if($localmatch[$i]->match_id == $match->match_id){
+                        $id[] = $localmatch[$i]->id;
+                    }
+                }
             }
         }
 
@@ -277,6 +290,12 @@ class SportsBaseController extends Controller {
         if (!$rows) {
             return responseToJson(-2003); //id����
         }
+        if(count($id)>0){
+            $row = \App\Models\Stbqlocalmatch::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
         return responseToJson(1, trans('menu.delete_success')); //id����
 
     }

+ 24 - 5
app/Http/Controllers/Admin/SportsBasketController.php

@@ -35,11 +35,11 @@ class SportsBasketController extends Controller {
 		$dt->setDataSource('/admin/SportsBasket/info');
 		$dt->setLang('sportsbase');
 		$dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
-		$dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
-		$dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
-		$dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 220));
-		$dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
-		$dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
+		$dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+		$dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+		$dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+		$dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+		$dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
 		$dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
 		$dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
 		//$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
@@ -184,7 +184,12 @@ class SportsBasketController extends Controller {
 			$model->tag = mt_rand(0,100) ;
 			$model->source = 'user-defined';
 
+			$db = new \App\Models\Stlqlocalmatch();
+			$db->source = 'user-defined';
+			$db->match_id = $model->match_id;
+
 			$model->save();
+			$db->save();
 			return responseToJson(1);
 
 		}
@@ -267,11 +272,19 @@ class SportsBasketController extends Controller {
 		if (!is_array($ids) && intval($ids) < 0) {
 			return responseToJson(-2002); //id����
 		}
+		$id = array();
+		$localmatch = \App\Models\Stlqlocalmatch::get();
 		if (is_array($ids) && count($ids) > 0) {
 			foreach ($ids as $k => $v) {
 				if (intval($v) < 1) {
 					unset($ids[$k]);
 				}
+				$match = \App\Models\SportsBasket::where('id',$v)->first();
+				for($i=0;$i<count($localmatch);$i++){
+					if($localmatch[$i]->match_id == $match->match_id){
+						$id[] = $localmatch[$i]->id;
+					}
+				}
 			}
 		}
 
@@ -279,6 +292,12 @@ class SportsBasketController extends Controller {
 		if (!$rows) {
 			return responseToJson(-2003); //id����
 		}
+		if(count($id)>0) {
+			$row = \App\Models\Stlqlocalmatch::whereIn('id', $id)->delete();
+			if (!$row) {
+				return responseToJson(-2003); //id????
+			}
+		}
 		return responseToJson(1, trans('menu.delete_success')); //id����
 
 	}

+ 25 - 7
app/Http/Controllers/Admin/SportsSoccerController.php

@@ -36,11 +36,11 @@ class SportsSoccerController extends Controller {
         $dt->setDataSource('/admin/SportsSoccer/info');
         $dt->setLang('sportsbase');
         $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
-        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
-        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
-        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 220));
-        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
-        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
+        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
         $dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
         $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
         //$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
@@ -176,13 +176,17 @@ class SportsSoccerController extends Controller {
             $model->match_time = $req->input('match_time');
             $model->status = $req->input('status');
             $model->match_id = time() ;
-            $model->m_match_id = $model->match_id ;
             $model->ctime = date('Y-m-d H:i:s',time());
             $model->utime = date('Y-m-d H:i:s',time());
             $model->tag = mt_rand(0,100) ;
             $model->source = 'user-defined';
 
+            $db = new \App\Models\Stzqlocalmatch();
+            $db->source = 'user-defined';
+            $db->match_id = $model->match_id;
+
             $model->save();
+            $db->save();
             return responseToJson(1);
 
         }
@@ -232,7 +236,7 @@ class SportsSoccerController extends Controller {
             return view('sports.soccer_form', $data);
         } else {
             $model = new \App\Models\SportsSoccer();
-            $model->id = $req->input('id');
+            $model->id = $req->input('lg_id');
             $model = $model::find($model->id);
             $model->home_team = $req->input('home_team');
             $model->guest_team = $req->input('guest_team');
@@ -265,11 +269,19 @@ class SportsSoccerController extends Controller {
         if (!is_array($ids) && intval($ids) < 0) {
             return responseToJson(-2002); //id����
         }
+        $id = array();
+        $localmatch = \App\Models\Stzqlocalmatch::get();
         if (is_array($ids) && count($ids) > 0) {
             foreach ($ids as $k => $v) {
                 if (intval($v) < 1) {
                     unset($ids[$k]);
                 }
+                $match = \App\Models\SportsSoccer::where('id',$v)->first();
+                for($i=0;$i<count($localmatch);$i++){
+                    if($localmatch[$i]->match_id == $match->match_id){
+                        $id[] = $localmatch[$i]->id;
+                    }
+                }
             }
         }
 
@@ -277,6 +289,12 @@ class SportsSoccerController extends Controller {
         if (!$rows) {
             return responseToJson(-2003); //id����
         }
+        if(count($id)>0) {
+            $row = \App\Models\Stzqlocalmatch::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
         return responseToJson(1, trans('menu.delete_success')); //id����
 
     }

+ 24 - 5
app/Http/Controllers/Admin/SportsTennisController.php

@@ -35,11 +35,11 @@ class SportsTennisController extends Controller {
         $dt->setDataSource('/admin/SportsTennis/info');
         $dt->setLang('sportstennis');
         $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
-        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
-        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
-        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 220));
-        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
-        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 130));
+        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
         $dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
         $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
         //$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
@@ -183,7 +183,12 @@ class SportsTennisController extends Controller {
             $model->tag = mt_rand(0,100) ;
             $model->source = 'user-defined';
 
+            $db = new \App\Models\Stwqlocalmatch();
+            $db->source = 'user-defined';
+            $db->match_id = $model->match_id;
+
             $model->save();
+            $db->save();
             return responseToJson(1);
 
         }
@@ -266,11 +271,19 @@ class SportsTennisController extends Controller {
         if (!is_array($ids) && intval($ids) < 0) {
             return responseToJson(-2002); //id����
         }
+        $id = array();
+        $localmatch = \App\Models\Stwqlocalmatch::get();
         if (is_array($ids) && count($ids) > 0) {
             foreach ($ids as $k => $v) {
                 if (intval($v) < 1) {
                     unset($ids[$k]);
                 }
+                $match = \App\Models\SportsTennis::where('id',$v)->first();
+                for($i=0;$i<count($localmatch);$i++){
+                    if($localmatch[$i]->match_id == $match->match_id){
+                        $id[] = $localmatch[$i]->id;
+                    }
+                }
             }
         }
 
@@ -278,6 +291,12 @@ class SportsTennisController extends Controller {
         if (!$rows) {
             return responseToJson(-2003); //id����
         }
+        if(count($id)>0) {
+            $row = \App\Models\Stwqlocalmatch::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
         return responseToJson(1, trans('menu.delete_success')); //id����
 
     }

+ 15 - 22
app/Http/Controllers/Admin/SportsfootController.php

@@ -80,7 +80,7 @@ class SportsfootController extends Controller {
 		$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++) { 
@@ -91,7 +91,7 @@ class SportsfootController extends Controller {
         //串式撤单只改状态
         $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
         $csapp = new \App\Models\MoneyBuyStr();
-        $ss = $csapp->updatestatus($str_ids);//var_dump($ss);die;
+        $csapp->updatestatus($str_ids);//var_dump($ss);die;
         //修改money_buy_match 投注结果result=2为平
         $newapp->updatast($match_id);
         
@@ -250,38 +250,26 @@ class SportsfootController extends Controller {
 		if($type==1){
 			$data['u_home_score'] = $num;
 			$res = $newapp->updateInfo($data,$id);//联赛id
+             $this->addcomendnotice($match_id);
 		}else if($type==2){
 			$data['u_guest_score'] = $num;
 			$res = $newapp->updateInfo($data,$id);//联赛id
+			$this->addcomendnotice($match_id);
 		}else if($type==3){
 			$data['home_score'] = $num;
 			$res = $newapp->updateInfo($data,$id);//联赛id
+			$this->addcomendnotice($match_id);
 		}else{
 			$data['guest_score'] = $num;
 			$res = $newapp->updateInfo($data,$id);//联赛id
-			$this->addcomendnotice($match_id);
-			// $data = \App\Models\Comendnotice::where('match_id', $match_id)->first();
-			// if(!$data){
-			// 	$model = new \App\Models\Comendnotice();
-			// 	$model->status = 0;//联赛id
-			// 	$model->game_code = 'zq';
-			// 	$model->match_id = $match_id;//赛事id
-			// 	$model->ctime = date('Y-m-d H:i:s');
-			// 	$model->save();
-
-			// 	$newapp = new \App\Lib\Settlement\SettlementWinFail();
-			// 	return $newapp->doRun($model->id);
-			// }else{
-			// 	$newapp = new \App\Lib\Settlement\SettlementWinFail();
-			// 	return $newapp->doRun($data->toArray()['id']);
-			// }
+            $this->addcomendnotice($match_id);
 		}
 		return responseToJson($res);
 	}
 
 	//添加赛事结束纪录
 	function addcomendnotice($match_id){
-		$data = \App\Models\Comendnotice::where('match_id', $match_id)->first();
+		$data = \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->first();
 		if(!$data){
 			$model = new \App\Models\Comendnotice();
 			$model->status = 0;//联赛id
@@ -291,12 +279,17 @@ class SportsfootController extends Controller {
 			$model->save();
 
 			$newapp = new \App\Lib\Settlement\SettlementWinFail();
-			$newapp->doRun($model->id);
+			$ret = $newapp->doRun($model->id);
 		}else{
 			$newapp = new \App\Lib\Settlement\SettlementWinFail();
-			$newapp->doRun($data->toArray()['id']);
+            \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->update(['status'=>0]);
+			$ret = $newapp->doRun($data->toArray()['id']);
+			$ret2 =$data->toArray()['id'];
+            if ($ret2['status']==1){
+                \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->update(['status'=>4]);
+            }
 		}
-
+		return $ret;
 	}
 	
 	

+ 102 - 47
app/Http/Controllers/Api/WriteSportsController.php

@@ -12,6 +12,10 @@ 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;
+use App\Http\Model\StBroadcast as broadcastModel;
+use App\Http\Model\StGameType as gameModel;
+
+
 
 class WriteSportsController extends BaseController{
 
@@ -19,21 +23,17 @@ class WriteSportsController extends BaseController{
      * 体育数据入库接口
      */
     public function setSports(Req $data){
-
         try {
             //开启事务
             DB::beginTransaction();
-            //当只有球类代码,则写滚球结果
             if($data->game_code){
-                //将所有进行中的赛事写入结果
+                //用于后台 将所有进行中的赛事写入结果
                 $this->match_result($data->game_code);
             }
             //写赛事数据
             $obt = $data->data;
             if($obt){
                 $getData = $this->getAddData($obt);
-//                            return Response::success($getData);
-
                 $league = [];
                 $competition = [];
                 $odds = [];
@@ -41,6 +41,7 @@ class WriteSportsController extends BaseController{
                 $match_result = [];
                 $match_result_record = [];
                 $odds_record = [];
+                $broadcast = [];
                 //指定排序
                 foreach ($getData as $k=>$v){
                     if($v['title'] == 'league') $league[] = $v;
@@ -50,18 +51,17 @@ class WriteSportsController extends BaseController{
                     if($v['title'] == 'match_result') $match_result[] = $v;
                     if($v['title'] == 'match_result_record') $match_result_record[] = $v;
                     if($v['title'] == 'odds_record') $odds_record[] = $v;
+                    if($v['title'] == 'broadcast') $broadcast[] = $v;
+
                 }
-                $matchData = [$league,$competition,$odds,$league_result,$match_result,$match_result_record,$odds_record];
+                $matchData = [$league,$competition,$odds,$league_result,$match_result,$match_result_record,$odds_record,$broadcast];
                 //排空处理
                 foreach ($matchData as $k=>$v){
                     if($v == []) unset($matchData[$k]);
                 }
-//                $dd = [];
                 //根据顺序写入数据
-//                return Response::success($matchData);
                 foreach ($matchData as $k=>$v){
                     foreach ($v as $kk =>$vv){
-
                         switch ($vv['title']){
                             case 'area'://地区
                                 throw new \Exception(Response::generate(Response::AUTH_ERROR)) ;
@@ -70,8 +70,7 @@ class WriteSportsController extends BaseController{
                                 throw new \Exception(Response::generate(Response::AUTH_ERROR));
                                 break;
                             case 'league'://联赛
-                                $ret = $this->league($vv);
-//                                $dd[] = $ret;
+                                $this->league($vv);
                                 break;
                             case 'competition'://赛事
                                 $this->competition($vv);
@@ -83,17 +82,21 @@ class WriteSportsController extends BaseController{
                                 $this->league_result($vv);
                                 break;
                             case 'match_result'://赛事结果
-                                throw new \Exception(Response::generate(Response::AUTH_ERROR));
+                                throw new \Exception(Response::generate('',Response::AUTH_ERROR));
                                 $this->match_result($vv);
                                 break;
                             case 'match_result_record'://赛事结果记录
                                 $this->com_result_record($vv);
                                 break;
                             case 'odds_record'://赔率记录
+                                throw new \Exception(Response::generate('',Response::AUTH_ERROR));
                                 $this->odds_record($vv);
                                 break;
+                            case 'broadcast'://直播数据
+                                $this->broadcast($vv);
+                                break;
                             default:
-                                throw new \Exception(Response::generate(Response::ABNORMAL)) ;
+                                throw new \Exception(Response::generate('',Response::ABNORMAL)) ;
                         }
                     }
                 }
@@ -115,6 +118,25 @@ class WriteSportsController extends BaseController{
         return $res;
     }
 
+    //写入直播 数据
+    public function broadcast($opt = []){
+        $data = $opt['data'];
+        $set_broadcast = [
+            "doing" => $data['doing'],
+		    "game_type" => $data['game_type'],
+		    "guest_team" => $data['guest_team'],
+		    "host_team" => $data['host_team'],
+		    "league_name" => $data['league_name'],
+		    "shower" => $data['shower'],
+		    "showid" => (int)$data['showid'],
+            "start_time" => $data['start_time'],
+            "ctime" =>date('Y-m-d H:m:i'),
+            "utime" =>date('Y-m-d H:m:i'),
+        ];
+        $ret = broadcastModel::insert($set_broadcast);
+        if($ret == false) throw new \Exception(Response::generate('',Response::BROADCAST_ERROR));
+    }
+
     //将进行中赛事写入 赛事结果
     public function match_result($game_code = ''){
         $model =commonFunction::getModels($game_code,1);
@@ -150,7 +172,7 @@ class WriteSportsController extends BaseController{
                     ];
             }
             $ret = $model['model_result']::insert($set_match_r);
-            if($ret != true) return Response::generate(Response::ADD_MATCH_R_ERROR);
+            if($ret != true) throw new \Exception( Response::generate('',Response::ADD_MATCH_R_ERROR));
         }
 
         //如果结果表有数据,则获取结果表没有的赛事
@@ -179,7 +201,7 @@ class WriteSportsController extends BaseController{
                 ];
             }
             $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'));
+            if($ret != true) throw new \Exception( Response::generate('',Response::ADD_MATCH_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
         }
     }
     //写入地区数据 弃用
@@ -229,7 +251,7 @@ class WriteSportsController extends BaseController{
                 $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));
+                if($m_lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::INSERT_ERROR));
             }
             $set_local = [
                 'lg_id'=>$id,
@@ -237,10 +259,8 @@ class WriteSportsController extends BaseController{
                 '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'));
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LOCAL_LEAGUE_ERROR)) ;//Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
         }
-        return 1;
-//        return Response::success();
     }
 
     //写入赛事数据
@@ -249,12 +269,12 @@ class WriteSportsController extends BaseController{
         //根据球类代码获取相关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'));
+        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'));
+        if(empty($lg_id)) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',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');
@@ -268,7 +288,7 @@ class WriteSportsController extends BaseController{
             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($half_match_id)) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
             }
             //写入赛事
             if(empty($id)){
@@ -278,7 +298,7 @@ class WriteSportsController extends BaseController{
                     $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'));
+                    if(empty($last_time)) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',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);
@@ -305,7 +325,7 @@ class WriteSportsController extends BaseController{
                 ];
                 //写入赛事 返回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'));
+                if($id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::INSERT_ERROR)) ;//Render([], '10012', lang('Tips','Sports')->get('insert_error'));
             }
             $set_local = [
                 'match_id'=>$id,
@@ -313,7 +333,7 @@ class WriteSportsController extends BaseController{
                 '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'));
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::LOCAL_MATCH_ERROR)) ;//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
         }
 //        return Response::success();
     }
@@ -328,7 +348,8 @@ class WriteSportsController extends BaseController{
         $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'));
+
+        if(count($match) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR)) ;//Render([], '10016', lang('Tips','Sports')->get('match_error'));
 
         //获取赛事 本地/源ID
         $others_match_id = $match->others_match_id;
@@ -337,13 +358,47 @@ class WriteSportsController extends BaseController{
         $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'));
+        if(count($lg) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR));
 
         //获取联赛 本地/源ID
         $others_lg_id = $lg->others_lg_id;
         $lg_id = $lg->lg_id;
+        //===写赔率记录===
+        //查询赔率记录是否存在
+        $oddsRecordID = $model['model_odds_record']::where(['odds_only'=>$data['odds_only']])
+            ->value('id');
+
+        $set_odds_r = [
+            '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'),
+        ];
+        //更新或写入赔率记录
+        if(!empty($oddsID)){
+            $ret = $model['model_odds_record']::where(['id'=>$oddsRecordID])
+                -> update($set_odds_r);
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR)) ;//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }else{
+            $ret = $model['model_odds_record']::insert($set_odds_r);
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }
+        //===写赔率===
         //查询 赔率数据是否存在
-        $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']])
+        $oddsID = $model['model_odds']::where(['sole'=>$data['sole']])
             ->value('id');
 
         $set_odds = [
@@ -368,14 +423,14 @@ class WriteSportsController extends BaseController{
         ];
         //更新或写入赔率数据
         if(!empty($oddsID)){
-            $ret = $model['model_odds']::where(['id'=>$oddsID])
+            $ret = $model['model_odds']::where(['sole'=>$data['sole']])
                 -> update($set_odds);
-            if($ret < 1) throw new \Exception(Response::generate(Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率-odds_only:'.$data['odds_only'].';',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'));
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
         }
-//        return Response::success();
+        //===end===
     }
 
     //写入联赛结果
@@ -388,7 +443,7 @@ class WriteSportsController extends BaseController{
         //验证结果所属联赛
         $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'));
+        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',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');
@@ -404,10 +459,10 @@ class WriteSportsController extends BaseController{
         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'));
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',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'));
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
         }
 //        return Response::success();
     }
@@ -421,11 +476,11 @@ class WriteSportsController extends BaseController{
         //验证结果所属联赛
         $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'));
+        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',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'));
+        if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
         //查询结果是否存在
         $match_r_id = $model['model_result']::where(['match_id'=>$match_id])
             ->value('id');
@@ -457,10 +512,10 @@ class WriteSportsController extends BaseController{
         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'));
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',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'));
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
         }
 //        return Response::success();
     }
@@ -474,11 +529,11 @@ class WriteSportsController extends BaseController{
         //验证结果所属联赛
         $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'));
+        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',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'));
+        if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',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');
@@ -507,10 +562,10 @@ class WriteSportsController extends BaseController{
         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'));
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',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'));
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
         }
 //        return Response::success();
     }
@@ -525,7 +580,7 @@ class WriteSportsController extends BaseController{
         $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'));
+        if(count($match) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR)) ;//Render([], '10016', lang('Tips','Sports')->get('match_error'));
 
         //获取赛事 本地/源ID
         $others_match_id = $match->others_match_id;
@@ -534,7 +589,7 @@ class WriteSportsController extends BaseController{
         $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'));
+        if(count($lg) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
 
         //获取联赛 本地/源ID
         $others_lg_id = $lg->others_lg_id;
@@ -565,10 +620,10 @@ class WriteSportsController extends BaseController{
         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'));
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',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'));
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
         }
 //        return Response::success();
     }

+ 8 - 6
app/Http/Response/Response.php

@@ -4,7 +4,6 @@ namespace App\Http\Response;
 
 class Response
 {
-
     const SUCCESS = 1;
     //体育数据入库操作
     const HANDLE_ERRORS = 10010;
@@ -25,14 +24,15 @@ class Response
     const HALF_MATCH_ERROR = 10025;
     const AUTH_ERROR = 10026;
     const LOCAL_MATCH_ERROR = 10027;
+    const BROADCAST_ERROR = 10028;
 
     private static $errorMsgs = [
-        self::SUCCESS           => '成功',
+        self::SUCCESS => '成功',
         //===体育数据写入===
         self::HANDLE_ERRORS =>'数据处理失败',
         self::ABNORMAL =>'提交数据异常',
-        self::UPDATE_ERROR =>'数据更新失败',
-        self::INSERT_ERROR =>'数据插入失败',
+        self::UPDATE_ERROR =>'数据更新失败',
+        self::INSERT_ERROR =>'数据插入失败',
         self::COUNTRY_ERROR =>'国家不存在',
         self::AREA_ERROR =>'地区不存在',
         self::LEAGUE_ERROR =>'联赛不存在',
@@ -47,6 +47,7 @@ class Response
         self::HALF_MATCH_ERROR =>'所属上半场赛事不存在',
         self::AUTH_ERROR => '无权操作',
         self::LOCAL_MATCH_ERROR =>'写入赛事关联记录失败',
+        self::BROADCAST_ERROR =>'写入直播数据失败',
     ];
 
     public static function getMsg($code)
@@ -54,11 +55,12 @@ class Response
         return isset(static::$errorMsgs[$code]) ? static::$errorMsgs[$code] : '';
     }
 
-    public static function generate($errCode, $data = [], $errMsg = '')
+    public static function generate($front = '',$errCode, $data = [], $errMsg = '')
     {
         $rs['status'] = $errCode;
         $rs['msg'] = $errMsg;
         $rs['msg'] OR $rs['msg'] = static::getMsg($errCode) ?: static::$errorMsgs[static::FAILED];
+        $rs['msg'] = $front.$rs['msg'];
         $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);
@@ -67,7 +69,7 @@ class Response
 
     public static function success($data = [])
     {
-        return static::generate(Response::SUCCESS, $data);
+        return static::generate('',Response::SUCCESS, $data);
         exit();
     }
 

+ 9 - 2
app/Lib/Biz/Sport/Common.php

@@ -11,6 +11,7 @@ use App\Http\Model\StZqOdds;
 use App\Http\Model\StZqOddsRecord;
 use App\Http\Model\StZqResult;
 use App\Http\Model\StZqResultRecord;
+use App\Http\Model\StZqBroadcast;
 
 use App\Http\Model\StLqMatch;
 use App\Http\Model\StLqLeague;
@@ -21,6 +22,7 @@ use App\Http\Model\StLqOdds;
 use App\Http\Model\StLqOddsRecord;
 use App\Http\Model\StLqResult;
 use App\Http\Model\StLqResultRecord;
+use App\Http\Model\StLqBroadcast;
 
 use App\Http\Model\StWqResultRecord;
 use App\Http\Model\StWqMatch;
@@ -31,6 +33,7 @@ use App\Http\Model\StWqLocalMatch;
 use App\Http\Model\StWqOdds;
 use App\Http\Model\StWqOddsRecord;
 use App\Http\Model\StWqResult;
+use App\Http\Model\StWqBroadcast;
 
 use App\Http\Model\StBqResultRecord;
 use App\Http\Model\StBqMatch;
@@ -41,7 +44,7 @@ use App\Http\Model\StBqLocalMatch;
 use App\Http\Model\StBqOdds;
 use App\Http\Model\StBqOddsRecord;
 use App\Http\Model\StBqResult;
-
+use App\Http\Model\StBqBroadcast;
 
 class Common {
     function checkDebug()
@@ -639,7 +642,6 @@ class Common {
      * 根据球类代码 定义相关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){
@@ -653,6 +655,7 @@ class Common {
                     $model_league_result = new StZqLeagueResult;
                     $model_local_league = new StZqLocalLeague;
                     $model_local_match = new StZqLocalMatch;
+                    $model_broadcast = new StZqBroadcast;
                     break;
                 case 'lq':
                     $model_league = new StLqLeague;
@@ -664,6 +667,7 @@ class Common {
                     $model_league_result = new StLqLeagueResult;
                     $model_local_league = new StLqLocalLeague;
                     $model_local_match = new StLqLocalMatch;
+                    $model_broadcast = new StLqBroadcast;
                     break;
                 case 'wq':
                     $model_league = new StWqLeague;
@@ -675,6 +679,7 @@ class Common {
                     $model_league_result = new StWqLeagueResult;
                     $model_local_league = new StWqLocalLeague;
                     $model_local_match = new StWqLocalMatch;
+                    $model_broadcast = new StWqBroadcast;
                     break;
                 case 'bq':
                     $model_league = new StBqLeague;
@@ -686,6 +691,7 @@ class Common {
                     $model_league_result = new StBqLeagueResult;
                     $model_local_league = new StBqLocalLeague;
                     $model_local_match = new StBqLocalMatch;
+                    $model_broadcast = new StBqBroadcast;
                     break;
                 default:
                     throw new \Exception(Response::generate(Response::ABNORMAL));
@@ -701,6 +707,7 @@ class Common {
             'model_league_result'=>$model_league_result,//联赛结果
             'model_local_league'=>$model_local_league,//本地关联联赛
             'model_local_match'=>$model_local_match,//本地关联赛事
+            'model_broadcast'=>$model_broadcast,
         ];
         return $data;
     }

+ 112 - 25
app/Lib/Settlement/Adapter/ZqRule.php

@@ -548,53 +548,53 @@ class ZqRule
     public  function  first_ball_home($model,$resultModel,$resultRecords){
         if ($resultModel->all_goal >0){
             if  ($resultModel->first_score === $resultModel->home_team){
-                return 1;
+                return ['result'=>1,'matchResult'=>''];
             }else{
-                return -1 ;
+                return ['result'=>-1,'matchResult'=>''];
             }
 		}
-        return 2 ;
+        return ['result'=>2,'matchResult'=>''] ;
     }
     //客队|最先进球
     public  function  first_ball_guest($model,$resultModel,$resultRecords){
         if ($resultModel->all_goal >0){
             if  ($resultModel->first_score === $resultModel->guest_team){
-                return 1;
+                return ['result'=>1,'matchResult'=>''];
             }else{
-                return -1 ;
+                return ['result'=>-1,'matchResult'=>''] ;
             }
 		}
-        return 2 ;
+        return ['result'=>2,'matchResult'=>''] ;
     }
     //主队|最后进球
     public  function  last_ball_home($model,$resultModel,$resultRecords){
         if ($resultModel->all_goal >0){
             if  ($resultModel->last_score === $resultModel->home_team){
-                return 1;
+                return ['result'=>1,'matchResult'=>''];
             }else{
-                return -1 ;
+                return ['result'=>-1,'matchResult'=>''] ;
             }
 		}
-        return 2 ;
+        return ['result'=>2,'matchResult'=>''] ;
 
     }
     //客队|最后进球
     public  function  last_ball_guest($model,$resultModel,$resultRecords){
         if ($resultModel->all_goal >0){
             if  ($resultModel->last_score === $resultModel->guest_team){
-                return 1;
+                return ['result'=>1,'matchResult'=>''];
             }else{
-                return -1 ;
+                return ['result'=>-1,'matchResult'=>''] ;
             }
 		}
-        return 2 ;
+        return ['result'=>2,'matchResult'=>''] ;
     }
     //没有进球
     public  function  not_ball($model,$resultModel,$resultRecords){
         if ($resultModel->all_goal <=0){
-            return 1 ;
+            return ['result'=>1,'matchResult'=>''] ;
         }else{
-            return -1 ;
+            return ['result'=>-1,'matchResult'=>''] ;
         }
 
     }
@@ -671,15 +671,36 @@ class ZqRule
         }
     }
 
-    //结果单/双 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球
+    //结果单/双 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场主队进球 u_guest_score 上半场-客队进球数  two_sides_single 全场单 two_sides_double 全场双 half_two_sides_single 上半场单 half_two_sides_double 上半场双
     public function  two_sides($model,$resultModel,$resultRecords){
-        $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score) + intval($resultModel->guest_rate) + intval($resultModel->home_rate);
+        $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score);//全场
+
         if($resulttod%2==0){
             $text = '双';
         }else{
             $text = '单';
         }
-        if($text = $model->condition){
+
+        if($model->odds_code == "two_sides_single"){
+            if($text == $model->condition){
+                $dsresult =1;
+            }else{
+                $dsresult = -1;
+            }
+        }elseif($model->odds_code == 'two_sides_double'){
+            if($text == $model->condition){
+                $dsresult =1;
+            }else{
+                $dsresult = -1;
+            }
+        }else{
+            $data = [
+                'result'=>100,
+                'matchResult'=>"参数不存在",
+            ];
+        }
+
+        if($dsresult==1){
             $data = [
                 'result'=>1,
                 'matchResult'=>"$resulttod(全场)",
@@ -692,26 +713,92 @@ class ZqRule
         }
         return $data;
 
-    }  
+    }
+ 
 
     //结果总数 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场-主队进球数 u_guest_score 上半场-客队进球数
     public function  total_goal($model,$resultModel,$resultRecords){
         //全场总进球数
-        $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score) + intval($resultModel->guest_rate) + intval($resultModel->home_rate);
+        $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score);
         //上半场总进球数
-        $Firsthalftod = intval($resultModel->home_score) + intval($resultModel->guest_score) + intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
-        
-        $qjnum = explode(',', $model->condition);
-        if($qjnum[0]<$resulttod and $qjnum[1]>$resulttod){
+        $Firsthalftod = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
+       
+        $qjnum = explode('-', $model->condition);
+        if($model->odds_code = "total_goal_four"){
+            if($qjnum[0]<=$resulttod and $qjnum[1]>=$resulttod){
+                $results = 1;
+            }else{
+                $results = -1;
+            }
+        }elseif($model->odds_code = "total_goal_zero"){
+            if($qjnum[0]<=$resulttod and $qjnum[1]>=$resulttod){
+                $results = 1;
+            }else{
+                $results = -1;
+            }
+        }elseif($model->odds_code = "total_goal_two"){
+            if($qjnum[0]<=$resulttod and $qjnum[1]>=$resulttod){
+                $results = 1;
+            }else{
+                $results = -1;
+            }
+        }elseif($model->odds_code = "total_goal_seven"){
+            if($qjnum[0]<=$resulttod and $qjnum[1]>=$resulttod){
+                $results = 1;
+            }else{
+                $results = -1;
+            }
+        }elseif($model->odds_code = "half_total_goal_zero"){
+            if($qjnum[0]<=$Firsthalftod and $qjnum[1]>=$Firsthalftod){
+                $resultb = 1;
+            }else{
+                $resultb = -1;
+            }
+        }elseif($model->odds_code = "half_total_goal_one"){
+            if($qjnum[0]<=$Firsthalftod and $qjnum[1]>=$Firsthalftod){
+                $resultb = 1;
+            }else{
+                $resultb = -1;
+            }
+        }elseif($model->odds_code = "half_total_goal_two"){
+            if($qjnum[0]<=$Firsthalftod and $qjnum[1]>=$Firsthalftod){
+                $resultb = 1;
+            }else{
+                $resultb = -1;
+            }
+        }elseif($model->odds_code = "half_total_goal_three"){
+            if($qjnum[0]<=$Firsthalftod and $qjnum[1]>=$Firsthalftod){
+                $resultb = 1;
+            }else{
+                $resultb = -1;
+            }
+        }else{
+            $data = [
+                'result'=>100,
+                'matchResult'=>"参数不存在",
+            ];
+        }
+
+        if($results==1){
             $data = [
                 'result'=>1,
                 'matchResult'=>"$resulttod(全场)",
             ];
-        }else{
-           $data = [
+        }elseif($results == -1){
+            $data = [
                 'result'=>-1,
                 'matchResult'=>"$resulttod(全场)",
             ];
+        }elseif($resultb==1){
+            $data = [
+                'result'=>1,
+                'matchResult'=>"$resulttod(半场)",
+            ];
+        }elseif($resultb == -1){
+            $data = [
+                'result'=>-1,
+                'matchResult'=>"$resulttod(半场)",
+            ];
         }
         return $data;
     }

+ 19 - 9
app/Lib/Settlement/SettlementOrder.php

@@ -56,7 +56,13 @@ class SettlementOrder extends SettlementBase
         $this->set_type = $settype;
 
         if (empty($order_ids)) {
-            return self::makeData(5, '订单号不能为空');
+            $needs_matchs = DB::table('money_buy_match')->where(['game_code' => $game_code, 'match_id' => $match_id])->get();
+            if (count($needs_matchs) <= 0) {
+                $this->cgStatus($game_code, $match_id);
+                return self::makeData();
+            } else {
+                return self::makeData(5, '订单号不能为空');
+            }
         }
 
         if ($bettype == 1) {
@@ -225,9 +231,9 @@ class SettlementOrder extends SettlementBase
             'type' => 1,
         ]);
         // 新增中奖记录表
-        $old = DB:: table('money_prize')->where(['buy_identity' => $buy_identity])->first();
+        $old = DB:: table('money_prize')->where(['buy_identity' => $buy_identity])->orWhere(['order_id' => $order_id])->first();
         if ($old) {
-            DB:: table('money_prize')->where(['buy_identity' => $buy_identity])->update(['money' => $money, 'prize_money' => $returnMoney, 'get_money' => $returnMoney - $money]);
+            DB:: table('money_prize')->where(['buy_identity' => $buy_identity])->orWhere(['order_id' => $order_id])->update(['money' => $money, 'prize_money' => $returnMoney, 'get_money' => $returnMoney - $money]);
         } else {
             DB:: table('money_prize')->insert([
                 'info_identity' => $info_identity,
@@ -304,7 +310,9 @@ class SettlementOrder extends SettlementBase
 
         $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;
 
     }
@@ -318,31 +326,33 @@ class SettlementOrder extends SettlementBase
         $modelSMD = new SettlementMiddleDetailModel();
         $hisData = $modelSMD->getSettledatas($game_code, $match_id, $bettype);
 
-        if (empty($hisData)) {
+        if (count($hisData) <= 0) {
             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])) {
+            if (!isset($orderList[$val->order_id])) {
                 throw  new  \Exception("订单数据缺失异常!($game_code,$match_id,$oid)");
             }
             $money = $val->money * (-1);
@@ -353,7 +363,7 @@ class SettlementOrder extends SettlementBase
         }
         $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]);
+            $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, 'game_status' => 0]);
         } else {
             $ret1 = DB::table($table)->where(['status' => 1])->whereIn('order_id', $order_ids)->update(['settle_status' => 1, 'gain_money' => 0]);
         }

+ 25 - 17
app/Lib/Settlement/SettlementWinFail.php

@@ -60,11 +60,12 @@ 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 (count($allmatchs)==0) {
+            //$allmatchs = DB::table('money_buy_match')->where(['game_code' => $ComendNoticModel->game_code, 'match_id' => $ComendNoticModel->match_id, 'result' => 0])->get();
+            $allmatchs = DB::table('money_buy_match')->where(['game_code' => $ComendNoticModel->game_code, 'match_id' => $ComendNoticModel->match_id])->get();
+            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::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, '本赛事无订单数据,退出');
             }
@@ -87,7 +88,7 @@ class SettlementWinFail
 
         } catch (\Exception $e) {
             DB::rollBack();
-            return $this->makeData(0, 'false', ['msg' => $e->getMessage(), 'code' => $e->getCode()]);
+            return $this->makeData(0, 'false', ['msg' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
 
         }
     }
@@ -95,12 +96,16 @@ 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 (count($buyModels)==0) {
+        //$buyModels = DB::table('money_buy_simplex')->where(['match_id' => $match_id, 'game_status' => 0])->get();
+        $buyModels = DB::table('money_buy_simplex')->where(['match_id' => $match_id])->get();
+
+        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 (count($buymatchModles)==0) {
+
+        //$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();
+        $buymatchModles = DB::table('money_buy_match')->where(['match_id' => $match_id, 'bet_type' => 1, 'game_code' => $game_type])->orderby('batch_id', 'asc')->get();
+        if (count($buymatchModles) == 0) {
             return true;
         }
 
@@ -121,6 +126,8 @@ class SettlementWinFail
                     $wininfo = $winorfalse['result'];
                     $matchinfo = $winorfalse['matchResult'];
                     $this->makesql_up_buymatch_winorfalse($sval->id, $wininfo, date("Y-m-d H:i:s"), $matchinfo);
+                    $gs_val = ($wininfo == 1) ? 1 : ($wininfo == -1 ? 2 : 3);
+                    DB::table('money_buy_simplex')->where(['batch_id'=>$sval->batch_id,'game_code'=>$sval->game_code])->update(['game_status'=>$gs_val]);
                 }
             }
         }
@@ -131,7 +138,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 (count($matchModels)==0) {
+        if (count($matchModels) == 0) {
             return true;
         }
 
@@ -146,7 +153,7 @@ class SettlementWinFail
 
         $buyModels = DB::table('money_buy_str')->whereIn('batch_id', $batch_ids_array)->get();
         $buyKeyModels = [];
-        if (count($buyModels)==0) {
+        if (count($buyModels) == 0) {
             return true;
         }
         foreach ($buyModels as $val) {
@@ -162,6 +169,7 @@ class SettlementWinFail
                 $wininfo = $winorfalse['result'];
                 $matchinfo = $winorfalse['matchResult'];
                 $this->makesql_up_buymatch_winorfalse($sval->id, $wininfo, date("Y-m-d H:i:s"), $matchinfo);
+
                 $sql = "update money_buy_str  set  wait_match_num=wait_match_num-1 where  batch_id='$sval->batch_id' ";
                 DB::update($sql);
             }
@@ -175,6 +183,7 @@ class SettlementWinFail
         $fun2 = $sval->p_code;
 
         if ($sval->p_code != 'gj') {
+
             if (empty($this->resultModel) || empty($this->resultRecords)) {
                 throw  new \Exception('非冠军比赛结果数据不能为空');
             }
@@ -184,7 +193,7 @@ class SettlementWinFail
             } elseif ($this->RefClass->hasMethod($fun2)) {
                 $winorfalse = $this->AdapterObj->$fun2($sval, $this->resultModel, $this->resultRecords);
             } else {
-                throw new \Exception('没有找到玩法输赢判断规则', 40010);
+                throw new \Exception('没有找到玩法输赢判断规则-01', 40010);
             }
         } else {
             $this->getGjDatas($sval);
@@ -197,10 +206,11 @@ class SettlementWinFail
             } elseif ($this->RefClass->hasMethod($fun2)) {
                 $winorfalse = $this->AdapterObj->$fun2($sval, $this->gjModel, []);
             } else {
-                throw new \Exception('没有找到玩法输赢判断规则', 40010);
+                throw new \Exception('没有找到玩法输赢判断规则-02', 40010);
             }
         }
 
+
         if (!isset($winorfalse['result']) || !isset($winorfalse['matchResult'])) {
             throw new \Exception('输赢结果数据结构异常!', 40011);
         }
@@ -214,10 +224,8 @@ class SettlementWinFail
 
     private function makesql_up_buymatch_winorfalse($id, $result, $utime, $matchResult = '')
     {
-        $sql = " update  money_buy_match  set  result=$result,utime='$utime',\"matchResult\"='$matchResult'  where id=$id  ";
-        DB::update($sql);
-
-        return true;
+        $ret = DB::table('money_buy_match')->where(['id'=>$id])->update(['result'=>$result,'utime'=>$utime,'matchResult'=>$matchResult]);
+        return $ret;
     }
 
     //设置 输赢 解析规则适配器

+ 66 - 0
app/Models/BaseLeague.php

@@ -10,6 +10,72 @@ use Illuminate\Support\Facades\DB;
 class BaseLeague extends BaseModel {
     protected $table = "st_bq_league";
 
+    function getinfo($list = 10, $page, $where = '')
+    {
+        if (is_array ($where) && count ($where) > 0){
+            $data = $this
+                ->orderby('utime','desc')
+                ->where($where)
+                ->paginate ($list);
+        }else{
+            $data = $this
+                ->orderby('utime','desc')
+                ->paginate ($list);
+        }
+        if (!$data) {
+            return -5040000102; //无相关信息
+        }
+        //地区
+        $area = \App\Models\StAreaCountry::where('pid','0')->get();
+//        $str = '';
+//        for($a=0;$a<count($area);$a++){
+//            $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
+//        }
+        //国家
+        $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
+
+        for($i=0;$i<count($data);$i++){
+            //$data[$i]->id = $data[$i]->lg_id;
+
+            if($data[$i]->status == '-1'){
+                $data[$i]->league_status = '未启用';
+            }
+            if($data[$i]->status == '1'){
+                $data[$i]->league_status = '启用';
+            }
+
+//            $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
+//            $data[$i]->country = '<select name="country" id="country"></select>';
+            $str = 0;
+            $str1 = 0;
+            if($data[$i]->area_id == '0'){
+                $data[$i]->area = '无';
+            }else{
+                for($b=0;$b<count($area);$b++){
+                    if($area[$b]->id == $data[$i]->area_id){
+                        $str = 1;
+                        $data[$i]->area = $area[$b]->name;
+                    }
+                }
+                if($str == 0){$data[$i]->area = '无';}
+            }
+            if($data[$i]->country_id == 0){
+                $data[$i]->country = '无';
+            }else{
+                for($c=0;$c<count($country);$c++){
+                    if($country[$c]->id == $data[$i]->country_id){
+                        $str1 = 1;
+                        $data[$i]->country = $country[$c]->name;
+                    }
+                }
+                if($str1 == 0){$data[$i]->country = '无';}
+            }
+
+        }
+
+        return $data->toArray();
+    }
+
     //所有赛事
     function allleague()
     {

+ 66 - 0
app/Models/BasketLeague.php

@@ -12,6 +12,72 @@ class BasketLeague extends BaseModel {
     protected $table = "st_lq_league";
     public $timestamps = false;
 
+    function getinfo($list = 10, $page, $where = '')
+    {
+        if (is_array ($where) && count ($where) > 0){
+            $data = $this
+                ->orderby('utime','desc')
+                ->where($where)
+                ->paginate ($list);
+        }else{
+            $data = $this
+                ->orderby('utime','desc')
+                ->paginate ($list);
+        }
+        if (!$data) {
+            return -5040000102; //无相关信息
+        }
+        //地区
+        $area = \App\Models\StAreaCountry::where('pid','0')->get();
+//        $str = '';
+//        for($a=0;$a<count($area);$a++){
+//            $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
+//        }
+        //国家
+        $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
+
+        for($i=0;$i<count($data);$i++){
+            //$data[$i]->id = $data[$i]->lg_id;
+
+            if($data[$i]->status == '-1'){
+                $data[$i]->league_status = '未启用';
+            }
+            if($data[$i]->status == '1'){
+                $data[$i]->league_status = '启用';
+            }
+
+//            $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
+//            $data[$i]->country = '<select name="country" id="country"></select>';
+            $str = 0;
+            $str1 = 0;
+            if($data[$i]->area_id == '0'){
+                $data[$i]->area = '无';
+            }else{
+                for($b=0;$b<count($area);$b++){
+                    if($area[$b]->id == $data[$i]->area_id){
+                        $str = 1;
+                        $data[$i]->area = $area[$b]->name;
+                    }
+                }
+                if($str == 0){$data[$i]->area = '无';}
+            }
+            if($data[$i]->country_id == 0){
+                $data[$i]->country = '无';
+            }else{
+                for($c=0;$c<count($country);$c++){
+                    if($country[$c]->id == $data[$i]->country_id){
+                        $str1 = 1;
+                        $data[$i]->country = $country[$c]->name;
+                    }
+                }
+                if($str1 == 0){$data[$i]->country = '无';}
+            }
+
+        }
+
+        return $data->toArray();
+    }
+
     //所有联赛
     function allleague()
     {

+ 1 - 1
app/Models/MoneyBuyStr.php

@@ -150,7 +150,7 @@ class MoneyBuyStr extends BaseModel {
         for($i=0;$i<count($data);$i++){
 
             //当父级玩法代码为first_last_ball/half_full/capot/two_sides时,不显示赔率条件
-            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' ){
+            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]->p_code == 'total_goal'){
                 $data[$i]->condition = '';
             }
             

+ 1 - 1
app/Models/SettlementMiddleDetail.php

@@ -15,7 +15,7 @@ class SettlementMiddleDetail extends BaseModel
             'bet_type' => $bettype
         ])->get();
 
-        if ($his) {
+        if (count($his) > 0) {
             foreach ($his as $val) {
                 $ret[$val->order_id] = $val;
             }

+ 65 - 1
app/Models/SoccerLeague.php

@@ -11,8 +11,72 @@ use Illuminate\Support\Facades\DB;
 class SoccerLeague extends BaseModel {
     protected $table = "st_zq_league";
     public $timestamps = false;
-    
 
+    function getinfo($list = 10, $page, $where = '')
+    {
+        if (is_array ($where) && count ($where) > 0){
+            $data = $this
+                ->orderby('utime','desc')
+                ->where($where)
+                ->paginate ($list);
+        }else{
+            $data = $this
+                ->orderby('utime','desc')
+                ->paginate ($list);
+        }
+        if (!$data) {
+            return -5040000102; //无相关信息
+        }
+        //地区
+        $area = \App\Models\StAreaCountry::where('pid','0')->get();
+//        $str = '';
+//        for($a=0;$a<count($area);$a++){
+//            $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
+//        }
+        //国家
+        $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
+
+        for($i=0;$i<count($data);$i++){
+            //$data[$i]->id = $data[$i]->lg_id;
+
+            if($data[$i]->status == '-1'){
+                $data[$i]->league_status = '未启用';
+            }
+            if($data[$i]->status == '1'){
+                $data[$i]->league_status = '启用';
+            }
+
+//            $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
+//            $data[$i]->country = '<select name="country" id="country"></select>';
+            $str = 0;
+            $str1 = 0;
+            if($data[$i]->area_id == '0'){
+                $data[$i]->area = '无';
+            }else{
+                for($b=0;$b<count($area);$b++){
+                    if($area[$b]->id == $data[$i]->area_id){
+                        $str = 1;
+                        $data[$i]->area = $area[$b]->name;
+                    }
+                }
+                if($str == 0){$data[$i]->area = '无';}
+            }
+            if($data[$i]->country_id == 0){
+                $data[$i]->country = '无';
+            }else{
+                for($c=0;$c<count($country);$c++){
+                    if($country[$c]->id == $data[$i]->country_id){
+                        $str1 = 1;
+                        $data[$i]->country = $country[$c]->name;
+                    }
+                }
+                if($str1 == 0){$data[$i]->country = '无';}
+            }
+
+        }
+
+        return $data->toArray();
+    }
     //所有赛事id
     function allleague()
     {

+ 5 - 0
app/Models/SportsBase.php

@@ -113,7 +113,12 @@ class SportsBase extends BaseModel {
                 $data[$i]->status = '正在进行';
             }else if($data[$i]->status==2){
                 $data[$i]->status = '已结束';
+            }else if($data[$i]->status==3){
+                $data[$i]->status = '已结算';
+            }else if($data[$i]->status==4){
+                $data[$i]->status = '已作废';
             }
+
             if($data[$i]->guest_team == ''){
                 $data[$i]->home_guest = $data[$i]->home_team;
             }else{

+ 5 - 0
app/Models/SportsBasket.php

@@ -113,7 +113,12 @@ class SportsBasket extends BaseModel {
                 $data[$i]->status = '正在进行';
             }else if($data[$i]->status==2){
                 $data[$i]->status = '已结束';
+            }else if($data[$i]->status==3){
+                $data[$i]->status = '已结算';
+            }else if($data[$i]->status==4){
+                $data[$i]->status = '已作废';
             }
+
             if($data[$i]->guest_team == ''){
                 $data[$i]->home_guest = $data[$i]->home_team;
             }else{

+ 2 - 1
app/Models/SportsNoteList.php

@@ -123,7 +123,7 @@ class SportsNoteList extends BaseModel {
                     }
                 }
                 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' ){
+                    if($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal'){
                         $content[$b]->condition = '';
                     }
 
@@ -230,6 +230,7 @@ class SportsNoteList extends BaseModel {
             for ($i=0; $i < count($data); $i++) { 
                 $the = array(
                     'status' => 2,
+                    'game_status' => 3,
                 );
                 $res = $this->where('order_id',$data[$i]['order_id'])->update($the);
             }

+ 5 - 0
app/Models/SportsTennis.php

@@ -113,7 +113,12 @@ class SportsTennis extends BaseModel {
                 $data[$i]->status = '正在进行';
             }else if($data[$i]->status==2){
                 $data[$i]->status = '已结束';
+            }else if($data[$i]->status==3){
+                $data[$i]->status = '已结算';
+            }else if($data[$i]->status==4){
+                $data[$i]->status = '已作废';
             }
+
             if($data[$i]->guest_team == ''){
                 $data[$i]->home_guest = $data[$i]->home_team;
             }else{

+ 66 - 0
app/Models/TennisLeague.php

@@ -12,6 +12,72 @@ class TennisLeague extends BaseModel {
     protected $table = "st_wq_league";
     public $timestamps = false;
 
+    function getinfo($list = 10, $page, $where = '')
+    {
+        if (is_array ($where) && count ($where) > 0){
+            $data = $this
+                ->orderby('utime','desc')
+                ->where($where)
+                ->paginate ($list);
+        }else{
+            $data = $this
+                ->orderby('utime','desc')
+                ->paginate ($list);
+        }
+        if (!$data) {
+            return -5040000102; //无相关信息
+        }
+        //地区
+        $area = \App\Models\StAreaCountry::where('pid','0')->get();
+//        $str = '';
+//        for($a=0;$a<count($area);$a++){
+//            $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
+//        }
+        //国家
+        $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
+
+        for($i=0;$i<count($data);$i++){
+            //$data[$i]->id = $data[$i]->lg_id;
+
+            if($data[$i]->status == '-1'){
+                $data[$i]->league_status = '未启用';
+            }
+            if($data[$i]->status == '1'){
+                $data[$i]->league_status = '启用';
+            }
+
+//            $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
+//            $data[$i]->country = '<select name="country" id="country"></select>';
+            $str = 0;
+            $str1 = 0;
+            if($data[$i]->area_id == '0'){
+                $data[$i]->area = '无';
+            }else{
+                for($b=0;$b<count($area);$b++){
+                    if($area[$b]->id == $data[$i]->area_id){
+                        $str = 1;
+                        $data[$i]->area = $area[$b]->name;
+                    }
+                }
+                if($str == 0){$data[$i]->area = '无';}
+            }
+            if($data[$i]->country_id == 0){
+                $data[$i]->country = '无';
+            }else{
+                for($c=0;$c<count($country);$c++){
+                    if($country[$c]->id == $data[$i]->country_id){
+                        $str1 = 1;
+                        $data[$i]->country = $country[$c]->name;
+                    }
+                }
+                if($str1 == 0){$data[$i]->country = '无';}
+            }
+
+        }
+
+        return $data->toArray();
+    }
+
 
     //所有赛事id
     function allleague()

+ 4 - 0
resources/lang/zh-cn/sportsbase.php

@@ -14,6 +14,10 @@ return array(
     'recommend' => '是否推荐',
     'match_score' => '赛事比分',
     'search' => '搜索',
+    'area' => '地区',
+    'country' => '国家',
+    'league_status' => '联赛状态',
+    'utime' => '修改时间',
 
 );
 

+ 4 - 1
resources/lang/zh-cn/sportssoccer.php

@@ -2,6 +2,7 @@
 return array(
     'id' => '赔率id',
     'match_id' => '赛事id',
+    'lg_id' => '联赛id',
     'odds_code' => '赔率代码',
     'odds_code_cn' => '赔率代码',
     'odds' => '赔率值',
@@ -22,6 +23,8 @@ return array(
     'match_status_search' => '赛事状态查询',
 
     'p_code_search' => '父级赔率代码查询',
-    'odds_status_search' => '赔率状态查询',
+    'league_status_search' => '联赛状态查询',
+
+
 
 );

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

@@ -343,6 +343,12 @@ return array(
 			'2' => '已结束',
 		),
 	),
+	'league_status' => array(
+		'status' => array(
+			'-1' => '未启用',
+			'1' => '启用',
+		),
+	),
 	'sjsource' => array(
 		'source' => array(
 			'hg3535' => 'hg3535',

+ 9 - 9
resources/views/admin/sportsfoot/outcome.blade.php

@@ -71,9 +71,9 @@
     <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="u_home_score" name="u_home_score" value="@{{d.u_home_score}}" onchange="inputFunc(@{{d.id}}, event.target.value,@{{d.match_id}})"> 
+        <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,@{{d.match_id}})"> / 
+        <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,@{{d.match_id}})">
         <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}})">
 
       @{{#} }}
@@ -223,7 +223,7 @@
         }
 
         //上半场主队
-        function inputFunc(id,num){
+        function inputFunc(id,num,match_id){
             var id = id;
             var num = num;
             var reg = /^[0-99]\d*$/;
@@ -240,7 +240,7 @@
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/Sportsfoot/updatenum',
-                data: {id:id,num:num,type:1},
+                data: {id:id,num:num,type:1,match_id:match_id},
                 success: function(data) {
                     if(data.status==1){
                         layer.msg(data.msg);
@@ -250,7 +250,7 @@
             })
         }
         //上半场客队
-        function inputTunc(id,num){
+        function inputTunc(id,num,match_id){
            var id = id;
             var num = num;
             var reg = /^[0-99]\d*$/;
@@ -266,7 +266,7 @@
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/Sportsfoot/updatenum',
-                data: {id:id,num:num,type:2},
+                data: {id:id,num:num,type:2,match_id:match_id},
                 success: function(data) {
                     if(data.status==1){
                         layer.msg(data.msg);
@@ -276,7 +276,7 @@
             })
         }
         //全场主队
-        function inputSunc(id,num){
+        function inputSunc(id,num,match_id){
             var id = id;
             var num = num;
             var u_home_score = $("#u_home_score").val();
@@ -288,7 +288,7 @@
                 type: 'POST',
                 dataType: 'json',
                 url: '/admin/Sportsfoot/updatenum',
-                data: {id:id,num:num,type:3},
+                data: {id:id,num:num,type:3,match_id:match_id},
                 success: function(data) {
                     if(data.status==1){
                         layer.msg(data.msg);

+ 15 - 1
resources/views/sports/soccer_league.blade.php

@@ -83,7 +83,21 @@
                         {{--</div>--}}
                     {{--</div>--}}
 
-                    
+                    <div class="layui-inline">
+                        <label class="layui-form-label">{{ trans('sportssoccer.league_status_search') }}</label>
+                        <div class="layui-input-inline" style="width: 100px">
+                            <select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
+                                <option value="0"></option>
+                                @foreach(trans('status.league_status.status') as $k=>$v):
+                                @if($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" href="javascript:history.go(-1)" style="background-color:#1E9FFF;">返回</a>--}}