浏览代码

社媒对接

moshaorui 19 小时之前
父节点
当前提交
2c4ce6e477
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 2 2
      app/Console/Commands/TimerSsmPost.php
  2. 4 1
      app/Distributor/Repositories/SmmUserAccount.php

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

@@ -145,7 +145,7 @@ class TimerSsmPost extends Command
             try {
                 $expiresAt = Carbon::parse($account->expires_at);
                 //少于15分钟就开始刷新access_token
-                if ($expiresAt->diffInSeconds(Carbon::now()) <= 900) {
+                //if ($expiresAt->diffInSeconds(Carbon::now()) <= 900) {
                     Log::info('开始刷新access_token:'. $account->name);
                     $mediaName = $account->getParent->name;
                     $configData = ['accountInfo' => $account->toArray()];
@@ -162,7 +162,7 @@ class TimerSsmPost extends Command
                     } else {
                         Log::info('access_token 刷新失败:'. $result['data']);
                     }
-                }
+               // }
             } catch (\Exception $e) {
                 Log::info('access_token 刷新失败:'. $account->name.$e->getMessage());
             }

+ 4 - 1
app/Distributor/Repositories/SmmUserAccount.php

@@ -90,7 +90,10 @@ class SmmUserAccount extends EloquentRepository
         $youTube = $model->where('name', 'YouTube')->first();
         $twitter = $model->where('name', 'Twitter')->first();
         $parentIds = [$youTube->id,$twitter->id];
-        $accounts = $model->whereIn('parent_id',$parentIds)->where('expires_at','>', Carbon::now())->orderBy('id', 'asc')->get();
+        //15分钟前
+        $time = Carbon::now()->addMinutes(15);
+        $accounts = $model->whereIn('parent_id',$parentIds)->where('expires_at','<', $time)->where('expires_at','>', Carbon::now())->orderBy('id', 'asc')->get();
+        //dd($accounts->toArray());
         return $accounts;
     }