|
|
@@ -0,0 +1,209 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+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\SettlementWinFail;
|
|
|
+use App\Models;
|
|
|
+use Request;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+class BasketLeagueController extends Controller {
|
|
|
+
|
|
|
+ public function index(Req $req) {
|
|
|
+ $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
|
|
|
+ $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
|
|
|
+ $request['match_date'] = isset($req->match_date) ? trim($req->match_date) : null;
|
|
|
+ $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : '';
|
|
|
+ $request['status'] = isset($req->status) ? trim($req->status) : '0';
|
|
|
+ $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
|
|
|
+ $data = \App\Models\BasketLeague::select('id','lg_id','name_chinese')->get();
|
|
|
+ $request['league'] = $data;
|
|
|
+ $dt = \App\Lib\DataTable\DataTable::init();
|
|
|
+ $dt->setDataSource('/admin/BasketLeague/info');
|
|
|
+ $dt->setLang('sportsbase');
|
|
|
+ $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
|
|
|
+ $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
|
|
|
+ $dt->addColsFields('area', array('sort' => false, 'width' => 180));
|
|
|
+ $dt->addColsFields('country', array('sort' => true, 'width' => 180));
|
|
|
+ $dt->addColsFields('league_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
|
|
|
+ $dt->addColsFields('utime', array('templet' => '#userdetail', 'sort' => false, 'width' => 160));
|
|
|
+ if (checkRriv('/admin/BasketLeague/edit')) {
|
|
|
+ $arr[] = 'edit';
|
|
|
+ }
|
|
|
+ $dt->setToolBar($arr, array('width' => 140));
|
|
|
+ $dt->enableCheckBox();
|
|
|
+ return view('sports/basket_league', $dt->render($request));
|
|
|
+ }
|
|
|
+
|
|
|
+ function info(Req $req) {
|
|
|
+ $page = Request::has('page') ? Request::get('page') : '';
|
|
|
+ $list = Request::has('limit') ? Request::get('limit') : 10;
|
|
|
+ $lg_id = Request::has('lg_id') ? Request::get('lg_id') : '';
|
|
|
+ $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
|
|
|
+ $status = Request::has('status') ? Request::get('status') : '';
|
|
|
+ $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
|
|
|
+ $where = array();
|
|
|
+ if (!empty($lg_id)) {
|
|
|
+// if (empty($sureblur) || $sureblur == 'off') {
|
|
|
+// $where[] = array('st_lq_league.lg_id', 'like', '%' . $lg_id . '%');
|
|
|
+// }else{
|
|
|
+// $where[] = array('st_lq_league.lg_id', '=', $lg_id);
|
|
|
+// }
|
|
|
+ $where[] = array('st_lq_league.lg_id', '=', $lg_id);
|
|
|
+ }
|
|
|
+ if ($name_chinese != -1) {
|
|
|
+ $where[] = array('st_lq_league.name_chinese', '=', $name_chinese);
|
|
|
+ }
|
|
|
+ if($status != 0){
|
|
|
+ $where[] = array('st_lq_league.status', '=', $status);
|
|
|
+ }
|
|
|
+
|
|
|
+ $newapp = new \App\Models\BasketLeague();
|
|
|
+ $data = $newapp->getinfo($list, $page, $where);
|
|
|
+ return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *获取地区
|
|
|
+ */
|
|
|
+ function getarea() {
|
|
|
+ $area = \App\Models\StAreaCountry::where('pid',0)->get();
|
|
|
+ return $area;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *获取该地区的所有国家
|
|
|
+ */
|
|
|
+ function getcountry() {
|
|
|
+ $pid = $_GET["id"];
|
|
|
+ $country = \App\Models\StAreaCountry::where('pid',$pid)->get();
|
|
|
+ return json_encode($country);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *添加联赛
|
|
|
+ */
|
|
|
+ function add(Req $req) {
|
|
|
+ if (!$req->isMethod('post')) {
|
|
|
+ $areas = $this->getarea();
|
|
|
+ if (!$areas) {
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+ $data['area'] = $areas;
|
|
|
+ return view('sports.basket_league_form', $data);
|
|
|
+ } else {
|
|
|
+ $model = new \App\Models\BasketLeague();
|
|
|
+ $model->name_chinese = $req->input('name_chinese');
|
|
|
+ $model->country_id = $req->input('country_id');
|
|
|
+ $model->area_id = $req->input('area_id');
|
|
|
+ $model->status = $req->input('status');
|
|
|
+ $model->lg_id = time();
|
|
|
+ $model->utime = date('Y-m-d H:i:s',time());
|
|
|
+ $model->source = 'user-defined';
|
|
|
+
|
|
|
+ $db = new \App\Models\Stlqlocalleague();
|
|
|
+ $db->source = 'user-defined';
|
|
|
+ $db->lg_id = $model->lg_id;
|
|
|
+
|
|
|
+ $model->save();
|
|
|
+ $db->save();
|
|
|
+ return responseToJson(1);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function view(Req $req) {
|
|
|
+ return $this->edit($req);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *修改联赛
|
|
|
+ */
|
|
|
+ function edit(Req $req) {
|
|
|
+ $id = $req->id;
|
|
|
+ if (intval($id) < 1) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if (!$req->isMethod('post')) {
|
|
|
+ $areas = $this->getarea();
|
|
|
+ if (!$areas) {
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+ $data = \App\Models\BasketLeague::where('id',$id)->first();
|
|
|
+ $areaname = \App\Models\StAreaCountry::where('id',$data->area_id)->first();
|
|
|
+ $countryname = \App\Models\StAreaCountry::where('id',$data->country_id)->first();
|
|
|
+ if(!empty($areaname)){
|
|
|
+ $data->area = $areaname->name;
|
|
|
+ }
|
|
|
+ if(!empty($countryname)){
|
|
|
+ $data->country = $countryname->name;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = $data->toArray();
|
|
|
+ $data['area'] = $areas;
|
|
|
+
|
|
|
+ return view('sports.basket_league_form', $data);
|
|
|
+ } else {
|
|
|
+ $model = new \App\Models\BasketLeague();
|
|
|
+ $model->id = $req->input('id');
|
|
|
+ $model = $model::find($model->id);
|
|
|
+ if(!empty($req->input('country_id'))){
|
|
|
+ $model->country_id = $req->input('country_id');
|
|
|
+ }
|
|
|
+ if(!empty($req->input('area_id'))){
|
|
|
+ $model->area_id = $req->input('area_id');
|
|
|
+ }
|
|
|
+ $model->status = $req->input('status');
|
|
|
+ $model->utime = date('Y-m-d H:i:s',time());
|
|
|
+ $model->save();
|
|
|
+ return responseToJson(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *删除联赛
|
|
|
+ */
|
|
|
+ public function delete(Req $req) {
|
|
|
+ $id = $req->input('id');
|
|
|
+ if (empty($id)) {
|
|
|
+ return responseToJson(-2001); //id???????
|
|
|
+ }
|
|
|
+ $ids = explode(',', $id);
|
|
|
+ if (!is_array($ids) && intval($ids) < 0) {
|
|
|
+ return responseToJson(-2002); //id????
|
|
|
+ }
|
|
|
+ $id = array();
|
|
|
+ $localleague = \App\Models\Stlqlocalleague::get();
|
|
|
+ if (is_array($ids) && count($ids) > 0) {
|
|
|
+ foreach ($ids as $k => $v) {
|
|
|
+ if (intval($v) < 1) {
|
|
|
+ unset($ids[$k]);
|
|
|
+ }
|
|
|
+ $league = \App\Models\BasketLeague::where('id',$v)->first();
|
|
|
+ for($i=0;$i<count($localleague);$i++){
|
|
|
+ if($localleague[$i]->lg_id == $league->lg_id){
|
|
|
+ $id[] = $localleague[$i]->id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $rows = \App\Models\BasketLeague::whereIn('id', $ids)->delete();
|
|
|
+ if (!$rows) {
|
|
|
+ return responseToJson(-2003); //id????
|
|
|
+ }
|
|
|
+ $row = \App\Models\Stlqlocalleague::whereIn('id', $id)->delete();
|
|
|
+ if (!$row) {
|
|
|
+ return responseToJson(-2003); //id????
|
|
|
+ }
|
|
|
+ return responseToJson(1, trans('menu.delete_success')); //id????
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|