Explorar o código

互动消息-评论和获赞

lizhen_gitee hai 1 ano
pai
achega
f9780bba7e

+ 49 - 0
application/api/controller/Topicdongtai.php

@@ -167,6 +167,7 @@ class Topicdongtai extends Api
         }
 
         Db::startTrans();
+        $where['createtime'] = time();
         $rs = Db::name('topic_dongtai_good')->insertGetId($where);
         $up = Db::name('topic_dongtai')->where('id',$id)->setInc('goodnum');
 
@@ -255,6 +256,7 @@ class Topicdongtai extends Api
         }
 
         Db::startTrans();
+        $where['createtime'] = time();
         $rs = Db::name('topic_answer_good')->insertGetId($where);
         $up = Db::name('topic_dongtai_answer')->where('id',$answer_id)->setInc('goodnum');
 
@@ -447,6 +449,53 @@ class Topicdongtai extends Api
         $this->success('success',$list);
     }
 
+    ////////////////////////////////////////////////////////////
+
+    //消息-互动消息-评论
+    //谁评论了我
+    public function msg_answer(){
+        $map = [
+            'dt.user_id' => $this->auth->id,
+            'a.level'    => 1,
+        ];
+        $list = Db::name('topic_dongtai_answer')->alias('a')
+            ->field('a.id,a.createtime,user.nickname,user.gender,user.avatar')
+            ->join('topic_dongtai dt','a.dt_id = dt.id','LEFT')
+            ->join('user','a.user_id = user.id','LEFT')
+            ->where($map)->order('a.id desc')->autopage()->select();
+        $list = list_domain_image($list,['avatar']);
+        if(!empty($list)){
+            foreach($list as $key => &$val){
+                //时间
+                $val['createtime_text'] = get_last_time($val['createtime']);
+            }
+        }
+
+        $this->success(1,$list);
+    }
+
+
+    //消息-互动消息-获赞
+    //谁赞了我
+    public function msg_good(){
+        $map = [
+            'dt.user_id' => $this->auth->id,
+        ];
+        $list = Db::name('topic_dongtai_good')->alias('g')
+            ->field('g.id,g.createtime,user.nickname,user.gender,user.avatar')
+            ->join('topic_dongtai dt','g.dt_id = dt.id','LEFT')
+            ->join('user','g.user_id = user.id','LEFT')
+            ->where($map)->order('g.id desc')->autopage()->select();
+        $list = list_domain_image($list,['avatar']);
+        if(!empty($list)){
+            foreach($list as $key => &$val){
+                //时间
+                $val['createtime_text'] = get_last_time($val['createtime']);
+            }
+        }
+
+        $this->success(1,$list);
+    }
 
 
 }

+ 3 - 3
application/api/controller/Usercenter.php

@@ -53,12 +53,12 @@ class UserCenter extends Common
         // 获取关注信息
         $where = [];
         $where["user_id"] = $user_id;
-        $userCount = $followModel->where($where)->value("follows");
+        $userCount = $followModel->where($where)->value("follows"); //该用户关注了几个人
+        $userInfo["follows_count"] = $userCount?$userCount:0;
         // 获取粉丝数
         $where = [];
         $where["user_id"] = $user_id;
-        $fansCount = $fansModel->where($where)->value("fans");
-        $userInfo["follows_count"] = $userCount?$userCount:0;
+        $fansCount = $fansModel->where($where)->value("fans"); //该用户的粉丝数
         $userInfo["fans_count"] = $fansCount?$fansCount:0;
         // 获取贵族信息
         $nobleInfo = $this->userModel->getUserNobleInfo($user_id);