xielin пре 5 година
родитељ
комит
5b577295ed
2 измењених фајлова са 2 додато и 2 уклоњено
  1. 1 0
      app/Console/Commands/PostStatistics.php
  2. 1 2
      app/Repositories/Post/PostRepository.php

+ 1 - 0
app/Console/Commands/PostStatistics.php

@@ -137,6 +137,7 @@ class PostStatistics extends Command
         $data['like_count'] = $likeCount;
         $data['collect_count'] = $collectCount;
         $data['comment_count'] = $commentCount;
+        $data['created_at'] = $yesterdayStart;
         $this->postStatistics->create($data);
         Log::info(date('Y-m-d H:i:s').'统计'.$yesterdayStart.'最终记录数据:'.json_encode($data));
     }

+ 1 - 2
app/Repositories/Post/PostRepository.php

@@ -925,8 +925,7 @@ class PostRepository
                 'comment' => 0,
             ];
             foreach ($result as $row) {
-                //-86400 因为每天零点以后统计昨天
-                if ($value == date('Y-m-d', strtotime($row['created_at']) - 86400)) {
+                if ($value == date('Y-m-d', strtotime($row['created_at']))) {
                     $info[$value]['read'] = $row['read_count'];
                     $info[$value]['post'] = $row['post_count'];
                     $info[$value]['share'] = $row['share_count'];