作者 lyh

gx

@@ -154,84 +154,5 @@ class Demo extends Command @@ -154,84 +154,5 @@ class Demo extends Command
154 DB::disconnect('custom_mysql'); 154 DB::disconnect('custom_mysql');
155 } 155 }
156 156
157 - /**  
158 - * Execute the job.  
159 - *  
160 - * @return void  
161 - */  
162 -// public function handle()  
163 -// {  
164 -// $projectModel = new Project();  
165 -// $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);  
166 -// $data = [];  
167 -// foreach ($list as $v){  
168 -// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;  
169 -// ProjectServer::useProject($v['id']);  
170 -// DB::table('gl_web_template_com')->truncate();  
171 -// $templateComModel = new BTemplateCom();  
172 -// $templateComModel->truncate();  
173 -// $this->saveTemplateCom($v['id']);  
174 -// DB::disconnect('custom_mysql');  
175 -// }  
176 -// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;  
177 -// }  
178 157
179 - public function saveTemplateCom($project_id){  
180 - //获取当前项目选择的模版  
181 - $settingModel = new Setting();  
182 - $settingInfo = $settingModel->read(['project_id'=>$project_id]);  
183 - echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;  
184 - if($settingInfo !== false){  
185 - $templateCommonModel = new BTemplateCommon();  
186 - $commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);  
187 - if(!empty($commonList)){  
188 - foreach ($commonList as $v){  
189 - $typeArr = [1, 2, 3];  
190 - foreach ($typeArr as $type){  
191 - if($type == 1){  
192 - $headData = [  
193 - 'project_id'=>$v['project_id'],  
194 - 'source'=>$v['type'] == 1 ? 99 : $v['type'],  
195 - 'common_type'=>1,  
196 - 'template_id'=>$v['template_id'],  
197 - 'html'=>$v['head_html'],  
198 - 'html_style'=>$v['head_css'],  
199 - 'is_custom'=>$v['is_custom'],  
200 - 'is_list'=>$v['is_list']  
201 - ];  
202 - $templateComModel = new BTemplateCom();  
203 - $templateComModel->add($headData);  
204 - }elseif ($type == 2){  
205 - $footerData = [  
206 - 'project_id'=>$v['project_id'],  
207 - 'source'=>$v['type'] == 1 ? 99 : $v['type'],  
208 - 'common_type'=>2,  
209 - 'template_id'=>$v['template_id'],  
210 - 'html'=>$v['footer_html'],  
211 - 'html_style'=>$v['footer_css'],  
212 - 'is_custom'=>$v['is_custom'],  
213 - 'is_list'=>$v['is_list']  
214 - ];  
215 - $templateComModel = new BTemplateCom();  
216 - $templateComModel->add($footerData);  
217 - }elseif ($type == 3){  
218 - $otherData = [  
219 - 'project_id'=>$v['project_id'],  
220 - 'source'=>$v['type'] == 1 ? 99 : $v['type'],  
221 - 'common_type'=>3,  
222 - 'template_id'=>$v['template_id'],  
223 - 'html'=>$v['other'],  
224 - 'html_style'=>null,  
225 - 'is_custom'=>$v['is_custom'],  
226 - 'is_list'=>$v['is_list']  
227 - ];  
228 - $templateComModel = new BTemplateCom();  
229 - $templateComModel->add($otherData);  
230 - }  
231 - }  
232 - }  
233 - }  
234 - }  
235 - return true;  
236 - }  
237 } 158 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Translate.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/21 9:32
  8 + */
  9 +
  10 +namespace App\Console\Commands\Test;
  11 +
  12 +use App\Models\Template\BTemplateCom;
  13 +use App\Models\Template\BTemplateCommon;
  14 +use App\Models\Template\Setting;
  15 +use Illuminate\Console\Command;
  16 +
  17 +class Translate extends Command
  18 +{
  19 + /**
  20 + * The name and signature of the console command.
  21 + *
  22 + * @var string
  23 + */
  24 + protected $signature = 'common_header';
  25 +
  26 + /**
  27 + * The console command description.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $description = 'common_header';
  32 + /**
  33 + * Execute the job.
  34 + *
  35 + * @return void
  36 + */
  37 + public function handle()
  38 + {
  39 + $projectModel = new Project();
  40 + $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
  41 + $data = [];
  42 + foreach ($list as $v){
  43 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  44 + ProjectServer::useProject($v['id']);
  45 + DB::table('gl_web_template_com')->truncate();
  46 + $templateComModel = new BTemplateCom();
  47 + $templateComModel->truncate();
  48 + $this->saveTemplateCom($v['id']);
  49 + DB::disconnect('custom_mysql');
  50 + }
  51 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  52 + }
  53 +
  54 + public function saveTemplateCom($project_id){
  55 + //获取当前项目选择的模版
  56 + $settingModel = new Setting();
  57 + $settingInfo = $settingModel->read(['project_id'=>$project_id]);
  58 + echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
  59 + if($settingInfo !== false){
  60 + $templateCommonModel = new BTemplateCommon();
  61 + $commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
  62 + if(!empty($commonList)){
  63 + foreach ($commonList as $v){
  64 + $typeArr = [1, 2, 3];
  65 + foreach ($typeArr as $type){
  66 + if($type == 1){
  67 + $headData = [
  68 + 'project_id'=>$v['project_id'],
  69 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  70 + 'common_type'=>1,
  71 + 'template_id'=>$v['template_id'],
  72 + 'html'=>$v['head_html'],
  73 + 'html_style'=>$v['head_css'],
  74 + 'is_custom'=>$v['is_custom'],
  75 + 'is_list'=>$v['is_list']
  76 + ];
  77 + $templateComModel = new BTemplateCom();
  78 + $templateComModel->add($headData);
  79 + }elseif ($type == 2){
  80 + $footerData = [
  81 + 'project_id'=>$v['project_id'],
  82 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  83 + 'common_type'=>2,
  84 + 'template_id'=>$v['template_id'],
  85 + 'html'=>$v['footer_html'],
  86 + 'html_style'=>$v['footer_css'],
  87 + 'is_custom'=>$v['is_custom'],
  88 + 'is_list'=>$v['is_list']
  89 + ];
  90 + $templateComModel = new BTemplateCom();
  91 + $templateComModel->add($footerData);
  92 + }elseif ($type == 3){
  93 + $otherData = [
  94 + 'project_id'=>$v['project_id'],
  95 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  96 + 'common_type'=>3,
  97 + 'template_id'=>$v['template_id'],
  98 + 'html'=>$v['other'],
  99 + 'html_style'=>null,
  100 + 'is_custom'=>$v['is_custom'],
  101 + 'is_list'=>$v['is_list']
  102 + ];
  103 + $templateComModel = new BTemplateCom();
  104 + $templateComModel->add($otherData);
  105 + }
  106 + }
  107 + }
  108 + }
  109 + }
  110 + return true;
  111 + }
  112 +}
@@ -683,9 +683,9 @@ if (!function_exists('str_replace_url')) { @@ -683,9 +683,9 @@ if (!function_exists('str_replace_url')) {
683 $cos = config('filesystems.disks.cos'); 683 $cos = config('filesystems.disks.cos');
684 $cosCdn = $cos['cdn']; 684 $cosCdn = $cos['cdn'];
685 $cosCdn1 = $cos['cdn1']; 685 $cosCdn1 = $cos['cdn1'];
686 - $cosCdn3 = $cos['cdn1'];  
687 - $cosCdn2 = config('filesystems.disks.s3')['cdn'];  
688 - if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false))){ 686 + $cosCdn2 = $cos['cdn2'];
  687 + $cosCdn3 = config('filesystems.disks.s3')['cdn'];
  688 + if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false) || (strpos($url,$cosCdn3) !== false))){
689 // 外部URL无需解析 689 // 外部URL无需解析
690 // 使用 parse_url 函数来解析 URL 690 // 使用 parse_url 函数来解析 URL
691 $urlParts = parse_url($url); 691 $urlParts = parse_url($url);