|
@@ -4,6 +4,7 @@ namespace App\Distributor\Controllers;
|
|
|
|
|
|
use App\Admin\Repositories\BaseProductImage;
|
|
use App\Admin\Repositories\BaseProductImage;
|
|
use App\Distributor\Repositories\SmmPost;
|
|
use App\Distributor\Repositories\SmmPost;
|
|
|
|
+use App\Distributor\Repositories\SmmPostLog;
|
|
use App\Distributor\Repositories\SmmUserAccount;
|
|
use App\Distributor\Repositories\SmmUserAccount;
|
|
use App\Services\SmmService;
|
|
use App\Services\SmmService;
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
@@ -17,6 +18,7 @@ use Dcat\Admin\Admin;
|
|
use Dcat\Admin\FormStep\Form as StepForm;
|
|
use Dcat\Admin\FormStep\Form as StepForm;
|
|
use Dcat\Admin\Traits\HasUploadedFile;
|
|
use Dcat\Admin\Traits\HasUploadedFile;
|
|
use Dcat\Admin\Widgets\Alert;
|
|
use Dcat\Admin\Widgets\Alert;
|
|
|
|
+use App\Console\Commands\TimerSsmPost;
|
|
|
|
|
|
class SmmPostController extends AdminDistController
|
|
class SmmPostController extends AdminDistController
|
|
{
|
|
{
|
|
@@ -27,12 +29,8 @@ class SmmPostController extends AdminDistController
|
|
*/
|
|
*/
|
|
public function index(Content $content)
|
|
public function index(Content $content)
|
|
{
|
|
{
|
|
-// $ssmService = new SmmService('youtube');
|
|
|
|
-// $videoCategories = $ssmService->getVideoCategories();
|
|
|
|
-// var_dump($videoCategories['data']);
|
|
|
|
-// exit;
|
|
|
|
return $content
|
|
return $content
|
|
- ->header('发报帖子')
|
|
|
|
|
|
+ ->header(admin_trans_label('send_post'))
|
|
->body($this->form());
|
|
->body($this->form());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -61,8 +59,9 @@ class SmmPostController extends AdminDistController
|
|
->autoUpload() // 自动上传
|
|
->autoUpload() // 自动上传
|
|
->uniqueName()
|
|
->uniqueName()
|
|
->limit(4)
|
|
->limit(4)
|
|
- ->accept(config('admin.upload.oss_image.accept'))
|
|
|
|
- ->maxSize(config('admin.upload.oss_image.max_size'));
|
|
|
|
|
|
+ ->accept('jpg,png')
|
|
|
|
+ ->help('图片格式jpg,png,不大于3M')
|
|
|
|
+ ->maxSize(3072);
|
|
})
|
|
})
|
|
->when([1], function ($step) {
|
|
->when([1], function ($step) {
|
|
$step->textarea('video_message', '<span style="color:#bd4147;">*</span> '.admin_trans_label('post_message'))->rows(3)->placeholder(' ');
|
|
$step->textarea('video_message', '<span style="color:#bd4147;">*</span> '.admin_trans_label('post_message'))->rows(3)->placeholder(' ');
|
|
@@ -70,8 +69,8 @@ class SmmPostController extends AdminDistController
|
|
->uniqueName()
|
|
->uniqueName()
|
|
->autoUpload()
|
|
->autoUpload()
|
|
->accept(config('admin.upload.oss_video.accept'))
|
|
->accept(config('admin.upload.oss_video.accept'))
|
|
- ->maxSize(config('admin.upload.oss_video.max_size'))
|
|
|
|
- ->chunkSize(1024);
|
|
|
|
|
|
+ ->maxSize(120400)
|
|
|
|
+ ->removable();
|
|
})
|
|
})
|
|
->options([ 0=>admin_trans_label('images'), 1=>admin_trans_label('videos')])->default(0);
|
|
->options([ 0=>admin_trans_label('images'), 1=>admin_trans_label('videos')])->default(0);
|
|
$this->stepLeaving($step,0);
|
|
$this->stepLeaving($step,0);
|
|
@@ -80,7 +79,10 @@ class SmmPostController extends AdminDistController
|
|
$rootAccounts = SmmUserAccount::getUserAccounts();
|
|
$rootAccounts = SmmUserAccount::getUserAccounts();
|
|
$listBoxOptions = [];
|
|
$listBoxOptions = [];
|
|
foreach ($rootAccounts as $account) {
|
|
foreach ($rootAccounts as $account) {
|
|
- $listBoxOptions[$account->id] = $account->name . ' ('.$account->getParent->name.')';
|
|
|
|
|
|
+ if (SmmPostLog::getPostQuota($account->getParent->name) > 0) {
|
|
|
|
+ //限额大于0才显示
|
|
|
|
+ $listBoxOptions[$account->id] = $account->name . ' ('.$account->getParent->name.')';
|
|
|
|
+ }
|
|
}
|
|
}
|
|
$step->listbox('account_ids', '<span style="color:#bd4147;">*</span> '.admin_trans_label('accountsSelect'))
|
|
$step->listbox('account_ids', '<span style="color:#bd4147;">*</span> '.admin_trans_label('accountsSelect'))
|
|
->options($listBoxOptions);
|
|
->options($listBoxOptions);
|
|
@@ -96,6 +98,12 @@ class SmmPostController extends AdminDistController
|
|
*/
|
|
*/
|
|
public function store() {
|
|
public function store() {
|
|
$post = $_POST;
|
|
$post = $_POST;
|
|
|
|
+ if (isset($post['_file_del_'])) {
|
|
|
|
+ // 删除上传的文件
|
|
|
|
+ header('Content-Type: application/json');
|
|
|
|
+ echo json_encode(['status' => true, 'data' => []]);
|
|
|
|
+ exit;
|
|
|
|
+ }
|
|
if (isset($post['upload_column']) && ($post['upload_column'] == 'image_url' || $post['upload_column'] == 'video_url')) {
|
|
if (isset($post['upload_column']) && ($post['upload_column'] == 'image_url' || $post['upload_column'] == 'video_url')) {
|
|
// 上传图片或视频
|
|
// 上传图片或视频
|
|
return $this->upload();
|
|
return $this->upload();
|
|
@@ -120,6 +128,9 @@ class SmmPostController extends AdminDistController
|
|
}
|
|
}
|
|
//保存数据
|
|
//保存数据
|
|
SmmPost::create($post,$send_time,$image_video_url);
|
|
SmmPost::create($post,$send_time,$image_video_url);
|
|
|
|
+ // 生成发送记录
|
|
|
|
+ $timer = new TimerSsmPost();
|
|
|
|
+ $timer->createLog();
|
|
//最后一步
|
|
//最后一步
|
|
$data = [
|
|
$data = [
|
|
'title' => '操作成功',
|
|
'title' => '操作成功',
|
|
@@ -134,20 +145,25 @@ class SmmPostController extends AdminDistController
|
|
* 上传图片到本地
|
|
* 上传图片到本地
|
|
*/
|
|
*/
|
|
public function upload() {
|
|
public function upload() {
|
|
- // 获取上传的文件
|
|
|
|
- $file = $this->file();
|
|
|
|
- $dir = 'ssm/'.getDistributorId();
|
|
|
|
- $newName = md5(uniqid() . mt_rand()) .'.'.$file->getClientOriginalExtension();
|
|
|
|
- //保存到本地
|
|
|
|
- $disk = $this->disk('local');
|
|
|
|
- $result = $disk->putFileAs($dir, $file, $newName);
|
|
|
|
|
|
+ try {
|
|
|
|
+ // 获取上传的文件
|
|
|
|
+ $file = $this->file();
|
|
|
|
+ $dir = 'ssm/'.getDistributorId();
|
|
|
|
+ $newName = md5(uniqid() . mt_rand()) .'.'.$file->getClientOriginalExtension();
|
|
|
|
+ //保存到本地
|
|
|
|
+ $disk = $this->disk('local');
|
|
|
|
+ $result = $disk->putFileAs($dir, $file, $newName);
|
|
|
|
+
|
|
|
|
+ //oss 保存
|
|
|
|
+ $disk = $this->disk('oss');
|
|
|
|
+ $result = $disk->putFileAs($dir, $file, $newName);
|
|
|
|
|
|
- //oss 保存
|
|
|
|
- $disk = $this->disk('oss');
|
|
|
|
- $result = $disk->putFileAs($dir, $file, $newName);
|
|
|
|
- return $result
|
|
|
|
- ? $this->responseUploaded($result, $disk->url($result))
|
|
|
|
- : $this->responseErrorMessage(admin_trans_label('upload_failed'));
|
|
|
|
|
|
+ return $result
|
|
|
|
+ ? $this->responseUploaded($result, $disk->url($result))
|
|
|
|
+ : $this->responseErrorMessage(admin_trans_label('upload_failed'));
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ return $this->responseErrorMessage($e->getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -261,6 +277,7 @@ let intervalId = setInterval(() => {
|
|
checkYouTubeOption(select);
|
|
checkYouTubeOption(select);
|
|
}
|
|
}
|
|
}, 300);
|
|
}, 300);
|
|
|
|
+
|
|
JS
|
|
JS
|
|
);
|
|
);
|
|
|
|
|