作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -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
@@ -33,11 +33,16 @@ class SyncFile extends Command @@ -33,11 +33,16 @@ class SyncFile extends Command
33 $errorFileModel = new ErrorFile(); 33 $errorFileModel = new ErrorFile();
34 $lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件 34 $lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件
35 foreach ($lists as $k => $v){ 35 foreach ($lists as $k => $v){
  36 + if(strpos($v['path'], '/181/') !== false ){
  37 + $code = $this->synchronizationFiles($v['path']);
  38 + }else{
36 $code = $this->synchronizationFile($v['path']); 39 $code = $this->synchronizationFile($v['path']);
  40 + }
37 if((int)$code == 200){ 41 if((int)$code == 200){
38 echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL; 42 echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
39 $errorFileModel->edit(['status'=>1],['id'=>$v['id']]); 43 $errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
40 } 44 }
  45 +
41 } 46 }
42 echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL; 47 echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
43 return true; 48 return true;
@@ -57,4 +62,13 @@ class SyncFile extends Command @@ -57,4 +62,13 @@ class SyncFile extends Command
57 $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php'; 62 $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
58 return shell_exec($cmd); 63 return shell_exec($cmd);
59 } 64 }
  65 +
  66 +
  67 + public function synchronizationFiles($path_name){
  68 + //同步到大文件
  69 + $file_path = config('filesystems.disks.s3')['cdn'].$path_name;
  70 + $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
  71 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
  72 + return shell_exec($cmd);
  73 + }
60 } 74 }
@@ -8,12 +8,18 @@ @@ -8,12 +8,18 @@
8 namespace App\Console\Commands\Test; 8 namespace App\Console\Commands\Test;
9 9
10 10
  11 +use App\Models\Com\KeywordVideoTask;
11 use App\Models\File\File; 12 use App\Models\File\File;
12 use App\Models\File\File as FileModel; 13 use App\Models\File\File as FileModel;
13 use App\Models\File\Image; 14 use App\Models\File\Image;
14 use App\Models\File\Image as ImageModel; 15 use App\Models\File\Image as ImageModel;
  16 +use App\Models\Product\Keyword;
  17 +use App\Models\Project\Project;
15 use App\Services\AmazonS3Service; 18 use App\Services\AmazonS3Service;
  19 +use App\Services\ProjectServer;
16 use Illuminate\Console\Command; 20 use Illuminate\Console\Command;
  21 +use Illuminate\Support\Facades\DB;
  22 +use Illuminate\Support\Facades\Schema;
17 23
18 24
19 class Demo extends Command 25 class Demo extends Command
@@ -33,25 +39,25 @@ class Demo extends Command @@ -33,25 +39,25 @@ class Demo extends Command
33 protected $description = 'demo'; 39 protected $description = 'demo';
34 40
35 41
36 - /**  
37 - * Execute the job.  
38 - *  
39 - * @return void  
40 - */  
41 - public function handle()  
42 - {  
43 - $this->param['project_id'] = 181;  
44 - $imageModel = new ImageModel();  
45 - //获取当前项目的所有图片  
46 - $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);  
47 - if(!empty($imageList)){  
48 - $amazonS3Service = new AmazonS3Service();  
49 - foreach ($imageList as $k => $v){  
50 - $amazonS3Service->syncImageFiles(getImageUrl($v['path']));  
51 - $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);  
52 - }  
53 - }  
54 - 42 +// /**
  43 +// * Execute the job.
  44 +// *
  45 +// * @return void
  46 +// */
  47 +// public function handle()
  48 +// {
  49 +// $this->param['project_id'] = 181;
  50 +// $imageModel = new ImageModel();
  51 +// //获取当前项目的所有图片
  52 +// $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);
  53 +// if(!empty($imageList)){
  54 +// $amazonS3Service = new AmazonS3Service();
  55 +// foreach ($imageList as $k => $v){
  56 +// $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
  57 +// $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
  58 +// }
  59 +// }
  60 +//
