diff --git a/app/Http/Controllers/ExecController.php b/app/Http/Controllers/ExecController.php index 7829d9d..7c365df 100755 --- a/app/Http/Controllers/ExecController.php +++ b/app/Http/Controllers/ExecController.php @@ -183,20 +183,29 @@ class ExecController extends Controller } // 自动点赞 @cron - public function likeAuto () + public function likeAuto() { echo "\n#start# like auto \n"; + $iRand = rand(0, 3); - -// if ($iRand === 1) { - - $r = ArticleList::where('code', date('Ymd')) - ->increment('like', $iRand); - - echo $r; - -// } - echo '\n'; + + if ($iRand > 0) { + $article = ArticleList::where('code', date('Ymd'))->first(); + + if ($article) { + // 使用 updateQuietly 避免触发 updated_at + $article->updateQuietly([ + 'like' => $article->like + $iRand + ]); + + echo "like +{$iRand}\n"; + } else { + echo "no article found\n"; + } + } else { + echo "skip, rand=0\n"; + } + echo "#end# like auto \n"; }