作者 lyh

gx

... ... @@ -154,84 +154,5 @@ class Demo extends Command
DB::disconnect('custom_mysql');
}
/**
* Execute the job.
*
* @return void
*/
// public function handle()
// {
// $projectModel = new Project();
// $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
// $data = [];
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
// DB::table('gl_web_template_com')->truncate();
// $templateComModel = new BTemplateCom();
// $templateComModel->truncate();
// $this->saveTemplateCom($v['id']);
// DB::disconnect('custom_mysql');
// }
// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
// }
public function saveTemplateCom($project_id){
//获取当前项目选择的模版
$settingModel = new Setting();
$settingInfo = $settingModel->read(['project_id'=>$project_id]);
echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
if($settingInfo !== false){
$templateCommonModel = new BTemplateCommon();
$commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
if(!empty($commonList)){
foreach ($commonList as $v){
$typeArr = [1, 2, 3];
foreach ($typeArr as $type){
if($type == 1){
$headData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>1,
'template_id'=>$v['template_id'],
'html'=>$v['head_html'],
'html_style'=>$v['head_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($headData);
}elseif ($type == 2){
$footerData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>2,
'template_id'=>$v['template_id'],
'html'=>$v['footer_html'],
'html_style'=>$v['footer_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($footerData);
}elseif ($type == 3){
$otherData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>3,
'template_id'=>$v['template_id'],
'html'=>$v['other'],
'html_style'=>null,
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($otherData);
}
}
}
}
}
return true;
}
}
... ...
<?php
/**
* @remark :
* @name :Translate.php
* @author :lyh
* @method :post
* @time :2024/5/21 9:32
*/
namespace App\Console\Commands\Test;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use Illuminate\Console\Command;
class Translate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'common_header';
/**
* The console command description.
*
* @var string
*/
protected $description = 'common_header';
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
DB::table('gl_web_template_com')->truncate();
$templateComModel = new BTemplateCom();
$templateComModel->truncate();
$this->saveTemplateCom($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
public function saveTemplateCom($project_id){
//获取当前项目选择的模版
$settingModel = new Setting();
$settingInfo = $settingModel->read(['project_id'=>$project_id]);
echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
if($settingInfo !== false){
$templateCommonModel = new BTemplateCommon();
$commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
if(!empty($commonList)){
foreach ($commonList as $v){
$typeArr = [1, 2, 3];
foreach ($typeArr as $type){
if($type == 1){
$headData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>1,
'template_id'=>$v['template_id'],
'html'=>$v['head_html'],
'html_style'=>$v['head_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($headData);
}elseif ($type == 2){
$footerData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>2,
'template_id'=>$v['template_id'],
'html'=>$v['footer_html'],
'html_style'=>$v['footer_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($footerData);
}elseif ($type == 3){
$otherData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>3,
'template_id'=>$v['template_id'],
'html'=>$v['other'],
'html_style'=>null,
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($otherData);
}
}
}
}
}
return true;
}
}
... ...
... ... @@ -683,9 +683,9 @@ if (!function_exists('str_replace_url')) {
$cos = config('filesystems.disks.cos');
$cosCdn = $cos['cdn'];
$cosCdn1 = $cos['cdn1'];
$cosCdn3 = $cos['cdn1'];
$cosCdn2 = config('filesystems.disks.s3')['cdn'];
if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false))){
$cosCdn2 = $cos['cdn2'];
$cosCdn3 = config('filesystems.disks.s3')['cdn'];
if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false) || (strpos($url,$cosCdn3) !== false))){
// 外部URL无需解析
// 使用 parse_url 函数来解析 URL
$urlParts = parse_url($url);
... ...