作者 刘锟

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

... ... @@ -103,7 +103,7 @@ class DeleteCustomCategory extends Command
return false;
}
foreach ($customList['list'] as $v){
$category_id_arr = Arr::setToArr(trim($v['category_id'],','));
$category_id_arr = $v['category_id'];
if(empty($category_id_arr)){
continue;
}
... ...
... ... @@ -87,7 +87,7 @@ class VideoTask extends Command
continue;
}
ProjectServer::useProject($task_project->project_id);
$keyword = $this->getProjectKeyword($task_project->number);
$keyword = $this->getProjectKeyword($task_project->num);
// 已经没有需要生成视频的关键词
if (!$keyword) {
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
... ... @@ -95,7 +95,13 @@ 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;
... ... @@ -114,12 +120,16 @@ class VideoTask extends Command
'created_at' => date('Y-m-d H:i:s'),
];
KeywordVideoTaskLog::insert($array);
$num--;
$sub_task_num--;
}
}
if($sub_task_num != 0){
$task_project->num = 0;
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
$task_project->save();
}
}
return true;
}
... ... @@ -171,6 +181,12 @@ class VideoTask extends Command
public function getProjectKeyword($number)
{
$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(count($keyword_arr_id) < $number){
$number = count($keyword_arr_id);
}
$keyword_id = array_rand($keyword_arr_id, $number);
$keyword = Keyword::whereIn("id", $keyword_id)->get();
return $keyword;
... ...
... ... @@ -125,6 +125,20 @@ class ReplaceHtml extends Command
* @time :2024/5/10 17:26
*/
public function createReplaceHtmlLog($info){
if($info['is_rollback'] != 0){
$saveData = [];
$templateHtmlLogModel = new TemplateReplaceHtmlLog();
$list = $templateHtmlLogModel->list(['replace_id'=>$info['rollback_id']]);
foreach ($list as $value){
$value['replace_id'] = $info['id'];
$value['is_rollback'] = $info['is_rollback'];
$value['old_html'] = $info['old_html'];
$value['html'] = $info['html'];
$value['created_at'] = date('Y-m-d H:i:s');
$value['updated_at'] = date('Y-m-d H:i:s');
$saveData[] = $value;
}
}else{
$bTemplateModel = new BTemplate();
$condition = ['is_custom'=>$info['is_custom'], 'is_list'=>$info['is_list'], 'template_id'=>$info['template_id']];
if($info['source'] != 0){
... ... @@ -139,8 +153,9 @@ class ReplaceHtml extends Command
$saveData = [];
foreach ($bTemplateList as $v){
$source_id = $v['source'] == 1 ? 0 : $v['source_id'];
$name = $this->getSourceName($v['source'],$source_id,$v['is_list'],$v['is_custom']);
$saveData[] = $this->saveData($info,$v,$source_id,$name);
$name_route = $this->getSourceName($v['source'],$source_id,$v['is_list'],$v['is_custom']);
$saveData[] = $this->saveData($info,$v,$source_id,$name_route);
}
}
if(!empty($saveData)){
$templateHtmlLogModel = new TemplateReplaceHtmlLog();
... ... @@ -156,7 +171,7 @@ class ReplaceHtml extends Command
* @method :post
* @time :2024/5/13 11:29
*/
public function saveData($info,$v,$source_id,$name){
public function saveData($info,$v,$source_id,$name_route){
return [
'replace_id'=>$info['id'],
'project_id'=>$info['project_id'],
... ... @@ -169,7 +184,8 @@ class ReplaceHtml extends Command
'is_list'=>$v['is_list'],
'is_rollback'=>$info['is_rollback'],
'template_id'=>$info['template_id'],
'source_name'=>$name,
'source_name'=>$name_route['name'],
'route'=>$name_route['route'],
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
... ... @@ -231,6 +247,7 @@ class ReplaceHtml extends Command
return false;
}
$name = $cateInfo['name'];
$route = $cateInfo['alias'];
}else{
$newsModel = new News();
$newsInfo = $newsModel->read(['id'=>$source_id]);
... ... @@ -238,8 +255,9 @@ class ReplaceHtml extends Command
return false;
}
$name = $newsInfo['name'];
$route = $newsInfo['url'];
}
return $name;
return ['name'=>$name,'route'=>$route];
}
/**
... ... @@ -257,6 +275,7 @@ class ReplaceHtml extends Command
return false;
}
$name = $cateInfo['name'];
$route = $cateInfo['alias'];
}else{
$blogModel = new Blog();
$productInfo = $blogModel->read(['id'=>$source_id]);
... ... @@ -264,8 +283,9 @@ class ReplaceHtml extends Command
return false;
}
$name = $productInfo['name'];
$route = $productInfo['url'];
}
return $name;
return ['name'=>$name,'route'=>$route];
}
/**
... ... @@ -283,6 +303,7 @@ class ReplaceHtml extends Command
return false;
}
$name = $cateInfo['title'];
$route = $cateInfo['route'];
}else{
$productModel = new Product();
$productInfo = $productModel->read(['id'=>$source_id]);
... ... @@ -290,8 +311,9 @@ class ReplaceHtml extends Command
return false;
}
$name = $productInfo['title'];
$route = $productInfo['route'];
}
return $name;
return ['name'=>$name,'route'=>$route];
}
/**
... ... @@ -314,6 +336,7 @@ class ReplaceHtml extends Command
return false;
}
$name = $cateInfo['name'];
$route = $cateInfo['route'];
}else{
$contentModel = new CustomModuleContent();
$contentInfo = $contentModel->read(['id'=>$source_id],['id','name']);
... ... @@ -321,7 +344,8 @@ class ReplaceHtml extends Command
return false;
}
$name = $contentInfo['name'];
$route = $contentInfo['route'];
}
return $name;
return ['name'=>$name,'route'=>$route];
}
}
... ...
... ... @@ -80,7 +80,7 @@ class ReplaceHtmlLog extends Command
public function replaceHtml($info){
$source_id = $info['source'] == 1 ? 0 : $info['source_id'];
$bTemplateModel = new BTemplate();
$condition = ['source'=>$info['source'],'source_id'=>$info['source_id'],
$condition = ['source'=>$info['source'],'source_id'=>$source_id,
'template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];
$old_html = $info['old_html'];
$html = $info['html'];
... ...
... ... @@ -610,7 +610,6 @@ if (!function_exists('getFileUrl')) {
return $cdn2.$path;
}
if($location == 0){
//v6-file.globalso.com
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
return $cosCdn.$path;
... ...
... ... @@ -108,7 +108,7 @@ class KeywordVideoController extends BaseController
if($info === false){
$this->response('请先设置域名',Code::SYSTEM_ERROR);
}
$this->param['num'] = $this->param['number'];
$rs = $keywordModel->add($this->param);
if($rs === false){
$this->response('添加失败',Code::SYSTEM_ERROR);
... ... @@ -130,6 +130,9 @@ class KeywordVideoController extends BaseController
'id.required' => '主键标识不为空',
]);
$keywordModel = new KeywordVideoTask();
if($this->param['status'] == 0){
$this->param['num'] = $this->param['number'];
}
$rs = $keywordModel->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->response('编辑失败',Code::SYSTEM_ERROR);
... ...
... ... @@ -134,7 +134,7 @@ class FileController
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
$this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
$this->synchronizationFile($fileName,$this->upload_location);
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -303,7 +303,7 @@ class FileController
$mime = $file->getMimeType();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
$data[] = $this->responseData($this->path.'/'.$fileName, $name);
$this->synchronizationFile($fileName,($this->upload_location == 0) ? 1 : 0);
$this->synchronizationFile($fileName,$this->upload_location);
}
$this->response('资源',Code::SUCCESS,$data);
}
... ...
... ... @@ -215,7 +215,7 @@ class ImageController extends Controller
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
$this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
$this->synchronizationImage($fileName,$this->upload_location);
return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -347,7 +347,7 @@ class ImageController extends Controller
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$this->synchronizationImage($fileName,($this->upload_location == 0) ? 1 : 0);
$this->synchronizationImage($fileName,$this->upload_location);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
}
$this->response('图片资源',Code::SUCCESS,$data);
... ...
... ... @@ -97,7 +97,8 @@ class InitHtmlLogic extends BaseLogic
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($mainInfo === false){
$data = [
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
'html'=>$this->param['html'],
'main_html'=>characterTruncationStr($this->param['html'],"<main","</main>"),
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
'section_list_id'=>$this->param['section_list_id'] ?? '',
'project_id'=>$this->user['project_id'],
... ... @@ -108,7 +109,8 @@ class InitHtmlLogic extends BaseLogic
$bTemplateMainModel->add($data);
}else{
$data = [
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
'html'=>$this->param['html'],
'main_html'=>characterTruncationStr($this->param['html'],"<main","</main>"),
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
'section_list_id'=>$this->param['section_list_id'] ?? '',
];
... ...
... ... @@ -359,6 +359,11 @@ class TranslateLogic extends BaseLogic
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT_KEYWORD){
if($routeInfo['source_id']){
$data = ['source'=>8,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_MODULE){
if($routeInfo['source_id']){
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>1];
... ...
... ... @@ -38,8 +38,9 @@ class SyncImageFileJob implements ShouldQueue
*/
public function handle()
{
$file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,$this->param['location']);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
... ... @@ -47,4 +48,40 @@ class SyncImageFileJob implements ShouldQueue
}
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
}
}
... ...
... ... @@ -36,7 +36,7 @@ class TemplateReplaceHtml extends Base
'新闻列表'=>['source'=>4,'is_list'=>1,'is_custom'=>0],
'博客详情'=>['source'=>3,'is_list'=>0,'is_custom'=>0],
'博客列表'=>['source'=>3,'is_list'=>1,'is_custom'=>0],
// '单页面'=>['source'=>9,'is_list'=>0,'is_custom'=>0],
'单页面'=>['source'=>9,'is_list'=>0,'is_custom'=>0],
];
}
}
... ...