moshaorui 1 napja
szülő
commit
302e0960c2

+ 4 - 2
app/Console/Commands/TimerSsmPost.php

@@ -46,6 +46,8 @@ class TimerSsmPost extends Command
             Log::info('开始刷新access_token');
             $this->refreshAccessToken();
 
+
+
             //发送社媒帖子开始
             Log::info('开始发送社媒帖子');
             $sendLog = SmmPostLog::getSendLog(5);
@@ -158,10 +160,10 @@ class TimerSsmPost extends Command
             $accountIds = explode(',', $post->account_ids);
             $accounts = SmmUserAccount::getAccountsByIds($accountIds);
             foreach ($accounts as $account) {
-                $send_time = $post->send_time;
+                $send_time = Carbon::now();
                 // 如果是Twitter,15分钟内只能发一个帖
                 if ($account->getParent->name == 'Twitter') {
-                    $send_time = SmmPostLog::getTwitterSendTime($send_time);
+                    $send_time = SmmPostLog::getTwitterSendTime();
                 }
                 //生成post_logs表数据
                 $data = [

+ 7 - 9
app/Distributor/Repositories/SmmPostLog.php

@@ -88,30 +88,28 @@ class SmmPostLog extends EloquentRepository
     /*
      * 返回Twitter可以发送的时间
      */
-    public static function getTwitterSendTime($sendTime)
+    public static function getTwitterSendTime()
     {
         // 将字符串转换为Carbon实例
-        $sendTimeCarbon = Carbon::parse($sendTime);
+        $sendTimeCarbon = Carbon::now();
 
         $log = new Model();
         $query = $log->where('status', 0)
             ->where('media_name', 'Twitter')
-            ->whereBetween('send_time', [
-                $sendTimeCarbon->copy()->subMinutes(15),
-                $sendTimeCarbon
-            ])
-            ->orderByDesc('send_time')
+            ->where('send_time', '>=',$sendTimeCarbon->copy()->subMinutes(15))
+            ->orderByDesc('id')
             ->first();
 
         if ($query) {
             // 返回格式化的时间字符串(与原输入格式保持一致)
             $query_send_time = Carbon::parse($query->send_time);
             return $query_send_time
-                ->addMinutes(15)
+                ->addMinutes(16)
                 ->toDateTimeString();
         }
+
         // 没有记录时返回原始字符串
-        return $sendTime;
+        return Carbon::now();
     }
 
     /*