作者 Your Name
@@ -16,6 +16,7 @@ use App\Models\Product\Keyword; @@ -16,6 +16,7 @@ use App\Models\Product\Keyword;
16 use App\Models\Product\Product; 16 use App\Models\Product\Product;
17 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
18 use Illuminate\Console\Command; 18 use Illuminate\Console\Command;
  19 +use Illuminate\Support\Facades\DB;
19 use Illuminate\Support\Facades\Http; 20 use Illuminate\Support\Facades\Http;
20 use Illuminate\Support\Facades\Log; 21 use Illuminate\Support\Facades\Log;
21 22
@@ -87,7 +88,10 @@ class VideoTask extends Command @@ -87,7 +88,10 @@ class VideoTask extends Command
87 continue; 88 continue;
88 } 89 }
89 ProjectServer::useProject($task_project->project_id); 90 ProjectServer::useProject($task_project->project_id);
90 - $keyword = $this->getProjectKeyword($task_project->num); 91 + if(!empty($task_project->keywords)){
  92 + $task_project->keywords = explode(',',trim(',',$task_project->keywords));
  93 + }
  94 + $keyword = $this->getProjectKeyword($task_project->number,$task_project->keywords);
91 // 已经没有需要生成视频的关键词 95 // 已经没有需要生成视频的关键词
92 if (!$keyword) { 96 if (!$keyword) {
93 $task_project->status = KeywordVideoTask::STATUS_CLOSE; 97 $task_project->status = KeywordVideoTask::STATUS_CLOSE;
@@ -95,13 +99,7 @@ class VideoTask extends Command @@ -95,13 +99,7 @@ class VideoTask extends Command
95 continue; 99 continue;
96 } 100 }
97 $logo_bg = $this->getImage($domainInfo); 101 $logo_bg = $this->getImage($domainInfo);
98 - $num = $task_project->num;  
99 foreach ($keyword as $val) { 102 foreach ($keyword as $val) {
100 - if($sub_task_num == 0){  
101 - $task_project->num = $num;  
102 - $task_project->save();  
103 - break;  
104 - }  
105 $log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first(); 103 $log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first();
106 if ($log){ 104 if ($log){
107 continue; 105 continue;
@@ -120,20 +118,14 @@ class VideoTask extends Command @@ -120,20 +118,14 @@ class VideoTask extends Command
120 'created_at' => date('Y-m-d H:i:s'), 118 'created_at' => date('Y-m-d H:i:s'),
121 ]; 119 ];
122 $rs = KeywordVideoTaskLog::insert($array); 120 $rs = KeywordVideoTaskLog::insert($array);
123 - if($rs){  
124 - $num--; 121 + if($rs && ($sub_task_num > 0)){
125 $sub_task_num--; 122 $sub_task_num--;
126 } 123 }
127 } 124 }
128 } 125 }
129 - if($sub_task_num != 0){  
130 - $task_project->num = $num;  
131 - if($num == 0){  
132 $task_project->status = KeywordVideoTask::STATUS_CLOSE; 126 $task_project->status = KeywordVideoTask::STATUS_CLOSE;
133 - }  
134 $task_project->save(); 127 $task_project->save();
135 } 128 }
136 - }  
137 return true; 129 return true;
138 } 130 }
139 131
@@ -182,18 +174,27 @@ class VideoTask extends Command @@ -182,18 +174,27 @@ class VideoTask extends Command
182 * @param $number 174 * @param $number
183 * @return mixed 175 * @return mixed
184 */ 176 */
185 - public function getProjectKeyword($number) 177 + public function getProjectKeyword($number,$keywords = [])
186 { 178 {
187 - $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->pluck('id')->toArray();  
188 - if(count($keyword_arr_id) == 0){  
189 - return []; 179 + if(!empty($keywords)){
  180 + $keyword_id = Keyword::where('video', null)->whereIn("title", $keywords)
  181 + ->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->pluck('id')->toArray();
  182 + if(count($keyword_id) == 0){
  183 + $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')
  184 + ->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();
  185 + }else{
  186 + $keyword_arr_id = Keyword::where('video', null)->whereNotIn("title", $keywords)->where('route', 'not like', '%-tag')
  187 + ->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number - count($keyword_id))->pluck('id')->toArray();
  188 + $keyword_arr_id = array_merge($keyword_id,$keyword_arr_id);
190 } 189 }
191 - if(count($keyword_arr_id) <= $number){  
192 - $keyword_id = array_rand($keyword_arr_id, count($keyword_arr_id));  
193 }else{ 190 }else{
194 - $keyword_id = array_rand($keyword_arr_id, $number); 191 + $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')
  192 + ->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();
  193 + }
  194 + if(count($keyword_arr_id) == 0){
  195 + return [];
195 } 196 }
196 - $keyword = Keyword::whereIn("id", $keyword_id)->get(); 197 + $keyword = Keyword::whereIn("id", $keyword_arr_id)->get();
197 return $keyword; 198 return $keyword;
198 } 199 }
199 200
@@ -100,6 +100,7 @@ class NoticeController extends BaseController @@ -100,6 +100,7 @@ class NoticeController extends BaseController
100 $keyword->video = $video; 100 $keyword->video = $video;
101 $keyword->embed_code = $embed_code; 101 $keyword->embed_code = $embed_code;
102 $keyword->video_thumb = $thumb; 102 $keyword->video_thumb = $thumb;
  103 + $keyword->is_video_keyword = 1;
