Browse Source

调整首页联赛列表/追加个人中心-我的消息接口

彭俊 6 years ago
parent
commit
771f55e047

+ 69 - 0
Application/Api/Controller/Information.php

@@ -0,0 +1,69 @@
+<?php
+namespace App\Api\Controller;
+use Biz\Account\AccountManager;
+use App\Api\Model\AccountNews as AccountNewsModel;
+use App\Api\Model\Article as ArticleModel;
+
+/**
+ * 个人中心-消息通知
+ */
+class Information extends BaseController
+{
+    public function init() {
+        $this->accountManager = new AccountManager();
+        $this->commonFunction =  C()->get('commonFunction');
+
+         //获取用户token
+         $token = $_POST['token'];
+         $UserInfo = $this->getAgent($token);
+         //获取用户信息
+         $this->UserInfo = $UserInfo;
+         //获取用户uuid
+         $this->account_identity = $UserInfo['account_identity'];
+    }
+
+    /**
+     * 获取所有 消息通知
+     */
+    public function getAll(){
+       
+        dd( $this->UserInfo);
+
+        //获取投注信息
+        $BetNews = $this->getUserNews();
+    }
+    /**
+     * 获取通知消息
+     */
+    public function getUserNews(){
+        //获取当前用户投注信息
+        $UserNews = AccountNewsModel::getUserNews($this->UserInfo);
+
+        Render($UserNews, '1', lang('Tips','Sports')->get('success'));
+    }
+
+    /**
+     * 获取系统通知
+     */
+    public function getArticle(){
+        $Article = ArticleModel::getArticle($this->UserInfo);
+
+        Render($Article, '1', lang('Tips','Sports')->get('success'));
+    }
+
+    /**
+     * token获取用户详情
+     */
+    public function getAgent($token = '') {
+        $checkToken = $this->accountManager->checkEffectiveTime($token);
+        if ($checkToken['status'] != 1) {
+            Render($checkToken['data'], $checkToken['status'], lang('commons')->get('user does login'));
+        };
+        $result = $this->accountManager->refreshToken($token);
+        return $result['data'];
+    }
+
+
+
+}
+?>

+ 5 - 2
Application/Api/Model/Article.php

@@ -24,8 +24,11 @@ class Article extends Model {
 		
 		if (!empty($_POST['type'])) {
             $where[] = ['type','=',$_POST['type']];
-        }
-        
+		}
+		if(!empty($_POST['id'])){
+			$where[] = ['article.id','=',$_POST['id']];
+		}
+		
 		$data = lm('article', "api")
 		->join('article_type','article_type.id','article.type')
 		->select('article.id','identity','title','content','time','author','type','article_type.cate_name','status','img','article.sort')

+ 30 - 9
Application/Sports/Controller/Sports.php

@@ -55,7 +55,7 @@ class Sports extends Controller{
                 $matchData = lm($st_competition,'Sports')
                     ->join($st_league,$st_league.'.id',$st_competition.'.lg_id')
                     ->select($st_competition.'.id as match_id')
-                    ->where([[$st_competition.'.status', '<', '2']])
+                    // ->where([[$st_competition.'.status', '<', '2']])
                     ->where([
                         [$st_competition.'.home_team','<>',null],
                         [$st_competition.'.guest_team','<>',null],
@@ -63,7 +63,7 @@ class Sports extends Controller{
                         [$st_competition.'.status','<',2],
                         [$st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)]
                     ])
-                    ->where($st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4))
+                    // ->where($st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4))
                     ->get()
                     ->toArray();
                     // ->count('*');
@@ -75,8 +75,8 @@ class Sports extends Controller{
         $data['match'] = lm($st_competition,"Sports")
             ->join($st_league,$st_league.'.id',$st_competition.'.lg_id')
             ->select($st_competition.'.id as match_id',$st_competition.'.home_team',$st_competition.'.guest_team',$st_competition.'.match_date',$st_competition.'.match_time')
-            ->where([[$st_competition.'.status','<',2]])
-            ->where($st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4))
+            // ->where([[$st_competition.'.status','<',2]])
+            // ->where($st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4))
             ->where($where)
             ->where([
                 [$st_competition.'.home_team','<>',null],
@@ -87,7 +87,7 @@ class Sports extends Controller{
             ])
             ->limit($limit_mt)
             ->get()
-            ->toarray();
+            ->toArray();
 
         //===获取当前赛事是否有赔率,如果没有则去除===
         $data['match'] = $this->commonFunction->Handle_Odds_Null($data['match'],$getModels);
@@ -96,11 +96,12 @@ class Sports extends Controller{
             $data['match'] = $data['match'];
         }
 //        获取正在进行的和未开始联赛
+/*
         $data['league'] = lm($st_competition,"Sports")
             ->join($st_league,$st_league.'.id',$st_competition.'.lg_id')
             ->select($st_league.'.id as lg_id',$st_league.'.name_chinese',$st_competition.'.id as match_id')
-            ->where([[$st_competition.'.status','<',2]])
-            ->where($st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4))
+            // ->where([[$st_competition.'.status','<',2]])
+            // ->where($st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4))
             ->where($where)
             ->where([
                 [$st_competition.'.home_team','<>',null],
@@ -112,7 +113,26 @@ class Sports extends Controller{
             ->limit($limit_lg)
             ->distinct($st_league.'id')
             ->get()
-            ->toarray();
+            ->toArray();
+            */
+
+        $data['league'] = lm($st_league,"Sports")
+            ->join($st_competition,$st_competition.'.lg_id',$st_league.'.id')
+            ->select($st_league.'.id as lg_id',$st_league.'.name_chinese',$st_competition.'.id as match_id')
+            ->where($where)
+            ->where([
+                [$st_competition.'.home_team','<>',null],
+                [$st_competition.'.guest_team','<>',null],
+                [$st_league.'.name_chinese','<>',null],
+                [$st_competition.'.status','<',2],
+                [$st_competition.'.us_time','>',$this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)]
+            ])
+            ->limit($limit_lg)
+            ->distinct($st_league.'id')
+            ->get()
+            ->toArray();
+        //去重
+        $data['league'] = $this->commonFunction->array_unset_tt($data['league'],'lg_id');
 
         //===获取当前赛事是否有赔率,如果没有则去除===
         $data['league'] = $this->commonFunction->Handle_Odds_Null($data['league'],$getModels);
@@ -124,7 +144,7 @@ class Sports extends Controller{
                 $data['league'][$k]['code'] = "qt";
                 $matchData = lm($st_competition,'Sports')
                     ->select($st_competition.'.id as match_id')
-                    ->where([[$st_competition.'.status','<',2]])
+                    // ->where([[$st_competition.'.status','<',2]])
                     ->where('lg_id',$v['lg_id'])
                     ->where($where)
                     ->where([
@@ -139,6 +159,7 @@ class Sports extends Controller{
                 $matchNum = $this->commonFunction->Handle_Odds_Null($matchData,$getModels);
                 $data['league'][$k]['count'] = count($matchNum);
             }
+
         }
         return $data;
     }