|
|
@@ -2,6 +2,14 @@
|
|
|
namespace App\Sports\Controller;
|
|
|
|
|
|
use BaseController\Controller;
|
|
|
+use App\Sports\Model\St_zq_competition as ZQmatchModel;
|
|
|
+use App\Sports\Model\St_lq_competition as LQmatchModel;
|
|
|
+use App\Sports\Model\St_wq_competition as WQmatchModel;
|
|
|
+use App\Sports\Model\St_bq_competition as BQmatchModel;
|
|
|
+use App\Sports\Model\St_zq_odds as ZQoddsModel;
|
|
|
+use App\Sports\Model\St_lq_odds as LQoddsModel;
|
|
|
+use App\Sports\Model\St_wq_odds as WQoddsModel;
|
|
|
+use App\Sports\Model\St_bq_odds as BQoddsModel;
|
|
|
|
|
|
/**
|
|
|
* Class Head
|
|
|
@@ -16,185 +24,93 @@ class Head extends Controller{
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 首页头部类别列表 弃用
|
|
|
+ * @throws \Exception
|
|
|
+ * 返回首页球类列表
|
|
|
*/
|
|
|
- public function __typeList (){
|
|
|
-
|
|
|
- //获取类型 代码
|
|
|
- $type = lang('GameTypes','Sports')->getAll();
|
|
|
- $ret = lm('GameType', 'Sports')->select('id','game_name','game_code','game_ico_url')->where('status',1)->get()->toArray();
|
|
|
-
|
|
|
- $data = [];
|
|
|
- foreach ($type as $key =>$item){
|
|
|
- $matchNum = [];
|
|
|
- $where = $this->commonFunction->getState($item['type_code']);
|
|
|
- foreach ($ret as $key1 => $item1){
|
|
|
- if($item1['game_code'] != 'gj'){
|
|
|
- //根据球类代码 获取相关model
|
|
|
- $models = $this->commonFunction->getModels($item1['game_code'],0);
|
|
|
- $model_match = $models['model_match'];
|
|
|
-
|
|
|
- $matchNum[$key1][] = lm($model_match, 'Sports')
|
|
|
-// ->select('match_id')
|
|
|
- ->where($this->source)
|
|
|
- ->where($where)
|
|
|
- ->count("*");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $num_s = array_sum(array_column($matchNum, 0));
|
|
|
-
|
|
|
- //追加统计 各状态赛事数量
|
|
|
- $item['matchNum'] = $num_s;
|
|
|
+ public function ballList (){
|
|
|
+ $ret = lm('GameType', 'Sports')->select('id','game_name','game_code','game_ico_url')->where('status',1)->get();
|
|
|
|
|
|
- $data[$key][]=$item;
|
|
|
- }
|
|
|
+ if(!empty($ret)) Render($ret, '1', lang('Tips','Sports')->get('success'));
|
|
|
|
|
|
- Render($data, '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 重写获取头部状态及其赛事数量
|
|
|
- */
|
|
|
+ //获取各状态下所有赛事数量
|
|
|
public function typeList(){
|
|
|
+ //获取所有未结束赛事
|
|
|
+ $where = [
|
|
|
+ ['status','<','2']
|
|
|
+ ];
|
|
|
+ $select = ['id','match_id','status','match_date','match_time','us_time','is_morningplate','is_stringscene'];
|
|
|
+ $ZQmatchData = ZQmatchModel::getMatchData($where,$select)->toarray();
|
|
|
+ $LQmatchData = LQmatchModel::getMatchData($where,$select)->toarray();
|
|
|
+ $WQmatchData = WQmatchModel::getMatchData($where,$select)->toarray();
|
|
|
+ $BQmatchData = BQmatchModel::getMatchData($where,$select)->toarray();
|
|
|
+ //合并所有球类赛事
|
|
|
+ $matchAll = array_merge_recursive($ZQmatchData,$LQmatchData,$WQmatchData,$BQmatchData);
|
|
|
+
|
|
|
+ //获取所有冠军盘口
|
|
|
+ $where = [
|
|
|
+ ['type','=',1],
|
|
|
+ ['source','=',$this->source]
|
|
|
+ ];
|
|
|
+ $select = ['match_id','type'];
|
|
|
+ $ZQoddsData = ZQoddsModel::getOddsData($where,$select)->toArray();
|
|
|
+ $LQoddsData = LQoddsModel::getOddsData($where,$select)->toArray();
|
|
|
+ $WQoddsData = WQoddsModel::getOddsData($where,$select)->toArray();
|
|
|
+ $BQoddsData = BQoddsModel::getOddsData($where,$select)->toArray();
|
|
|
+ //合并所有球类关键盘口
|
|
|
+ $oddsAll = array_merge_recursive($ZQoddsData,$LQoddsData,$WQoddsData,$BQoddsData);
|
|
|
+
|
|
|
+ $StRollBall = [];
|
|
|
+ $StSoon = [];
|
|
|
+ $StToday = [];
|
|
|
+ $StMorningPlate = [];
|
|
|
+ $StStringScene = [];
|
|
|
+ //按状态条件分装数组
|
|
|
+ foreach ($matchAll as $kk=>$vv){
|
|
|
+ if($vv['status'] == '1'){
|
|
|
+ $StRollBall[] = $vv;
|
|
|
+ }
|
|
|
+ if($vv['status'] == '0' and $vv['match_date'] == date("Y-m-d") and $vv['match_time'] < date("H:i:s", strtotime("+2 hour")) and $vv['match_time'] > date("H:i:s", time())){
|
|
|
+ $StSoon[] = $vv;
|
|
|
+ }
|
|
|
+ if($vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time())){
|
|
|
+ $StToday[] = $vv;
|
|
|
+ }
|
|
|
+ if($vv['is_morningplate'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)){
|
|
|
+ $StMorningPlate[] = $vv;
|
|
|
+ }
|
|
|
+ if($vv['is_stringscene'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)){
|
|
|
+ $StStringScene[] = $vv;
|
|
|
+ }
|
|
|
+ }
|
|
|
//获取所有状态
|
|
|
$type = lang('GameTypes','Sports')->getAll();
|
|
|
- $d = [];
|
|
|
-
|
|
|
- $ret = lm('GameType', 'Sports')->select('id','game_name','game_code','game_ico_url')->where('status',1)->get()->toArray();
|
|
|
-
|
|
|
- foreach ($type as $key =>$item){
|
|
|
- $matchNum = [];
|
|
|
- switch ($item['type_code']){
|
|
|
+ foreach ($type as $k=>$v){
|
|
|
+ switch ($v['type_code']) {
|
|
|
case 'StRollBall'://滚球
|
|
|
- foreach ($ret as $key1 => $item1){
|
|
|
- //根据球类代码 获取相关model
|
|
|
- $models = $this->commonFunction->getModels($item1['game_code'],1);
|
|
|
- $model_match = $models['model_match'];
|
|
|
- $model_result = $models['model_result'];
|
|
|
- $model_odds = $models['model_odds'];
|
|
|
- $where = $this->commonFunction->getState($item['type_code'],$model_match);
|
|
|
- if($item1['game_code'] != 'gj'){
|
|
|
- $matchNum[$key1][] = lm($model_match, 'Sports')
|
|
|
- ->join($model_result,$model_result.'.match_id',$model_match . '.match_id')
|
|
|
- ->where($model_match.'.source',$this->source['source'])
|
|
|
- ->where($where)
|
|
|
- ->count("*");
|
|
|
- }
|
|
|
- }
|
|
|
+ $type[$k]['matchNum'] = count($StRollBall);
|
|
|
break;
|
|
|
case 'StSoon'://即将
|
|
|
- foreach ($ret as $key1 => $item1){
|
|
|
- //根据球类代码 获取相关model
|
|
|
- $models = $this->commonFunction->getModels($item1['game_code'],1);
|
|
|
- $model_match = $models['model_match'];
|
|
|
- $model_league = $models['model_league'];
|
|
|
-
|
|
|
- $where = $this->commonFunction->getState($item['type_code'],$model_match);
|
|
|
- if($item1['game_code'] != 'gj'){
|
|
|
- $matchNum[$key1][] = lm($model_league,"Sports")
|
|
|
- ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
|
|
|
- ->where($model_match.'.source',$this->source['source'])
|
|
|
- ->where($where)
|
|
|
- ->count("*");
|
|
|
- }
|
|
|
- }
|
|
|
+ $type[$k]['matchNum'] = count($StSoon);
|
|
|
break;
|
|
|
case 'StToday'://今日
|
|
|
- foreach ($ret as $key1 => $item1){
|
|
|
- //根据球类代码 获取相关model
|
|
|
- $models = $this->commonFunction->getModels($item1['game_code'],1);
|
|
|
- $model_match = $models['model_match'];
|
|
|
- $model_league = $models['model_league'];
|
|
|
- $where = $this->commonFunction->getState($item['type_code'],$model_match);
|
|
|
- if($item1['game_code'] != 'gj'){
|
|
|
-// $matchNum[$key1][] = lm($model_match, 'Sports')
|
|
|
-// ->where($model_match.'.source',$this->source['source'])
|
|
|
-// ->where($where)
|
|
|
-// ->count("*");
|
|
|
- $matchNum[$key1][] = lm($model_league,"Sports")
|
|
|
- ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
|
|
|
- ->where($model_match.'.source',$this->source['source'])
|
|
|
- ->where($where)
|
|
|
- ->count("*");
|
|
|
- }
|
|
|
- }
|
|
|
+ $type[$k]['matchNum'] = count($StToday);
|
|
|
break;
|
|
|
case 'StMorningPlate'://早盘
|
|
|
- foreach ($ret as $key1 => $item1){
|
|
|
- //根据球类代码 获取相关model
|
|
|
- $models = $this->commonFunction->getModels($item1['game_code'],1);
|
|
|
- $model_match = $models['model_match'];
|
|
|
- $model_league = $models['model_league'];
|
|
|
- $where = $this->commonFunction->getState($item['type_code'],$model_match);
|
|
|
- if($item1['game_code'] != 'gj'){
|
|
|
- $matchNum[$key1][] = lm($model_league,"Sports")
|
|
|
- ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
|
|
|
- ->where($model_match.'.source',$this->source['source'])
|
|
|
- ->where($where)
|
|
|
- ->count("*");
|
|
|
- }
|
|
|
- }
|
|
|
+ $type[$k]['matchNum'] = count($StMorningPlate);
|
|
|
break;
|
|
|
case 'StStringScene'://串场
|
|
|
- foreach ($ret as $key1 => $item1) {
|
|
|
- //根据球类代码 获取相关model
|
|
|
- $models = $this->commonFunction->getModels($item1['game_code'], 1);
|
|
|
- $model_match = $models['model_match'];
|
|
|
- $model_league = $models['model_league'];
|
|
|
- $where = $this->commonFunction->getState($item['type_code'], $model_match);
|
|
|
- if ($item1['game_code'] != 'gj') {
|
|
|
- $matchNum[$key1][] = lm($model_league,"Sports")
|
|
|
- ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
|
|
|
- ->where($model_match.'.source',$this->source['source'])
|
|
|
- ->where($where)
|
|
|
- ->count("*");
|
|
|
- }
|
|
|
- }
|
|
|
+ $type[$k]['matchNum'] = count($StStringScene);
|
|
|
break;
|
|
|
case 'StChampion'://冠军
|
|
|
- foreach ($ret as $key1 => $item1) {
|
|
|
- //根据球类代码 获取相关model
|
|
|
- $models = $this->commonFunction->getModels($item1['game_code'], 1);
|
|
|
- $model_odds = $models['model_odds'];
|
|
|
- $where = $this->commonFunction->getState($item['type_code']);
|
|
|
- if ($item1['game_code'] != 'gj') {
|
|
|
- $matchNum[$key1][] =count(lm($model_odds, 'Sports')
|
|
|
- ->select("match_id","type")
|
|
|
- ->where($this->source)
|
|
|
- ->where($where)
|
|
|
- ->groupby("match_id","type")
|
|
|
- ->get()
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
+ $type[$k]['matchNum'] = count($oddsAll);
|
|
|
break;
|
|
|
default:
|
|
|
- throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
|
|
|
+ throw new \Exception(Render([], '10002', lang('Tips', 'Sports')->get('PARAM_ERROR')));
|
|
|
}
|
|
|
-
|
|
|
- $num_s = array_sum(array_column($matchNum, 0));
|
|
|
-
|
|
|
- //追加统计 各状态赛事数量
|
|
|
- $item['matchNum'] = $num_s;
|
|
|
-
|
|
|
- $data[$key][]=$item;
|
|
|
-
|
|
|
}
|
|
|
- Render($data, '1', lang('Tips','Sports')->get('success'));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @throws \Exception
|
|
|
- * 返回首页球类列表
|
|
|
- */
|
|
|
- public function ballList (){
|
|
|
- $ret = lm('GameType', 'Sports')->select('id','game_name','game_code','game_ico_url')->where('status',1)->get();
|
|
|
-
|
|
|
- if(!empty($ret)) Render($ret, '1', lang('Tips','Sports')->get('success'));
|
|
|
+ Render($type, '1', lang('Tips','Sports')->get('success'));
|
|
|
|
|
|
}
|
|
|
}
|