Explorar el Código

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/community-manage into develop

xielin hace 5 años
padre
commit
045040f943

+ 8 - 1
app/Console/Commands/UpdateReplyCount.php

@@ -48,7 +48,14 @@ class UpdateReplyCount extends Command
     {
         $this->line("开始更新评论回复数量");
 
-        $bar = $this->output->createProgressBar($this->postComment->where('parent_id', 0)->count());
+        $bar = $this->output->createProgressBar($this->postComment->where('parent_id', 0)->count()+1000);
+
+        for($i=1;$i<1000;$i++){
+            Redis::del('post_new_comment_'.$i);
+            Redis::del('post_new_reply_'.$i);
+            $bar->advance();
+        }
+
         $this->postComment->where('parent_id', 0)->chunk(100, function($comments) use ($bar){
             foreach($comments as $comment){
                 $replyCount = $this->postComment->where('parent_id', $comment->id)->count();

+ 13 - 13
app/Repositories/Post/PostRepository.php

@@ -444,18 +444,18 @@ class PostRepository
         }
         DB::beginTransaction();
         try {
-            $comment = $this->postComment->create($data);
+            $newComment = $this->postComment->create($data);
 
-            if($comment->parent_id){
-                $this->postComment->where('id', $comment->parent_id)->increment('reply_count');
+            if($newComment->parent_id){
+                $this->postComment->where('id', $newComment->parent_id)->increment('reply_count');
             }
 
             DB::commit();
 
-            if(!$comment->parent_id){
-                Redis::DEL('post_new_comment_'.$comment->post_id);
+            if($newComment->parent_id){
+                Redis::DEL('post_new_reply_'.$newComment->parent_id);
             }else{
-                Redis::DEL('post_new_reply_'.$comment->id);
+                Redis::DEL('post_new_comment_'.$newComment->post_id);
             }
             $virus = $this->behavior->where('behavior_identification', 'comment')->first();
             if ($virus) {
@@ -472,16 +472,16 @@ class PostRepository
                     'post_author_uid' => $post->uid,
                     'post_desc' => $desc,
                     'post_cover' => $post->img,
-                    'comment_id' => $comment->id,
-                    'comment_content' => $comment->content,
-                    'parent_comment_id' => $comment->parent_id,
+                    'comment_id' => $newComment->id,
+                    'comment_content' => $newComment->content,
+                    'parent_comment_id' => $newComment->parent_id,
                     'parent_comment_content' => $parentCommentContent,
                     'parent_comment_uid' => $parentCommentUid,
                     'parent_comment_time' => $parentCommentTime,
-                    'reply_uid' => $comment->reply_uid,
-                    'reply_username' => $comment->reply_username,
-                    'target_id' => $comment->uid,
-                    'action_id' => $comment->id,
+                    'reply_uid' => $newComment->reply_uid,
+                    'reply_username' => $newComment->reply_username,
+                    'target_id' => $newComment->uid,
+                    'action_id' => $newComment->id,
                 ]);
             }
             return Response::create();