55 // $fileModel = new FileModel(); 61 // $fileModel = new FileModel();
56 // $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']); 62 // $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
57 // if(!empty($fileList)){ 63 // if(!empty($fileList)){
@@ -63,7 +69,73 @@ class Demo extends Command @@ -63,7 +69,73 @@ class Demo extends Command
63 // gc_collect_cycles(); 69 // gc_collect_cycles();
64 // } 70 // }
65 // } 71 // }
66 - return true; 72 +// return true;
  73 +// }
  74 +
  75 +// public function handle(){
  76 +// $keywordVideoModel = new KeywordVideoTask();
  77 +// $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();
  78 +// $projectModel = new Project();
  79 +// $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);
  80 +// $data = [];
  81 +// foreach ($list as $v){
  82 +// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  83 +// ProjectServer::useProject($v['id']);
  84 +// $this->saveKeyword();
  85 +// DB::disconnect('custom_mysql');
  86 +// }
  87 +// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  88 +// }
  89 +//
  90 +// /**
  91 +// * @remark :关键字有视频的改为1
  92 +// * @name :getProductKeywordInfo
  93 +// * @author :lyh
  94 +// * @method :post
  95 +// * @time :2024/5/31 9:54
  96 +// */
  97 +// public function saveKeyword(){
  98 +// $keywordModel = new Keyword();
  99 +// $rs = $keywordModel->edit(['is_video_keyword'=>1],['video'=>['!=',null]]);
  100 +// echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;
  101 +// return true;
  102 +// }
  103 +
  104 + public function handle(){
  105 + //切换数据库配置
  106 + ProjectServer::useProject(1862);
  107 + return $this->initTable(1380,1862);
67 } 108 }
68 109
  110 + public function initTable($project_id, $news_project_id)
  111 + {
  112 + config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
  113 + $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
  114 + $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
  115 + $tables = array_column($tables, 'Tables_in_' . $database_name);
  116 + foreach ($tables as $table) {
  117 + $has_table = Schema::connection('custom_mysql')->hasTable($table);
  118 + if (!$has_table) {
  119 + $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
  120 + DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式
  121 + }
  122 +
  123 + if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {
  124 + continue;
  125 + }
  126 + DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
  127 + DB::connection('custom_mysql')->table($table)->insertUsing(
  128 + [], // 列名数组,留空表示插入所有列
  129 + function ($query) use ($table, $project_id) {
  130 + $name = 'gl_data_' . $project_id . '.' . $table;
  131 + $query->select('*')->from("{$name}");
  132 + }
  133 + );
  134 +
  135 + if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
  136 + DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
  137 + }
  138 + }
  139 + return true;
  140 + }
69 } 141 }
@@ -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 }
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/5/28
  6 + * Time: 14:25
  7 + */
  8 +namespace App\Http\Controllers\Aside\Task;
  9 +
  10 +use App\Enums\Common\Code;
  11 +use App\Http\Controllers\Aside\BaseController;
  12 +use App\Models\Com\Notify;
  13 +use App\Models\Project\Project;
  14 +use App\Models\WebSetting\WebLanguage;
  15 +use Illuminate\Http\Request;
  16 +
  17 +/**
  18 + * 自动任务信息
  19 + * Class AutoTaskController
  20 + * @package App\Http\Controllers\Aside\Task
  21 + */
  22 +class AutoTaskController extends BaseController
  23 +{
  24 + /**
  25 + * 页面生成任务
  26 + * @param Request $request
  27 + * @return \Illuminate\Http\JsonResponse
  28 + */
  29 + public function createHtmlTask(Request $request)
  30 + {
  31 + // 接收信息
  32 + $project_id = intval($request->input('project_id'));
  33 + $status = intval($request->input('status'));
  34 + $route = intval($request->input('route'));
  35 + $type = intval($request->input('type'));
  36 + $row = intval($request->input('row', 20));
  37 + // 所有参数都有初始化数据, 无数据验证
  38 + // 查询初始数据
  39 + $where = compact('project_id', 'route', 'type');
  40 + $where = array_filter($where);
  41 + if ($status)
  42 + $where['status'] = $status - 1;
  43 + $result = Notify::select(['id','project_id', 'type', 'data', 'status', 'route', 'num', 'updated_at', 'created_at'])
  44 + ->where('id', '>', 84000) // 查询有效数据
  45 + ->where('server_id', '<>', 9) // 过滤测试环境数据
  46 + ->where('server_id', '>', 0) // 过滤测试环境数据
  47 + ->where($where)
  48 + ->orderBy('id', 'desc')
  49 + ->paginate($row);
  50 +
  51 + // 数据中需要处理项目信息
  52 + $project_ids = $result->pluck('project_id')->toArray();
  53 + $projects = Project::whereIN('id', $project_ids)->pluck('title', 'id')->toArray();
  54 + // 数据中需要处理的语种信息
  55 + $language = WebLanguage::pluck('chinese', 'id')->toArray();
  56 + // 数据中需要映射的参数信息
  57 + $type = Notify::typeMap();
  58 + $route = Notify::routeMap();
  59 + $status = Notify::statusMap();
  60 + // 转数组操作, 如果是对象, 添加字段会报错
  61 + $result = $result->toArray();
  62 + foreach ($result['list'] as &$val) {
  63 + // 解析data信息, 以后数据库尽量不要存需要处理的JSON信息, 拆分成指定字段
  64 + $data = json_decode($val['data'], true);
  65 + $val['language'] = [];
  66 + // 小语种 并且 有语种信息, 将语种转换成中文
  67 + if ($val['type'] == Notify::TYPE_MINOR && FALSE == empty($data['language'])) {
  68 + foreach ($data['language'] as $v) {
  69 + $val['language'][] = $language[$v];
  70 + }
  71 + }
  72 + // 映射信息 以及解析信息
  73 + $val['type'] = $type[$val['type']];
  74 + $val['route'] = $route[$val['route']];
  75 + $val['status'] = $status[$val['status']];
  76 + $val['project_title'] = $projects[$val['project_id']] ?? '';
  77 + $val['domain'] = $data['domain'] ?? '';
  78 + $val['url'] = FALSE == empty($data['url']) ? $data['url'] : [];
  79 +
  80 + }
  81 + return $this->response('success', Code::SUCCESS, $result);
  82 + }
  83 +
  84 + /**
  85 + * 页面生成任务参数
  86 + * @return \Illuminate\Http\JsonResponse
  87 + */
  88 + public function createHtmlTaskParam()
  89 + {
  90 + $status = Notify::statusMap();
  91 + $status_new = [];
  92 + foreach ($status as $key=>$val) {
  93 + $status_new[$key+1] = $val;
  94 + }
  95 + $result = [
  96 + 'status' => $status_new,
  97 + 'type' => Notify::typeMap(),
  98 + 'route' => Notify::routeMap()
  99 + ];
  100 + return $this->response('success', Code::SUCCESS, $result);
  101 + }
  102 +}
