Explorar o código

添加个人中心 -消息通知接口

彭俊 %!s(int64=6) %!d(string=hai) anos
pai
achega
47aa96b740

+ 2 - 2
Application/Api/Controller/BaseController.php

@@ -15,12 +15,12 @@ class BaseController extends Controller
 {
 {
     public function init()
     public function init()
     {
     {
-        // lm('user_logs', 'commons')->initVisitor();
         if (isCheckToken()) {
         if (isCheckToken()) {
             $token = isset($_GET['token']) && !empty($_GET['token']) ? trim($_GET['token']) : '';
             $token = isset($_GET['token']) && !empty($_GET['token']) ? trim($_GET['token']) : '';
             if (empty($token)) {
             if (empty($token)) {
                 Render('5555', '-4010', lang('errors')->get('-4010'));
                 Render('5555', '-4010', lang('errors')->get('-4010'));
             }
             }
+
             $re = C()->get('user')->refreshStatus($token);
             $re = C()->get('user')->refreshStatus($token);
             if ($re < 0) {
             if ($re < 0) {
                 Render('', $re, lang('errors')->get($re));
                 Render('', $re, lang('errors')->get($re));
@@ -36,7 +36,7 @@ class BaseController extends Controller
         $setTime = lm('Setinfo', 'Commons')->getType(1912);
         $setTime = lm('Setinfo', 'Commons')->getType(1912);
         if (empty($setTime)) {
         if (empty($setTime)) {
             return;
             return;
-            // $setTime = date('Y-m-d H:i:s');
+            // $setTime = date('Y-m-d H:i:s');`
         }
         }
         if (C()->get('cache')->has('systenLastUpdateTime')) {
         if (C()->get('cache')->has('systenLastUpdateTime')) {
             $lastTime = C()->get('cache')->get('systenLastUpdateTime');
             $lastTime = C()->get('cache')->get('systenLastUpdateTime');

+ 39 - 0
Application/Api/Model/AccountNews.php

@@ -59,4 +59,43 @@ class AccountNews extends Model {
 
 
         return $result;
         return $result;
     }
     }
+
+
+    //获取用户投注相关消息通知
+    public static function getUserNews($userInfo){
+       
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $accountNewsWhere['account_identity'] = $userInfo['identity'];
+        // 查询条件
+        if (!empty($_POST['read_status'])) {
+            $accountNewsWhere['read_status'] = $_POST['read_status'];
+        }
+        if (!empty($_POST['type'])) {
+            $accountNewsWhere['type'] = $_POST['type'];
+        }
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $accountNewsBetween = ['write_time' => [$startTime, $endTime]];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        $accountNewsMdl = lm('account_news', "commons");
+        // 获取消息
+        $accountNewsSlt = ['title', 'identity', 'content', 'details', 'write_time', 'read_status', 'type'];
+        $getMoneyBuyStr = $accountNewsMdl -> accountNews($accountNewsSlt, $accountNewsWhere, $accountNewsBetween, $begin, $pageSize, 1);
+        // 获取消息总数
+        $result['total'] = $accountNewsMdl -> accountNewsTotal($accountNewsWhere, $accountNewsBetween);
+        $result['list'] = $getMoneyBuyStr;
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
 }
 }

+ 25 - 0
Application/Api/Model/Article.php

@@ -11,4 +11,29 @@ use \System\Model;
 class Article extends Model {
 class Article extends Model {
 
 
 	protected $table = 'article';
 	protected $table = 'article';
+
+	//获取系统通知数据
+	public static function getArticle($userInfo){
+		if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+		}
+		
+		$where = [];
+		$where[] = ['status','=',1];
+		// $where[] = ['time','>',date("Y-m-d H:i:s",strtotime('-1 week'))];
+		
+		if (!empty($_POST['type'])) {
+            $where[] = ['type','=',$_POST['type']];
+        }
+        
+		$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')
+		->where($where)
+		->limit(5)
+		->get()
+		->toArray();
+
+        return $data;
+	}
 }
 }