103 $keyword->save(); 104 $keyword->save();
104 DB::disconnect('custom_mysql'); 105 DB::disconnect('custom_mysql');
105 return 200; 106 return 200;
@@ -9,6 +9,7 @@ use App\Http\Logic\Aside\Project\ProjectLogic; @@ -9,6 +9,7 @@ use App\Http\Logic\Aside\Project\ProjectLogic;
9 use App\Models\Ai\AiPrefix; 9 use App\Models\Ai\AiPrefix;
10 use App\Models\ASide\APublicModel; 10 use App\Models\ASide\APublicModel;
11 use App\Models\Channel\Channel; 11 use App\Models\Channel\Channel;
  12 +use App\Models\Com\KeywordVideoTask;
12 use App\Models\Domain\DomainInfo; 13 use App\Models\Domain\DomainInfo;
13 use App\Models\Manage\ManageHr; 14 use App\Models\Manage\ManageHr;
14 use App\Models\Project\DeployOptimize; 15 use App\Models\Project\DeployOptimize;
@@ -194,6 +195,7 @@ class OptimizeController extends BaseController @@ -194,6 +195,7 @@ class OptimizeController extends BaseController
194 'gl_project_deploy_optimize.design_mid AS design_mid', 195 'gl_project_deploy_optimize.design_mid AS design_mid',
195 'gl_project_deploy_optimize.start_date AS start_date', 196 'gl_project_deploy_optimize.start_date AS start_date',
196 'gl_project_deploy_optimize.backlink AS backlink', 197 'gl_project_deploy_optimize.backlink AS backlink',
  198 + 'gl_project_deploy_optimize.ai_video AS ai_video',
197 'gl_domain_info.amp_status AS amp_status', 199 'gl_domain_info.amp_status AS amp_status',
198 'gl_domain_info.domain AS domain', 200 'gl_domain_info.domain AS domain',
199 ]; 201 ];
@@ -390,4 +392,30 @@ class OptimizeController extends BaseController @@ -390,4 +392,30 @@ class OptimizeController extends BaseController
390 $optimizeModel->edit(['backlink'=>$this->param['backlink']],['project_id'=>$this->param['project_id']]); 392 $optimizeModel->edit(['backlink'=>$this->param['backlink']],['project_id'=>$this->param['project_id']]);
391 $this->response('success'); 393 $this->response('success');
392 } 394 }
  395 +
  396 + /**
  397 + * @remark :开启视频模块
  398 + * @name :setAiVideo
  399 + * @author :lyh
  400 + * @method :post
  401 + * @time :2024/5/30 10:30
  402 + */
  403 + public function setAiVideo(){
  404 + $this->request->validate([
  405 + 'project_id'=>'required',
  406 + 'status'=>'required',
  407 + ],[
  408 + 'project_id.required' => 'project_id不能为空',
  409 + 'status.required' => '状态不能为空',
  410 + ]);
  411 + $keywordVideoModel = new KeywordVideoTask();
  412 + $info = $keywordVideoModel->read(['project_id'=>$this->param['project_id']]);
  413 + if($info === false){
  414 + $this->response('请先创建视频任务,才能开启',Code::SYSTEM_ERROR);
  415 + }
  416 + $keywordVideoModel->edit(['status'=>$this->param['status']],['project_id'=>$this->param['project_id']]);
  417 + $optimizeModel = new DeployOptimize();
  418 + $optimizeModel->edit(['ai_video'=>$this->param['status']],['project_id'=>$this->param['project_id']]);
  419 + $this->response('success');
  420 + }
393 } 421 }
@@ -201,4 +201,26 @@ class KeywordController extends BaseController @@ -201,4 +201,26 @@ class KeywordController extends BaseController
201 } 201 }
202 $this->response('success'); 202 $this->response('success');
203 } 203 }
  204 +
  205 + /**
  206 + * @remark :批量操作关键字是否展示视频
  207 + * @name :batchKeywordIsVideo
  208 + * @author :lyh
  209 + * @method :post
  210 + * @time :2024/5/30 14:29
  211 + */
  212 + public function batchKeywordIsVideo(){
  213 + $this->request->validate([
  214 + 'title'=>['required','array', 'max:500']
  215 + ],[
  216 + 'title.required' => 'title不能为空',
  217 + 'title.array' => 'title为数组',
  218 + 'title.max' => '批量操作不能超过500条数据'
  219 + ]);
  220 + $keywordModel = new Keyword();
  221 + foreach ($this->param['title'] as $v){
  222 + $keywordModel->edit(['is_video_keyword'=>$this->param['is_video_keyword']],['title'=>$v]);
  223 + }
  224 + $this->response('success');
  225 + }