@@ -96,6 +96,7 @@ class FileManageController extends BaseController @@ -96,6 +96,7 @@ class FileManageController extends BaseController
96 $cosService = new CosService(); 96 $cosService = new CosService();
97 $cosService->uploadFile($file,$path,$fileName); 97 $cosService->uploadFile($file,$path,$fileName);
98 $data['project_id'] = $this->user['project_id']; 98 $data['project_id'] = $this->user['project_id'];
  99 + $data['en_name'] = $fileName;
99 $data['path'] = $path.'/'.$fileName; 100 $data['path'] = $path.'/'.$fileName;
100 $rs = $fileManage->add($data); 101 $rs = $fileManage->add($data);
101 if ($rs === false) { 102 if ($rs === false) {
@@ -113,14 +114,16 @@ class FileManageController extends BaseController @@ -113,14 +114,16 @@ class FileManageController extends BaseController
113 */ 114 */
114 public function getOnlyFilename($name,$project_id = 0){ 115 public function getOnlyFilename($name,$project_id = 0){
115 $nameArr = explode('.',$name); 116 $nameArr = explode('.',$name);
116 - $enName = generateRoute(Translate::tran($nameArr[0], 'en')); 117 + $suffix = array_pop($nameArr) ?? 'txt';
  118 + $nameStr = implode('-', $nameArr);
  119 + $enName = generateRoute(Translate::tran($nameStr, 'en'));
117 $fileName = $enName; 120 $fileName = $enName;
118 $i=1; 121 $i=1;
119 - while($this->onlyName($enName.'.'.$nameArr[1],$project_id)){ 122 + while($this->onlyName($enName.'.'.$suffix,$project_id)){
120 $enName = $fileName .'-'.$i; 123 $enName = $fileName .'-'.$i;
121 $i++; 124 $i++;
122 } 125 }
123 - return $enName.'.'.$nameArr[1]; 126 + return $enName.'.'.$suffix;
124 } 127 }
125 128
126 /** 129 /**
@@ -154,7 +157,7 @@ class FileManageController extends BaseController @@ -154,7 +157,7 @@ class FileManageController extends BaseController
154 if(!in_array($extension, explode(',', $this->upload_config['allow_file_type']))){ 157 if(!in_array($extension, explode(',', $this->upload_config['allow_file_type']))){
155 $this->fail('不允许上传的文件类型'); 158 $this->fail('不允许上传的文件类型');
156 } 159 }
157 - $hash = hash_file('md5', $file->getPathname()); 160 + $hash = hash_file('sha256', $file->getPathname());
158 $info = FileManage::where('hash', $hash)->first(); 161 $info = FileManage::where('hash', $hash)->first();
159 if($info){ 162 if($info){
160 $this->fail('文件已上传,文件名称.'.$info['name']); 163 $this->fail('文件已上传,文件名称.'.$info['name']);
@@ -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 }
@@ -195,7 +195,7 @@ class FileController @@ -195,7 +195,7 @@ class FileController
195 */ 195 */
196 public function api_upload_single(&$files) 196 public function api_upload_single(&$files)
197 { 197 {
198 - $hash = hash_file('md5', $files->getPathname()); 198 + $hash = hash_file('sha256', $files->getPathname());
199 $name = $files->getFilename(); 199 $name = $files->getFilename();
200 //查看文件是否存在 200 //查看文件是否存在
201 $fileModel = new File(); 201 $fileModel = new File();
@@ -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 /**
@@ -9,6 +9,7 @@ use App\Models\Service\Service as ServiceSettingModel; @@ -9,6 +9,7 @@ use App\Models\Service\Service as ServiceSettingModel;
9 use App\Models\Template\BCustomTemplate; 9 use App\Models\Template\BCustomTemplate;
10 use App\Models\Template\BTemplateCommon; 10 use App\Models\Template\BTemplateCommon;
11 use App\Models\Template\BTemplateLog; 11 use App\Models\Template\BTemplateLog;
  12 +use App\Models\Template\BTemplateMain;
12 use App\Models\Template\Setting; 13 use App\Models\Template\Setting;
13 use App\Models\Template\BTemplate; 14 use App\Models\Template\BTemplate;
14 15
@@ -83,6 +84,13 @@ class CustomTemplateLogic extends BaseLogic @@ -83,6 +84,13 @@ class CustomTemplateLogic extends BaseLogic
83 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){ 84 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
84 $this->fail('404页面已存在'); 85 $this->fail('404页面已存在');
85 } 86 }
  87 + if($this->param['url'] == 'search'){
  88 + $bTemplateMainModel = new BTemplateMain();
  89 + $mainInfo = $bTemplateMainModel->read(['type'=>8]);
  90 + if($mainInfo !== false){
  91 + $this->param['html'] = $mainInfo['main_html'];
  92 + }
  93 + }
86 $this->param['project_id'] = $this->user['project_id']; 94 $this->param['project_id'] = $this->user['project_id'];
87 $id = $this->model->addReturnId($this->param); 95 $id = $this->model->addReturnId($this->param);
88 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); 96 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
@@ -303,7 +303,7 @@ class TranslateLogic extends BaseLogic @@ -303,7 +303,7 @@ class TranslateLogic extends BaseLogic
303 if(strtolower($route) == 'all'){ 303 if(strtolower($route) == 'all'){
304 return $this->success($data); 304 return $this->success($data);
305 } 305 }
306 - if($route == '/'){ 306 + if($route == 'index'){
307 $data['source'] = 1; 307 $data['source'] = 1;
308 return $this->success($data); 308 return $this->success($data);
309 } 309 }
@@ -69,10 +69,11 @@ class CopyProjectJob implements ShouldQueue @@ -69,10 +69,11 @@ class CopyProjectJob implements ShouldQueue
69 $settingTemplateModel = new Setting(); 69 $settingTemplateModel = new Setting();
70 $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first(); 70 $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();
71 if(!empty($settingData)){ 71 if(!empty($settingData)){
72 - $settingData = $settingData->getAttributes();  
73 - unset($settingData['id']);  
74 - $settingData['project_id'] = $project_id;  
75 - $settingTemplateModel->insert($settingData); 72 + $data = [
  73 + 'template_id' =>$settingData['template_id'],
  74 + 'project_id' => $project_id
  75 + ];
  76 + $settingTemplateModel->add($data);
76 } 77 }
77 //复制部署表 78 //复制部署表
78 $buildModel = new DeployBuild(); 79 $buildModel = new DeployBuild();
@@ -13,6 +13,7 @@ class Notify extends Base @@ -13,6 +13,7 @@ class Notify extends Base
13 const STATUS_INIT = 0; 13 const STATUS_INIT = 0;
14 const STATUS_FINISH_ROUTE = 1; 14 const STATUS_FINISH_ROUTE = 1;
15 const STATUS_FINISH_PAGE = 2; 15 const STATUS_FINISH_PAGE = 2;
  16 + const STATUS_FINISH_SITEMAP = 3;
16 17
17 /** 18 /**
18 * 类型 1:主站, 2:小语种, 3:amp 19 * 类型 1:主站, 2:小语种, 3:amp
@@ -36,4 +37,47 @@ class Notify extends Base @@ -36,4 +37,47 @@ class Notify extends Base
36 const ROUTE_PRODUCT_KEYWORD = 4; 37 const ROUTE_PRODUCT_KEYWORD = 4;
37 const ROUTE_NOT_TRANSLATE = 5; 38 const ROUTE_NOT_TRANSLATE = 5;
38 const ROUTE_PRODUCT_VIDEO_KEYWORD = 6; 39 const ROUTE_PRODUCT_VIDEO_KEYWORD = 6;
  40 +
  41 + /**
  42 + * 类型
  43 + * @return array
  44 + */
  45 + public static function typeMap()
  46 + {
  47 + return [
  48 + self::TYPE_MASTER => '主站',
  49 + self::TYPE_MINOR => '小语种',
  50 + self::TYPE_AMP => 'AMP',
  51 + ];
  52 + }
  53 +
  54 + /**
  55 + * 生成目标页面
  56 + * @return array
  57 + */
  58 + public static function routeMap()
  59 + {
  60 + return [
  61 + self::ROUTE_ALL => '主站页面',
  62 + self::ROUTE_NEED => '更新页面',
  63 + self::ROUTE_URL => '指定路由',
  64 + self::ROUTE_PRODUCT_KEYWORD => '聚合页面',
  65 + self::ROUTE_NOT_TRANSLATE => '漏翻检查',
  66 + self::ROUTE_PRODUCT_VIDEO_KEYWORD => '视频聚合页'
  67 + ];
  68 + }
  69 +
  70 + /**
  71 + * 状态
  72 + * @return array
  73 + */
  74 + public static function statusMap()
  75 + {
  76 + return [
  77 + self::STATUS_INIT => '排队中',
  78 + self::STATUS_FINISH_ROUTE => '页面生成中',
  79 + self::STATUS_FINISH_PAGE => 'sitemap生成中',
  80 + self::STATUS_FINISH_SITEMAP => '完成',
  81 + ];
  82 + }
39 } 83 }
@@ -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 }
@@ -51,7 +51,7 @@ return [ @@ -51,7 +51,7 @@ return [
51 'url' => env('AWS_URL'), 51 'url' => env('AWS_URL'),
52 'endpoint' => env('AWS_ENDPOINT'), 52 'endpoint' => env('AWS_ENDPOINT'),
53 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 53 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
54 - 'cdn'=>'https://v6-file.globalso.com' 54 + 'cdn'=>'https://globalso-v6.s3.us-west-2.amazonaws.com'
55 ], 55 ],
56 56
57 'upload' => [ 57 'upload' => [
@@ -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 //生成关键字
@@ -411,6 +412,10 @@ Route::middleware(['aloginauth'])->group(function () { @@ -411,6 +412,10 @@ Route::middleware(['aloginauth'])->group(function () {
411 412
412 Route::any('/generate_aicc_token', [Aside\Com\IndexController::class, 'generateAiCCToken'])->name('admin.generate_aicc_token'); 413 Route::any('/generate_aicc_token', [Aside\Com\IndexController::class, 'generateAiCCToken'])->name('admin.generate_aicc_token');
413 Route::any('/getAutoToken', [Aside\Com\IndexController::class, 'getAutoToken'])->name('admin.getAutoToken'); 414 Route::any('/getAutoToken', [Aside\Com\IndexController::class, 'getAutoToken'])->name('admin.getAutoToken');
  415 +
  416 + // 生成页面任务
  417 + Route::any('/create_html_task', [Aside\Task\AutoTaskController::class, 'createHtmlTask'])->name('admin.create_html_task');
  418 + Route::any('/create_html_param', [Aside\Task\AutoTaskController::class, 'createHtmlTaskParam'])->name('admin.create_html_param');
414 }); 419 });
415 420
416 //无需登录验证的路由组 421 //无需登录验证的路由组
@@ -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');