作者 Your Name
... ... @@ -16,6 +16,7 @@ use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
... ... @@ -87,7 +88,10 @@ class VideoTask extends Command
continue;
}
ProjectServer::useProject($task_project->project_id);
$keyword = $this->getProjectKeyword($task_project->num);
if(!empty($task_project->keywords)){
$task_project->keywords = explode(',',trim(',',$task_project->keywords));
}
$keyword = $this->getProjectKeyword($task_project->number,$task_project->keywords);
// 已经没有需要生成视频的关键词
if (!$keyword) {
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
... ... @@ -95,13 +99,7 @@ class VideoTask extends Command
continue;
}
$logo_bg = $this->getImage($domainInfo);
$num = $task_project->num;
foreach ($keyword as $val) {
if($sub_task_num == 0){
$task_project->num = $num;
$task_project->save();
break;
}
$log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first();
if ($log){
continue;
... ... @@ -120,20 +118,14 @@ class VideoTask extends Command
'created_at' => date('Y-m-d H:i:s'),
];
$rs = KeywordVideoTaskLog::insert($array);
if($rs){
$num--;
if($rs && ($sub_task_num > 0)){
$sub_task_num--;
}
}
}
if($sub_task_num != 0){
$task_project->num = $num;
if($num == 0){
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
}
$task_project->save();
}
}
return true;
}
... ... @@ -182,18 +174,27 @@ class VideoTask extends Command
* @param $number
* @return mixed
*/
public function getProjectKeyword($number)
public function getProjectKeyword($number,$keywords = [])
{
$keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->pluck('id')->toArray();
if(count($keyword_arr_id) == 0){
return [];
if(!empty($keywords)){
$keyword_id = Keyword::where('video', null)->whereIn("title", $keywords)
->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->pluck('id')->toArray();
if(count($keyword_id) == 0){
$keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')
->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();
}else{
$keyword_arr_id = Keyword::where('video', null)->whereNotIn("title", $keywords)->where('route', 'not like', '%-tag')
->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number - count($keyword_id))->pluck('id')->toArray();
$keyword_arr_id = array_merge($keyword_id,$keyword_arr_id);
}
if(count($keyword_arr_id) <= $number){
$keyword_id = array_rand($keyword_arr_id, count($keyword_arr_id));
}else{
$keyword_id = array_rand($keyword_arr_id, $number);
$keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')
->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();
}
if(count($keyword_arr_id) == 0){
return [];
}
$keyword = Keyword::whereIn("id", $keyword_id)->get();
$keyword = Keyword::whereIn("id", $keyword_arr_id)->get();
return $keyword;
}
... ...
... ... @@ -100,6 +100,7 @@ class NoticeController extends BaseController
$keyword->video = $video;
$keyword->embed_code = $embed_code;
$keyword->video_thumb = $thumb;
$keyword->is_video_keyword = 1;
$keyword->save();
DB::disconnect('custom_mysql');
return 200;
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Ai\AiPrefix;
use App\Models\ASide\APublicModel;
use App\Models\Channel\Channel;
use App\Models\Com\KeywordVideoTask;
use App\Models\Domain\DomainInfo;
use App\Models\Manage\ManageHr;
use App\Models\Project\DeployOptimize;
... ... @@ -194,6 +195,7 @@ class OptimizeController extends BaseController
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.start_date AS start_date',
'gl_project_deploy_optimize.backlink AS backlink',
'gl_project_deploy_optimize.ai_video AS ai_video',
'gl_domain_info.amp_status AS amp_status',
'gl_domain_info.domain AS domain',
];
... ... @@ -390,4 +392,30 @@ class OptimizeController extends BaseController
$optimizeModel->edit(['backlink'=>$this->param['backlink']],['project_id'=>$this->param['project_id']]);
$this->response('success');
}
/**
* @remark :开启视频模块
* @name :setAiVideo
* @author :lyh
* @method :post
* @time :2024/5/30 10:30
*/
public function setAiVideo(){
$this->request->validate([
'project_id'=>'required',
'status'=>'required',
],[
'project_id.required' => 'project_id不能为空',
'status.required' => '状态不能为空',
]);
$keywordVideoModel = new KeywordVideoTask();
$info = $keywordVideoModel->read(['project_id'=>$this->param['project_id']]);
if($info === false){
$this->response('请先创建视频任务,才能开启',Code::SYSTEM_ERROR);
}
$keywordVideoModel->edit(['status'=>$this->param['status']],['project_id'=>$this->param['project_id']]);
$optimizeModel = new DeployOptimize();
$optimizeModel->edit(['ai_video'=>$this->param['status']],['project_id'=>$this->param['project_id']]);
$this->response('success');
}
}
... ...
... ... @@ -201,4 +201,26 @@ class KeywordController extends BaseController
}
$this->response('success');
}
/**
* @remark :批量操作关键字是否展示视频
* @name :batchKeywordIsVideo
* @author :lyh
* @method :post
* @time :2024/5/30 14:29
*/
public function batchKeywordIsVideo(){
$this->request->validate([
'title'=>['required','array', 'max:500']
],[
'title.required' => 'title不能为空',
'title.array' => 'title为数组',
'title.max' => '批量操作不能超过500条数据'
]);
$keywordModel = new Keyword();
foreach ($this->param['title'] as $v){
$keywordModel->edit(['is_video_keyword'=>$this->param['is_video_keyword']],['title'=>$v]);
}
$this->response('success');
}
}
... ...
... ... @@ -45,10 +45,13 @@ class AyrReleaseLogic extends BaseLogic
}
$this->param['result_data'] = $res;
$this->param['platforms'] = json_encode($this->param['platforms']);
$info = $this->model->read(['platforms'=>$this->param['platforms'],'operator_id'=>$this->param['operator_id'],'project_id'=>$this->param['project_id'],'title'=>$this->param['title']]);
if($info === false){
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
}
}
return $this->success();
}
/**
... ...
... ... @@ -71,14 +71,16 @@ class UpdateLog extends Model
*/
public static function getProjectUpdate($project_id)
{
$collect_time = '';
$collect_un_count = UpdateLog::where('project_id', $project_id)->where('collect_status', 0)->count();
if ($collect_un_count > 0) {
$collect_time = '采集中';
} else {
$collect_info = UpdateLog::where('project_id', $project_id)->orderBy('updated_at', 'desc')->first();
if(!empty($collect_info)){
$collect_time = $collect_info->updated_at->format('Y-m-d H:i:s');
}
}
return $collect_time;
}
}
... ...
... ... @@ -276,6 +276,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/saveAiPrefix', [Aside\Optimize\OptimizeController::class, 'saveAiPrefix'])->name('admin.optimize_saveAiPrefix');//保存Ai前后缀
Route::any('/setRobots', [Aside\Optimize\OptimizeController::class, 'setRobots'])->name('admin.optimize_setRobots');//设置robots开关
Route::any('/editBacklink', [Aside\Optimize\OptimizeController::class, 'editBacklink'])->name('admin.optimize_editBacklink');//设置backlink开关
Route::any('/setAiVideo', [Aside\Optimize\OptimizeController::class, 'setAiVideo'])->name('admin.optimize_setAiVideo');//设置backlink开关
Route::any('/editTranslateStatus', [Aside\Optimize\OptimizeController::class, 'editTranslateStatus'])->name('admin.optimize_editTranslateStatus');//设置robots开关
});
//生成关键字
... ...
... ... @@ -266,6 +266,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
//产品参数
Route::get('attr', [\App\Http\Controllers\Bside\Product\AttrController::class, 'index'])->name('product_attr');
... ...