xielin 5 年之前
父節點
當前提交
4f5b748ef7
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      app/Repositories/PostRepositories.php

+ 9 - 1
app/Repositories/PostRepositories.php

@@ -648,6 +648,7 @@ class PostRepositories
         $postInfoKey = "post_info_" . $postId;
         $post = PostData::where('post_id', $postId)->first();
         if (!$post) return true;
+        $row = false;
         if (isset($request['behavior_flag']) && $request['behavior_flag'] == 'read') {
             $post->pv += 1;
             $post->pv_real += 1;
@@ -660,6 +661,7 @@ class PostRepositories
                     $this->topic->where('id', $id)->increment('pv');
                 }
             }
+            $row = $post->save();
             Log::debug("帖子:" . $postId . "被阅读,pv +1");
         } elseif (isset($request['behavior_flag']) && $request['behavior_flag'] == 'unlike') {
             //用户不喜欢帖子key
@@ -668,6 +670,7 @@ class PostRepositories
             PostDislike::create(['uid' => $request['target_id'], 'post_id' => $request['post_id']]);
             Redis::sadd($postUnLikeKey, $request['target_id']);
             Redis::HINCRBY($postInfoKey, 'dislike_count', 1);
+            $row = $post->save();
             Log::debug("帖子:" . $postId . "被不喜欢,unlike +1");
         } elseif (isset($request['behavior_flag']) && $request['behavior_flag'] == 'like') {
             //用户点赞帖子
@@ -687,6 +690,7 @@ class PostRepositories
                 Redis::HINCRBY($postInfoKey, 'praise_count', -1);
                 Log::debug("帖子:" . $postId . "被取消点赞,praise_count -1");
             }
+            $row = $post->save();
         } elseif (isset($request['behavior_flag']) && $request['behavior_flag'] == 'comment_like') {
             //用户点赞评论
             $comment = PostComment::where('id', $request['comment_id'])->first();
@@ -702,6 +706,7 @@ class PostRepositories
                 Redis::srem($postLikeKey, $request['target_id'] . '_' . $request['comment_id']);
                 Log::debug("评论:" . $request['comment_id'] . "被取消点赞,like_count -1");
             }
+            $row = $comment->save();
         } elseif (isset($request['behavior_flag']) && $request['behavior_flag'] == 'forward') {
             $post->share_count += 1;
             $post->share_real_count += 1;
@@ -712,10 +717,12 @@ class PostRepositories
             } else {
                 PostShare::create(['uid' => $request['target_id'], 'post_id' => $request['post_id']]);
             }
+            $row = $post->save();
             Log::debug("帖子:" . $postId . "被分享,share_count +1");
         } elseif (isset($request['behavior_flag']) && $request['behavior_flag'] == 'comment') {
             $post->comment_count += 1;
             Redis::HINCRBY($postInfoKey, 'comment_count', 1);
+            $row = $post->save();
             Log::debug("帖子:" . $postId . "被评论,comment_count +1");
         } elseif (isset($request['behavior_flag']) && $request['behavior_flag'] == 'collect') {
             //用户收藏帖子
@@ -735,9 +742,10 @@ class PostRepositories
                 Redis::HINCRBY($postInfoKey, 'collect_count', -1);
                 Log::debug("帖子:" . $postId . "被取消收藏,collect_count -1");
             }
+            $row = $post->save();
         }
         $this->collectPostId($request['post_id']);
-        return $post->save();
+        return $row;
     }
 
     /**