204 } 226 }
@@ -45,10 +45,13 @@ class AyrReleaseLogic extends BaseLogic @@ -45,10 +45,13 @@ class AyrReleaseLogic extends BaseLogic
45 } 45 }
46 $this->param['result_data'] = $res; 46 $this->param['result_data'] = $res;
47 $this->param['platforms'] = json_encode($this->param['platforms']); 47 $this->param['platforms'] = json_encode($this->param['platforms']);
  48 + $info = $this->model->read(['platforms'=>$this->param['platforms'],'operator_id'=>$this->param['operator_id'],'project_id'=>$this->param['project_id'],'title'=>$this->param['title']]);
  49 + if($info === false){
48 $rs = $this->model->add($this->param); 50 $rs = $this->model->add($this->param);
49 if($rs === false){ 51 if($rs === false){
50 $this->fail('error'); 52 $this->fail('error');
51 } 53 }
  54 + }
52 return $this->success(); 55 return $this->success();
53 } 56 }
54 /** 57 /**
@@ -71,14 +71,16 @@ class UpdateLog extends Model @@ -71,14 +71,16 @@ class UpdateLog extends Model
71 */ 71 */
72 public static function getProjectUpdate($project_id) 72 public static function getProjectUpdate($project_id)
73 { 73 {
  74 + $collect_time = '';
74 $collect_un_count = UpdateLog::where('project_id', $project_id)->where('collect_status', 0)->count(); 75 $collect_un_count = UpdateLog::where('project_id', $project_id)->where('collect_status', 0)->count();
75 if ($collect_un_count > 0) { 76 if ($collect_un_count > 0) {
76 $collect_time = '采集中'; 77 $collect_time = '采集中';
77 } else { 78 } else {
78 $collect_info = UpdateLog::where('project_id', $project_id)->orderBy('updated_at', 'desc')->first(); 79 $collect_info = UpdateLog::where('project_id', $project_id)->orderBy('updated_at', 'desc')->first();
  80 + if(!empty($collect_info)){
79 $collect_time = $collect_info->updated_at->format('Y-m-d H:i:s'); 81 $collect_time = $collect_info->updated_at->format('Y-m-d H:i:s');
80 } 82 }
81 - 83 + }
82 return $collect_time; 84 return $collect_time;
83 } 85 }
84 } 86 }
@@ -276,6 +276,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -276,6 +276,7 @@ Route::middleware(['aloginauth'])->group(function () {
276 Route::any('/saveAiPrefix', [Aside\Optimize\OptimizeController::class, 'saveAiPrefix'])->name('admin.optimize_saveAiPrefix');//保存Ai前后缀 276 Route::any('/saveAiPrefix', [Aside\Optimize\OptimizeController::class, 'saveAiPrefix'])->name('admin.optimize_saveAiPrefix');//保存Ai前后缀
277 Route::any('/setRobots', [Aside\Optimize\OptimizeController::class, 'setRobots'])->name('admin.optimize_setRobots');//设置robots开关 277 Route::any('/setRobots', [Aside\Optimize\OptimizeController::class, 'setRobots'])->name('admin.optimize_setRobots');//设置robots开关
278 Route::any('/editBacklink', [Aside\Optimize\OptimizeController::class, 'editBacklink'])->name('admin.optimize_editBacklink');//设置backlink开关 278 Route::any('/editBacklink', [Aside\Optimize\OptimizeController::class, 'editBacklink'])->name('admin.optimize_editBacklink');//设置backlink开关
  279 + Route::any('/setAiVideo', [Aside\Optimize\OptimizeController::class, 'setAiVideo'])->name('admin.optimize_setAiVideo');//设置backlink开关
279 Route::any('/editTranslateStatus', [Aside\Optimize\OptimizeController::class, 'editTranslateStatus'])->name('admin.optimize_editTranslateStatus');//设置robots开关 280 Route::any('/editTranslateStatus', [Aside\Optimize\OptimizeController::class, 'editTranslateStatus'])->name('admin.optimize_editTranslateStatus');//设置robots开关
280 }); 281 });
281 //生成关键字 282 //生成关键字
@@ -266,6 +266,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -266,6 +266,7 @@ Route::middleware(['bloginauth'])->group(function () {
266 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); 266 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
267 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel'); 267 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
268 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); 268 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
  269 + Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
269 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled'); 270 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
270 //产品参数 271 //产品参数
271 Route::get('attr', [\App\Http\Controllers\Bside\Product\AttrController::class, 'index'])->name('product_attr'); 272 Route::get('attr', [\App\Http\Controllers\Bside\Product\AttrController::class, 'index'])->name('product_attr');