|
@@ -8,6 +8,7 @@ use App\Distributor\Repositories\SmmUserAccount;
|
|
use App\Libraries\CommonHelper;
|
|
use App\Libraries\CommonHelper;
|
|
use App\Services\SmmService;
|
|
use App\Services\SmmService;
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
|
|
+use Dcat\Admin\Traits\HasUploadedFile;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
@@ -35,6 +36,8 @@ class TimerSsmPost extends Command
|
|
protected $description = '发送社媒帖子';
|
|
protected $description = '发送社媒帖子';
|
|
|
|
|
|
|
|
|
|
|
|
+ use HasUploadedFile;
|
|
|
|
+
|
|
public function handle()
|
|
public function handle()
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
@@ -42,6 +45,10 @@ class TimerSsmPost extends Command
|
|
Log::info('开始生成发送帖子日志');
|
|
Log::info('开始生成发送帖子日志');
|
|
$this->createLog();
|
|
$this->createLog();
|
|
|
|
|
|
|
|
+ //上传图片到oss
|
|
|
|
+ Log::info('开始上传图片到oss');
|
|
|
|
+ $this->ossUpload();
|
|
|
|
+
|
|
//刷新access_token
|
|
//刷新access_token
|
|
Log::info('开始刷新access_token');
|
|
Log::info('开始刷新access_token');
|
|
$this->refreshAccessToken();
|
|
$this->refreshAccessToken();
|
|
@@ -49,6 +56,9 @@ class TimerSsmPost extends Command
|
|
//发送社媒帖子开始
|
|
//发送社媒帖子开始
|
|
Log::info('开始发送社媒帖子');
|
|
Log::info('开始发送社媒帖子');
|
|
$sendLog = SmmPostLog::getSendLog(5);
|
|
$sendLog = SmmPostLog::getSendLog(5);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
$logIds = [];
|
|
$logIds = [];
|
|
foreach ($sendLog as $log) {
|
|
foreach ($sendLog as $log) {
|
|
Log::info('开始发送社媒帖子,id:'. $log->id);
|
|
Log::info('开始发送社媒帖子,id:'. $log->id);
|
|
@@ -195,4 +205,27 @@ class TimerSsmPost extends Command
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ public function ossUpload()
|
|
|
|
+ {
|
|
|
|
+ // 发送社媒帖子
|
|
|
|
+ $disk = $this->disk('oss');
|
|
|
|
+ $ossUploadPost = SmmPost::getOssUploadPost();
|
|
|
|
+ foreach ($ossUploadPost as $post) {
|
|
|
|
+ //上传图片到oss
|
|
|
|
+ $imageVideoUrl = explode(',', $post->image_video_url);
|
|
|
|
+ foreach ($imageVideoUrl as $key => $url) {
|
|
|
|
+ $localPath = toStoragePath($url);
|
|
|
|
+ $filename = basename($url);
|
|
|
|
+ $dir = dirname($url);
|
|
|
|
+ $disk->putFileAs($dir, $localPath, $filename);
|
|
|
|
+ }
|
|
|
|
+ $post->oss_upload = 1;
|
|
|
|
+ $post->save();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|