作者 赵彬吉
@@ -89,9 +89,9 @@ class Count extends Command @@ -89,9 +89,9 @@ class Count extends Command
89 DB::table('gl_count')->insert($data); 89 DB::table('gl_count')->insert($data);
90 } 90 }
91 }catch (\Exception $e){ 91 }catch (\Exception $e){
92 - echo date('Y-m-d H:i:s') . ' error: ' . $v['test_domain'] . '->' . $e->getMessage() . PHP_EOL; 92 + echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL;
93 } 93 }
94 - echo date('Y-m-d H:i:s') . ' end: ' . $v['test_domain'] . PHP_EOL; 94 + echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
95 echo $this->error; 95 echo $this->error;
96 } 96 }
97 97
@@ -16,8 +16,12 @@ use App\Models\Domain\DomainInfo; @@ -16,8 +16,12 @@ use App\Models\Domain\DomainInfo;
16 use App\Models\Product\Keyword; 16 use App\Models\Product\Keyword;
17 use App\Models\Product\Product; 17 use App\Models\Product\Product;
18 use App\Models\RouteMap\RouteMap; 18 use App\Models\RouteMap\RouteMap;
  19 +use App\Models\Template\BSettingTemplate;
  20 +use App\Models\Template\BTemplateCommon;
  21 +use App\Models\Template\Setting;
19 use App\Services\ProjectServer; 22 use App\Services\ProjectServer;
20 use Illuminate\Console\Command; 23 use Illuminate\Console\Command;
  24 +use Illuminate\Support\Facades\Cache;
21 use Illuminate\Support\Facades\DB; 25 use Illuminate\Support\Facades\DB;
22 use Illuminate\Support\Facades\Http; 26 use Illuminate\Support\Facades\Http;
23 use Illuminate\Support\Facades\Log; 27 use Illuminate\Support\Facades\Log;
@@ -51,7 +55,7 @@ class VideoTask extends Command @@ -51,7 +55,7 @@ class VideoTask extends Command
51 /** 55 /**
52 * @var int 最大子任务 56 * @var int 最大子任务
53 */ 57 */
54 - public $max_sub_task = 800; 58 + public $max_sub_task = 200;
55 59
56 /** 60 /**
57 * @return bool 61 * @return bool
@@ -97,6 +101,7 @@ class VideoTask extends Command @@ -97,6 +101,7 @@ class VideoTask extends Command
97 $task_project->save(); 101 $task_project->save();
98 continue; 102 continue;
99 } 103 }
  104 + $logo_bg = $this->getImage($domainInfo);
100 foreach ($keyword as $val) { 105 foreach ($keyword as $val) {
101 $log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first(); 106 $log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first();
102 if ($log){ 107 if ($log){
@@ -109,7 +114,7 @@ class VideoTask extends Command @@ -109,7 +114,7 @@ class VideoTask extends Command
109 'keyword' => $val->title, 114 'keyword' => $val->title,
110 'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'], 115 'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'],
111 'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'], 116 'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'],
112 - 'keywords' => $keywordInfo['keyword_list']]), 117 + 'keywords' => $keywordInfo['keyword_list'], 'logo_bg' => $logo_bg]),
113 'status' => KeywordVideoTaskLog::STATUS_INIT, 118 'status' => KeywordVideoTaskLog::STATUS_INIT,
114 'updated_at' => date('Y-m-d H:i:s'), 119 'updated_at' => date('Y-m-d H:i:s'),
115 'created_at' => date('Y-m-d H:i:s'), 120 'created_at' => date('Y-m-d H:i:s'),
@@ -130,10 +135,11 @@ class VideoTask extends Command @@ -130,10 +135,11 @@ class VideoTask extends Command
130 public function sendSubTask() 135 public function sendSubTask()
131 { 136 {
132 $subTask = KeywordVideoTaskLog::where(['status' => KeywordVideoTaskLog::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get(); 137 $subTask = KeywordVideoTaskLog::where(['status' => KeywordVideoTaskLog::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get();
133 - if ($subTask->isEmpty()) 138 + if ($subTask->isEmpty()){
134 return true; 139 return true;
  140 + }
135 foreach ($subTask as $val) { 141 foreach ($subTask as $val) {
136 - $valData = (array)json_decode($val->data); 142 + $valData = json_decode($val->data,true);
137 $task_id = 'v6-' . uniqid(); 143 $task_id = 'v6-' . uniqid();
138 $data = [ 144 $data = [
139 'project_data' => [ 145 'project_data' => [
@@ -141,7 +147,9 @@ class VideoTask extends Command @@ -141,7 +147,9 @@ class VideoTask extends Command
141 'title' => $valData['title'], 147 'title' => $valData['title'],
142 'keywords' => $valData['keywords'], 148 'keywords' => $valData['keywords'],
143 'description' => $valData['description'], 149 'description' => $valData['description'],
144 - 'images' => $valData['images'] 150 + 'images' => $valData['images'],
  151 + 'logo'=> $valData['logo_bg']['logo'] ?? '',
  152 + 'bg'=> $valData['logo_bg']['bg'] ?? ''
145 ], 153 ],
146 'task_id' => $task_id, 154 'task_id' => $task_id,
147 'callback_url' => env('APP_URL') . '/api/video_task_callback', 155 'callback_url' => env('APP_URL') . '/api/video_task_callback',
@@ -163,7 +171,7 @@ class VideoTask extends Command @@ -163,7 +171,7 @@ class VideoTask extends Command
163 */ 171 */
164 public function getProjectKeyword($number) 172 public function getProjectKeyword($number)
165 { 173 {
166 - $keyword_arr_id = Keyword::where('video', null)->whereNotNull('keyword_content')->pluck('id')->toArray(); 174 + $keyword_arr_id = Keyword::where('video', null)->where('title', 'not like', '%-tag%')->whereNotNull('keyword_content')->pluck('id')->toArray();
167 $keyword_id = array_rand($keyword_arr_id, $number); 175 $keyword_id = array_rand($keyword_arr_id, $number);
168 $keyword = Keyword::whereIn("id", $keyword_id)->get(); 176 $keyword = Keyword::whereIn("id", $keyword_id)->get();
169 return $keyword; 177 return $keyword;
@@ -181,23 +189,39 @@ class VideoTask extends Command @@ -181,23 +189,39 @@ class VideoTask extends Command
181 } 189 }
182 190
183 /** 191 /**
184 - * @remark :根据关键字获取产品主图  
185 - * @name :getKeywordList  
186 - * @author :lyh  
187 - * @method :post  
188 - * @time :2024/2/23 16:28 192 + * 根据关键字获取产品主图
  193 + * @param $keyword_id
  194 + * @param $project_id
  195 + * @param $domain
  196 + * @return array
189 */ 197 */
190 public function getKeywordImage($keyword_id,$project_id,$domain){ 198 public function getKeywordImage($keyword_id,$project_id,$domain){
191 $keywordModel = new Keyword(); 199 $keywordModel = new Keyword();
192 $keywordInfo = $keywordModel->read(['id'=>$keyword_id]); 200 $keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
  201 + // TODO 当内容太多时,生成视频过长, 尽量保证生成视频30秒左右, 所以需要控制文案内容长度
  202 + $content = $keywordInfo['keyword_content'];
  203 + $content_array = explode(" ", $content);
  204 + if (count($content_array) > 80) {
  205 + $content_array = preg_split("/[,,。]/u", $content);
  206 + $tmp = '';
  207 + foreach ($content_array as $val) {
  208 + $tmp .= $val . '.';
  209 + $tmp_array = explode(' ', $tmp);
  210 + if (count($tmp_array) > 60) {
  211 + $content = $tmp;
  212 + break;
  213 + }
  214 + }
  215 + }
  216 +
193 //TODO::所有产品 217 //TODO::所有产品
194 $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id); 218 $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
195 - $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();; 219 + $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();
196 $data = [ 220 $data = [
197 - 'url'=>$domain.'/'.$keywordInfo['route'], 221 + 'url'=> 'https://' . $domain.'/'.$keywordInfo['route'],
198 'title'=>$keywordInfo['title'], 222 'title'=>$keywordInfo['title'],
199 'keyword_title'=>$keywordInfo['keyword_title'], 223 'keyword_title'=>$keywordInfo['keyword_title'],
200 - 'keyword_content'=>$keywordInfo['keyword_content'], 224 + 'keyword_content'=>$content,
201 'product_list'=>$thumb ?? [], 225 'product_list'=>$thumb ?? [],
202 'keyword_list'=>$keyword_arr ?? [] 226 'keyword_list'=>$keyword_arr ?? []
203 ]; 227 ];
@@ -220,17 +244,24 @@ class VideoTask extends Command @@ -220,17 +244,24 @@ class VideoTask extends Command
220 if (count($productIds)<7){ 244 if (count($productIds)<7){
221 $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 245 $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
222 $number = 40; 246 $number = 40;
223 - $product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));  
224 - $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();  
225 - $products = $productsQuery->merge($randomData); 247 + $array_count = count($product_all_id);
  248 + if ($array_count > 0) {
  249 + $product_id = array_rand($product_all_id, min($array_count, $number - count($productIds)));
  250 + $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
  251 + $products = $productsQuery->merge($randomData);
  252 + }
226 }else{ 253 }else{
227 $products = $productsQuery; 254 $products = $productsQuery;
228 } 255 }
229 }else{ 256 }else{
230 $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 257 $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
231 $number = 40; 258 $number = 40;
232 - $product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));  
233 - $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 259 + $array_count = count($product_all_id);
  260 + if ($array_count > 0)
  261 + {
  262 + $product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));
  263 + $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
  264 + }
234 } 265 }
235 } 266 }
236 $data = []; 267 $data = [];
@@ -242,10 +273,11 @@ class VideoTask extends Command @@ -242,10 +273,11 @@ class VideoTask extends Command
242 if(count($data) > 13){ 273 if(count($data) > 13){
243 break; 274 break;
244 } 275 }
245 - if (strpos($item->keyword_id, ','.$productKeyword->id.',') === false) { 276 + $keyword_id = implode(',',$item->keyword_id);
  277 + if (strpos(','.$keyword_id.',', ','.$productKeyword->id.',') === false) {
246 //不包含 278 //不包含
247 $productModel = new Product(); 279 $productModel = new Product();
248 - $keyword_id = $item->keyword_id . $productKeyword->id.','; 280 + $keyword_id = $keyword_id . $productKeyword->id.',';
249 $productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]); 281 $productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]);
250 } 282 }
251 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title]; 283 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
@@ -254,4 +286,37 @@ class VideoTask extends Command @@ -254,4 +286,37 @@ class VideoTask extends Command
254 return $data; 286 return $data;
255 } 287 }
256 288
  289 + /**
  290 + * 获取图片
  291 + * @param $domainInfo
  292 + * @return array
  293 + */
  294 + public function getImage($domainInfo){
  295 + $logo = $bg = '';
  296 + try {
  297 + $dom = file_get_html('https://'.$domainInfo['domain'].'/');
  298 + $logoDom = $dom->find('.logo', 0)->find("img",0);
  299 + if($logoDom != null){
  300 + $logo = $logoDom->src;
  301 + }
  302 + $elements = $dom->find('.section-banner-wrap-block');
  303 + if (count($elements) >= 2) {
  304 + foreach ($elements as $v){
  305 + $image = $v->find('img', 0);
  306 + if($image != null){
  307 + break;
  308 + }
  309 + }
  310 + } else {
  311 + $image = $elements->find('img', 0);
  312 + }
  313 + if($image != null){
  314 + $bg = $image->src;
  315 + }
  316 + $dom->clear();
  317 + } catch (\Exception $e) {
  318 + Log::error('file_get_html: ' . $domainInfo['domain'] . ', error message: ' . $e->getMessage());
  319 + }
  320 + return ['logo' => $logo, 'bg' => $bg];
  321 + }
257 } 322 }
@@ -265,7 +265,37 @@ class Demo extends Command @@ -265,7 +265,37 @@ class Demo extends Command
265 // print_r($include); 265 // print_r($include);
266 // } 266 // }
267 public function handle(){ 267 public function handle(){
268 - echo '加密字符串:'.md5('company_list+2024-03-05+prod_desc=led&total=10'); 268 + $domainModel = new DomainInfo();
  269 + $domainInfo = $domainModel->read(['project_id'=>45]);
  270 + if($domainInfo === false){
  271 + dd('11111');
  272 + }
  273 + $bg = '';
  274 + $logo = '';
  275 + $dom = file_get_html('https://'.$domainInfo['domain'].'/');
  276 + $logoDom = $dom->find('.logo', 0)->find("img",0);
  277 + if($logoDom != null){
  278 + $logo = $logoDom->src;
  279 + }
  280 + $elements = $dom->find('.section-banner-wrap-block');
  281 + if (count($elements) >= 2) {
  282 + foreach ($elements as $v){
  283 + $image = $v->find('img', 0);
  284 + if($image != null){
  285 + break;
  286 + }
  287 + }
  288 + } else {
  289 + $image = $elements->find('img', 0);
  290 + }
  291 + if($image != null){
  292 + $bg = $image->src;
  293 + }
  294 + if($image != null){
  295 + $bg = $image->src;
  296 + }
  297 +// return $logo;
  298 + dd(['logo'=>$logo ?? '','bg'=>$bg ?? '']);
269 // $projectModel = new Project(); 299 // $projectModel = new Project();
270 // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); 300 // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
271 // foreach ($list as $v1){ 301 // foreach ($list as $v1){
@@ -665,23 +665,24 @@ class ProjectUpdate extends Command @@ -665,23 +665,24 @@ class ProjectUpdate extends Command
665 foreach ($item['extend'] as $ke => $ve) { 665 foreach ($item['extend'] as $ke => $ve) {
666 $extend = $extend_model->read(['title' => $ke]); 666 $extend = $extend_model->read(['title' => $ke]);
667 if ($extend) { 667 if ($extend) {
668 - $extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]);  
669 - if (!$extend_info) {  
670 - if ($extend['type'] == 3) {  
671 - $gallery = [];  
672 - if (is_array($ve)) {  
673 - foreach ($ve as $ve_img) {  
674 - $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];  
675 - }  
676 - } else {  
677 - $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]; 668 + if ($extend['type'] == 3) {
  669 + $gallery = [];
  670 + if (is_array($ve)) {
  671 + foreach ($ve as $ve_img) {
  672 + $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)];
678 } 673 }
679 - $value = Arr::a2s($gallery);  
680 - } elseif ($extend['type'] == 4) {  
681 - $value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]);  
682 } else { 674 } else {
683 - $value = $ve; 675 + $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)];
684 } 676 }
  677 + $value = Arr::a2s($gallery);
  678 + } elseif ($extend['type'] == 4) {
  679 + $value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]);
  680 + } else {
  681 + $value = $ve;
  682 + }
  683 +
  684 + $extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]);
  685 + if (!$extend_info) {
685 $extend_info_model->add([ 686 $extend_info_model->add([
686 'key' => $extend['key'], 687 'key' => $extend['key'],
687 'type' => $extend['type'], 688 'type' => $extend['type'],
@@ -690,6 +691,8 @@ class ProjectUpdate extends Command @@ -690,6 +691,8 @@ class ProjectUpdate extends Command
690 'module_id' => $custom_info['id'], 691 'module_id' => $custom_info['id'],
691 'values' => $value, 692 'values' => $value,
692 ]); 693 ]);
  694 + } else {
  695 + $extend_info_model->edit(['type' => $extend['type'], 'values' => $value], ['key' => $extend['key'], 'content_id' => $id]);
693 } 696 }
694 } 697 }
695 } 698 }
@@ -939,7 +942,7 @@ class ProjectUpdate extends Command @@ -939,7 +942,7 @@ class ProjectUpdate extends Command
939 } 942 }
940 943
941 //资源下载 944 //资源下载
942 - protected function source_download($url, $project_id, $domain, $web_url_domain, $home_url) 945 + protected function source_download($url, $project_id, $domain, $web_url_domain, $home_url, $same_name = 0)
943 { 946 {
944 if (!$url) { 947 if (!$url) {
945 return ''; 948 return '';
@@ -961,7 +964,7 @@ class ProjectUpdate extends Command @@ -961,7 +964,7 @@ class ProjectUpdate extends Command
961 $path = '/' . $path; 964 $path = '/' . $path;
962 } 965 }
963 $url_complete = ($scheme ?: 'https') . '://' . $domain . $path; 966 $url_complete = ($scheme ?: 'https') . '://' . $domain . $path;
964 - $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete); 967 + $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete, '', '', $same_name);
965 968
966 if ($new_url) { 969 if ($new_url) {
967 CollectSource::insert([ 970 CollectSource::insert([
@@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel @@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel
25 $schedule->command('rank_data_recomm_domain')->dailyAt('01:40')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 25 $schedule->command('rank_data_recomm_domain')->dailyAt('01:40')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
26 $schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 26 $schedule->command('rank_data_week')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
27 // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 27 // $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
28 - $schedule->command('count')->dailyAt('01:30')->withoutOverlapping(1); //每天凌晨1点执行一次 28 +// $schedule->command('count')->dailyAt('00:30')->withoutOverlapping(1); //每天凌晨1点执行一次
29 $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次 29 $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
30 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 30 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
31 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 31 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
@@ -34,7 +34,7 @@ class Kernel extends ConsoleKernel @@ -34,7 +34,7 @@ class Kernel extends ConsoleKernel
34 $schedule->command('web_traffic_russia 2')->cron('*/18 * * * *'); // 俄语站引流 4-8个月的项目,18分钟一次 34 $schedule->command('web_traffic_russia 2')->cron('*/18 * * * *'); // 俄语站引流 4-8个月的项目,18分钟一次
35 $schedule->command('web_traffic_russia 3')->cron('*/12 * * * *'); // 俄语站引流 大于9个月的项目,12分钟一次 35 $schedule->command('web_traffic_russia 3')->cron('*/12 * * * *'); // 俄语站引流 大于9个月的项目,12分钟一次
36 $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次 36 $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
37 - $schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录 37 +// $schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录
38 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 38 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
39 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次 39 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
40 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 40 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
@@ -46,12 +46,11 @@ class Kernel extends ConsoleKernel @@ -46,12 +46,11 @@ class Kernel extends ConsoleKernel
46 // $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件 46 // $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件
47 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 47 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
48 48
49 - $schedule->command('recommended_suppliers')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商  
50 - $schedule->command('notice_c')->dailyAt('02:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 49 + $schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
51 // 每日推送视频任务 50 // 每日推送视频任务
52 - $schedule->command('video_task')->dailyAt('01:30')->withoutOverlapping(1); 51 + $schedule->command('video_task')->dailyAt('03:30')->withoutOverlapping(1);
53 // 每日推送已完成视频任务项目生成对应界面 52 // 每日推送已完成视频任务项目生成对应界面
54 - $schedule->command('notice_c')->dailyAt('02:00')->withoutOverlapping(1); 53 + $schedule->command('notice_c')->dailyAt('04:00')->withoutOverlapping(1);
55 } 54 }
56 55
57 /** 56 /**
@@ -16,6 +16,7 @@ use App\Models\RouteMap\RouteMap; @@ -16,6 +16,7 @@ use App\Models\RouteMap\RouteMap;
16 use App\Models\User\User; 16 use App\Models\User\User;
17 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
18 use Illuminate\Http\Request; 18 use Illuminate\Http\Request;
  19 +use Illuminate\Support\Facades\DB;
19 20
20 /** 21 /**
21 * Class PrivateController 22 * Class PrivateController
@@ -127,4 +128,18 @@ class PrivateController extends BaseController @@ -127,4 +128,18 @@ class PrivateController extends BaseController
127 128
128 return $this->success($result); 129 return $this->success($result);
129 } 130 }
  131 +
  132 + /**
  133 + * v6 有效用户
  134 + * @param Request $request
  135 + * @return false|string
  136 + */
  137 + public function validUser(Request $request)
  138 + {
  139 + // 排除演示项目数据
  140 + $valid_user = User::select(['gl_project_user.mobile'])->leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_user.project_id')->where(['delete_status' => 0, 'is_upgrade' => Project::IS_UPGRADE_FALSE])->where('gl_project.id', '>', 1)->pluck('mobile')->toArray();
  141 + $upgrade_user = User::select(['gl_project_user.mobile'])->leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_user.project_id')->where(['delete_status' => 0, 'is_upgrade' => Project::IS_UPGRADE_TRUE])->where('gl_project.type', '>', Project::TYPE_ONE)->pluck('mobile')->toArray();
  142 + $user = array_unique(array_merge($valid_user, $upgrade_user));
  143 + return $this->success($user);
  144 + }
130 } 145 }
@@ -29,7 +29,7 @@ class KeywordsController extends BaseController @@ -29,7 +29,7 @@ class KeywordsController extends BaseController
29 ->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray(); 29 ->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray();
30 $projectModel = new Project(); 30 $projectModel = new Project();
31 $lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build') 31 $lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build')
32 - ->with('deploy_optimize')->get()->toArray(); 32 + ->with('deploy_optimize')->with('domainInfo')->get()->toArray();
33 $this->response('success',Code::SUCCESS,$lists); 33 $this->response('success',Code::SUCCESS,$lists);
34 } 34 }
35 } 35 }
@@ -114,6 +114,7 @@ class ProjectController extends BaseController @@ -114,6 +114,7 @@ class ProjectController extends BaseController
114 'gl_project_deploy_optimize.quality_mid AS quality_mid', 114 'gl_project_deploy_optimize.quality_mid AS quality_mid',
115 'gl_project_deploy_optimize.design_mid AS design_mid', 115 'gl_project_deploy_optimize.design_mid AS design_mid',
116 'gl_project_deploy_optimize.api_no AS api_no', 116 'gl_project_deploy_optimize.api_no AS api_no',
  117 + 'gl_project_deploy_optimize.brand_keyword AS brand_keyword',
117 ]; 118 ];
118 return $select; 119 return $select;
119 } 120 }
@@ -264,8 +265,8 @@ class ProjectController extends BaseController @@ -264,8 +265,8 @@ class ProjectController extends BaseController
264 if(isset($this->map['tech_mid'])){ 265 if(isset($this->map['tech_mid'])){
265 $query = $query->where('gl_project_deploy_optimize.tech_mid',$this->map['tech_mid']); 266 $query = $query->where('gl_project_deploy_optimize.tech_mid',$this->map['tech_mid']);
266 } 267 }
267 - if(isset($this->map['optimist_mid'])){  
268 - $query = $query->where('gl_project_deploy_optimize.optimist_mid',$this->map['optimist_mid']); 268 + if(isset($this->map['optimize_optimist_mid'])){
  269 + $query = $query->where('gl_project_deploy_optimize.optimist_mid',$this->map['optimize_optimist_mid']);
269 } 270 }
270 return $query; 271 return $query;
271 } 272 }
@@ -18,6 +18,7 @@ use App\Models\Project\Project; @@ -18,6 +18,7 @@ use App\Models\Project\Project;
18 use App\Models\RouteMap\RouteMap; 18 use App\Models\RouteMap\RouteMap;
19 use App\Models\WebSetting\WebLanguage; 19 use App\Models\WebSetting\WebLanguage;
20 use Illuminate\Http\Request; 20 use Illuminate\Http\Request;
  21 +use Illuminate\Support\Facades\DB;
21 22
22 23
23 /** 24 /**
@@ -169,7 +170,9 @@ class CNoticeController extends BaseController @@ -169,7 +170,9 @@ class CNoticeController extends BaseController
169 $ids = explode(',',$info['country_lists']); 170 $ids = explode(',',$info['country_lists']);
170 } 171 }
171 $languageModel = new WebLanguage(); 172 $languageModel = new WebLanguage();
172 - $lists = $languageModel->list(['id'=>['in',$ids]]); 173 + //根据排序查询选中的小语种
  174 + $lists = $languageModel->whereIn('id', $ids)->orderByRaw(DB::raw("FIND_IN_SET(id,'" . implode(',', $ids) . "'" . ')'))->get()->toArray();
  175 +// $lists = $languageModel->list(['id'=>['in',$ids]]);
173 $this->response('success',Code::SUCCESS,$lists); 176 $this->response('success',Code::SUCCESS,$lists);
174 } 177 }
175 178
@@ -30,6 +30,7 @@ class ProjectKeywordController extends BaseController @@ -30,6 +30,7 @@ class ProjectKeywordController extends BaseController
30 } 30 }
31 $data['search_keywords'] = $info['search_keywords']; 31 $data['search_keywords'] = $info['search_keywords'];
32 $data['customer_keywords'] = $info['customer_keywords']; 32 $data['customer_keywords'] = $info['customer_keywords'];
  33 + $data['brand_keyword'] = $info['brand_keyword'];
33 $this->response('success',Code::SUCCESS,$data); 34 $this->response('success',Code::SUCCESS,$data);
34 } 35 }
35 36
@@ -235,9 +235,15 @@ class LoginController extends BaseController @@ -235,9 +235,15 @@ class LoginController extends BaseController
235 * @time :2023/8/24 17:37 235 * @time :2023/8/24 17:37
236 */ 236 */
237 public function globalSo_v6_login(UserLoginLogic $logic){ 237 public function globalSo_v6_login(UserLoginLogic $logic){
238 - $common = new Common();  
239 - $arr = $common->decrypt(urldecode($this->param['token']));  
240 - if(empty($arr)){ 238 + $this->param = $this->request->validate([
  239 + 'token' => 'required',
  240 + ],[
  241 + 'token.required' => 'token不能为空',
  242 + ]);
  243 + try {
  244 + $common = new Common();
  245 + $arr = $common->decrypt(urldecode($this->param['token']));
  246 + }catch (\Exception $e){
241 $this->response('非法请求!',Code::USER_ERROR); 247 $this->response('非法请求!',Code::USER_ERROR);
242 } 248 }
243 if (empty($arr['timestamp']) || time() - $arr['timestamp'] > 60) { 249 if (empty($arr['timestamp']) || time() - $arr['timestamp'] > 60) {
@@ -410,7 +410,7 @@ class DomainInfoLogic extends BaseLogic @@ -410,7 +410,7 @@ class DomainInfoLogic extends BaseLogic
410 //创建站点,设置证书 410 //创建站点,设置证书
411 $this->param['key'] = $this->param['private_key'] ?? ''; 411 $this->param['key'] = $this->param['private_key'] ?? '';
412 $this->param['cert'] = $this->param['private_cert'] ?? ''; 412 $this->param['cert'] = $this->param['private_cert'] ?? '';
413 - $this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],0); 413 + $this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],1);
414 } 414 }
415 415
416 return $this->success(); 416 return $this->success();
@@ -778,7 +778,7 @@ class ProjectLogic extends BaseLogic @@ -778,7 +778,7 @@ class ProjectLogic extends BaseLogic
778 $token = $common->encrypt($param); 778 $token = $common->encrypt($param);
779 $res = Http::withoutVerifying()->get($url, ['token' => $token])->json(); 779 $res = Http::withoutVerifying()->get($url, ['token' => $token])->json();
780 if(empty($res['code']) || $res['code'] != 200){ 780 if(empty($res['code']) || $res['code'] != 200){
781 - $this->fail('ProjectToHagro error'); 781 + $this->fail($res['msg']);
782 } 782 }
783 return true; 783 return true;
784 } 784 }
@@ -123,7 +123,8 @@ class NavLogic extends BaseLogic @@ -123,7 +123,8 @@ class NavLogic extends BaseLogic
123 'remark'=>$param['remark'] ?? '', 123 'remark'=>$param['remark'] ?? '',
124 'group_id'=>$param['group_id'], 124 'group_id'=>$param['group_id'],
125 'show'=>$param['show'] ?? 0, 125 'show'=>$param['show'] ?? 0,
126 - 'class'=>$param['class'] ?? '' 126 + 'class'=>$param['class'] ?? '',
  127 + 'rel'=>$param['rel'] ?? '',
127 ]; 128 ];
128 return $this->success($data); 129 return $this->success($data);
129 } 130 }
@@ -34,7 +34,7 @@ class TranslateLogic extends BaseLogic @@ -34,7 +34,7 @@ class TranslateLogic extends BaseLogic
34 if($this->param['url'] == 'All'){ 34 if($this->param['url'] == 'All'){
35 $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); 35 $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
36 if(!empty($info) && !empty($info['data'])){ 36 if(!empty($info) && !empty($info['data'])){
37 - $translateInfo = json_decode($info['data'],JSON_UNESCAPED_UNICODE); 37 + $translateInfo = json_decode($info['data']);
38 foreach ($translateInfo as $k => $v){ 38 foreach ($translateInfo as $k => $v){
39 $data[] = [$k=>$v]; 39 $data[] = [$k=>$v];
40 } 40 }
@@ -47,22 +47,18 @@ class TranslateLogic extends BaseLogic @@ -47,22 +47,18 @@ class TranslateLogic extends BaseLogic
47 $languageInfo = $this->getLanguage($this->param['language_id']); 47 $languageInfo = $this->getLanguage($this->param['language_id']);
48 // 原始校对内容 48 // 原始校对内容
49 $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); 49 $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
50 - //获取当前URl的所有文本内容  
51 - $text_array = $this->getUrlRead($url);  
52 - // 原始校对程序  
53 - $old_key = [];//key值组成数据  
54 if($info !== false){ 50 if($info !== false){
55 - $data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE); 51 + $data_read = json_decode($info['data']);
56 foreach ($data_read as $k => $v){ 52 foreach ($data_read as $k => $v){
57 - $old_key[] = $k;  
58 $data[] = [$k => $v]; 53 $data[] = [$k => $v];
59 } 54 }
60 - }  
61 - $arr2 = array_values(array_diff($text_array, $old_key));  
62 - if(!empty($arr2)){ 55 + return $this->success($data);
  56 + }else{
  57 + //获取当前URl的所有文本内容
  58 + $text_array = $this->getUrlRead($url);
63 $i = 0; 59 $i = 0;
64 TranslateText: 60 TranslateText:
65 - $translate_list = Translate::tran($arr2, $languageInfo['short']); 61 + $translate_list = Translate::tran($text_array, $languageInfo['short']);
66 if(empty($translate_list)){ 62 if(empty($translate_list)){
67 if ($i < 3) { 63 if ($i < 3) {
68 $i++; 64 $i++;
@@ -70,43 +66,57 @@ class TranslateLogic extends BaseLogic @@ -70,43 +66,57 @@ class TranslateLogic extends BaseLogic
70 } 66 }
71 $this->fail('翻译失败,请稍后重试!'); 67 $this->fail('翻译失败,请稍后重试!');
72 } 68 }
73 - if(count($arr2) == 1){ 69 + if(count($text_array) == 1){
74 $data[] = [ 70 $data[] = [
75 - $arr2[0]=>$translate_list 71 + $text_array[0]=>$translate_list
76 ]; 72 ];
77 }else{ 73 }else{
78 - foreach ($arr2 as $k => $v){ 74 + foreach ($text_array as $k => $v){
79 $data[] = [ 75 $data[] = [
80 - trim($v)=>$translate_list[$k] 76 + $v=>$translate_list[$k]
81 ]; 77 ];
82 } 78 }
83 -  
84 } 79 }
  80 + return $this->success($data);
85 } 81 }
86 - $data = $this->unique_multidimensional_array($data);  
87 - return $this->success($data);  
88 } 82 }
89 83
90 - /**  
91 - * @remark :多维数组去重  
92 - * @name :unique_multidimensional_array  
93 - * @author :lyh  
94 - * @method :post  
95 - * @time :2024/3/8 16:38  
96 - */  
97 - public function unique_multidimensional_array($array) {  
98 - $tempArray = [];  
99 - $uniqueArray = [];  
100 - foreach ($array as $value) {  
101 - // 使用键作为临时数组的键,如果不存在则添加到去重后的数组中  
102 - $key = key($value);  
103 - if (!isset($tempArray[$key])) {  
104 - $tempArray[$key] = true;  
105 - $uniqueArray[] = $value;  
106 - }  
107 - }  
108 - return $uniqueArray;  
109 - } 84 + // $old_key = [];//key值组成数据
  85 + // if($info !== false){
  86 + // $data_read = json_decode($info['data']);
  87 + // foreach ($data_read as $k => $v){
  88 + //// if(!in_array($k,$text_array)){
  89 + //// $arr2[] = $k;
  90 + //// }
  91 + //// $old_key[] = $k;
  92 + // $data[] = [$k => $v];
  93 + // }
  94 + // }else{
  95 + // $arr2 = array_values(array_diff($text_array, $old_key));
  96 + // }
  97 + // if(!empty($arr2)){
  98 + // $i = 0;
  99 + // TranslateText:
  100 + // $translate_list = Translate::tran($arr2, $languageInfo['short']);
  101 + // if(empty($translate_list)){
  102 + // if ($i < 3) {
  103 + // $i++;
  104 + // goto TranslateText;
  105 + // }
  106 + // $this->fail('翻译失败,请稍后重试!');
  107 + // }
  108 + // if(count($arr2) == 1){
  109 + // $data[] = [
  110 + // $arr2[0]=>$translate_list
  111 + // ];
  112 + // }else{
  113 + // foreach ($arr2 as $k => $v){
  114 + // $data[] = [
  115 + // $v=>$translate_list[$k]
  116 + // ];
  117 + // }
  118 + // }
  119 + // }
110 120
111 /** 121 /**
112 * @remark :获取图片列表 122 * @remark :获取图片列表
@@ -120,7 +130,7 @@ class TranslateLogic extends BaseLogic @@ -120,7 +130,7 @@ class TranslateLogic extends BaseLogic
120 $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); 130 $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
121 $data = []; 131 $data = [];
122 if(!empty($info) && !empty($info['data'])){ 132 if(!empty($info) && !empty($info['data'])){
123 - $translateInfo = json_decode($info['data'],JSON_UNESCAPED_UNICODE); 133 + $translateInfo = json_decode($info['data']);
124 foreach ($translateInfo as $k => $v){ 134 foreach ($translateInfo as $k => $v){
125 $data[] = [$k=>$v]; 135 $data[] = [$k=>$v];
126 } 136 }
@@ -141,7 +151,7 @@ class TranslateLogic extends BaseLogic @@ -141,7 +151,7 @@ class TranslateLogic extends BaseLogic
141 } 151 }
142 $new_list = $this->getUrlImageRead($url); 152 $new_list = $this->getUrlImageRead($url);
143 $old_list = []; 153 $old_list = [];
144 - $data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE); 154 + $data_read = json_decode($info['data']);
145 foreach ($data_read as $k=>$v){ 155 foreach ($data_read as $k=>$v){
146 $old_list[] = $k; 156 $old_list[] = $k;
147 $data[] = [ 157 $data[] = [
@@ -203,7 +213,9 @@ class TranslateLogic extends BaseLogic @@ -203,7 +213,9 @@ class TranslateLogic extends BaseLogic
203 if(FALSE !== strpos($country_class, 'country-flag')) { 213 if(FALSE !== strpos($country_class, 'country-flag')) {
204 continue; 214 continue;
205 } 215 }
206 - $need_tran[] = htmlspecialchars_decode(html_entity_decode($string)); 216 + if(!in_array(htmlspecialchars_decode(html_entity_decode($string)),$need_tran)){
  217 + $need_tran[] = htmlspecialchars_decode(html_entity_decode($string));
  218 + }
207 } 219 }
208 $need_tran[] = $description ? $description->attr['content'] : ''; 220 $need_tran[] = $description ? $description->attr['content'] : '';
209 $need_tran[] = $keywords ? $keywords->attr['content'] : ''; 221 $need_tran[] = $keywords ? $keywords->attr['content'] : '';
@@ -270,10 +282,10 @@ class TranslateLogic extends BaseLogic @@ -270,10 +282,10 @@ class TranslateLogic extends BaseLogic
270 'language_id'=>$this->param['language_id'], 282 'language_id'=>$this->param['language_id'],
271 'alias'=>$this->param['alias'], 283 'alias'=>$this->param['alias'],
272 ]; 284 ];
273 - $param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE); 285 + $param['data'] = json_encode($data);
274 $this->model->add($param); 286 $this->model->add($param);
275 }else{ 287 }else{
276 - $data = json_encode($data,JSON_UNESCAPED_UNICODE); 288 + $data = json_encode($data);
277 $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]); 289 $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
278 } 290 }
279 }catch (\Exception $e){ 291 }catch (\Exception $e){
@@ -29,7 +29,7 @@ class WebSettingAmpLogic extends BaseLogic @@ -29,7 +29,7 @@ class WebSettingAmpLogic extends BaseLogic
29 } 29 }
30 //log图处理 30 //log图处理
31 $info['top_logo'] = Arr::s2a($info['top_logo']); 31 $info['top_logo'] = Arr::s2a($info['top_logo']);
32 - if(!empty($info['top_logo'])){ 32 + if (!empty($info['top_logo'])) {
33 $info['top_logo']['url'] = getImageUrl($info['top_logo']['url'], $this->user['storage_type'], $this->user['project_location']); 33 $info['top_logo']['url'] = getImageUrl($info['top_logo']['url'], $this->user['storage_type'], $this->user['project_location']);
34 } 34 }
35 //banner处理 35 //banner处理
@@ -39,6 +39,13 @@ class WebSettingAmpLogic extends BaseLogic @@ -39,6 +39,13 @@ class WebSettingAmpLogic extends BaseLogic
39 $v['url'] = getImageUrl($v['url'], $this->user['storage_type'], $this->user['project_location']); 39 $v['url'] = getImageUrl($v['url'], $this->user['storage_type'], $this->user['project_location']);
40 } 40 }
41 } 41 }
  42 + //公司主图处理
  43 + $info['company_image'] = Arr::s2a($info['company_image']);
  44 + if (!empty($info['company_image'])) {
  45 + $info['company_image']['url'] = getImageUrl($info['company_image']['url'], $this->user['storage_type'], $this->user['project_location']);
  46 + }
  47 + //icon处理
  48 + $info['web_icon'] = getImageUrl($info['web_icon']);
42 return $this->success($info); 49 return $this->success($info);
43 } 50 }
44 51
@@ -65,6 +72,13 @@ class WebSettingAmpLogic extends BaseLogic @@ -65,6 +72,13 @@ class WebSettingAmpLogic extends BaseLogic
65 } 72 }
66 } 73 }
67 $this->param['index_banner'] = Arr::a2s($index_banner); 74 $this->param['index_banner'] = Arr::a2s($index_banner);
  75 + //公司主图处理
  76 + if (isset($this->param['company_image']) && $this->param['company_image']) {
  77 + $this->param['company_image']['url'] = str_replace_url($this->param['company_image']['url'] ?? '');
  78 + }
  79 + $this->param['company_image'] = Arr::a2s($this->param['company_image'] ?? []);
  80 + //icon处理
  81 + $this->param['web_icon'] = str_replace_url($this->param['web_icon'] ?? '');
68 82
69 $info = $this->model->read(['project_id' => $this->user['project_id']]); 83 $info = $this->model->read(['project_id' => $this->user['project_id']]);
70 if ($info === false) { 84 if ($info === false) {
@@ -227,9 +227,10 @@ class Project extends Base @@ -227,9 +227,10 @@ class Project extends Base
227 */ 227 */
228 public function domainInfo() 228 public function domainInfo()
229 { 229 {
230 - return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'project_id')->select('project_id', 'domain');; 230 + return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'id')->select('project_id', 'domain');
231 } 231 }
232 232
  233 +
233 public function setLevelAttribute($value) 234 public function setLevelAttribute($value)
234 { 235 {
235 $this->attributes['level'] = Arr::arrToSet($value); 236 $this->attributes['level'] = Arr::arrToSet($value);
@@ -72,17 +72,24 @@ class CosService @@ -72,17 +72,24 @@ class CosService
72 * @param $file_url 72 * @param $file_url
73 * @param $key 73 * @param $key
74 * @param $body_str 74 * @param $body_str
  75 + * @param int $same_name 是否保持名称一直
75 * @return string 76 * @return string
76 * @author Akun 77 * @author Akun
77 * @date 2023/09/21 9:39 78 * @date 2023/09/21 9:39
78 */ 79 */
79 - public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='') 80 + public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='',$same_name=0)
80 { 81 {
81 if(!$key){ 82 if(!$key){
82 $url_arr = parse_url($file_url); 83 $url_arr = parse_url($file_url);
83 - $ext = explode('.',$url_arr['path']);  
84 84
85 - $filename = uniqid().rand(10000,99999).'.'.end($ext); 85 + if($same_name){
  86 + $path_arr = explode('/',$url_arr['path']);
  87 + $filename = end($path_arr);
  88 + }else{
  89 + $ext = explode('.',$url_arr['path']);
  90 +
  91 + $filename = uniqid().rand(10000,99999).'.'.end($ext);
  92 + }
86 93
87 $uploads = config('upload.default_file'); 94 $uploads = config('upload.default_file');
88 $path = $uploads['path_b'].'/'.$project_id.'/'.$image_type.'/'.date('Y-m'); 95 $path = $uploads['path_b'].'/'.$project_id.'/'.$image_type.'/'.date('Y-m');
@@ -5,7 +5,11 @@ @@ -5,7 +5,11 @@
5 * Date: 2024/2/19 5 * Date: 2024/2/19
6 * Time: 15:46 6 * Time: 15:46
7 */ 7 */
8 -namespace App\Services; 8 +namespace App\Services\Html;
  9 +
  10 +use App\Models\Project\Project;
  11 +use App\Models\RouteMap\RouteMap;
  12 +use App\Services\TdkService;
9 13
10 class CreateHtmlService 14 class CreateHtmlService
11 { 15 {
@@ -15,40 +19,51 @@ class CreateHtmlService @@ -15,40 +19,51 @@ class CreateHtmlService
15 * 返回最终需要的HTML 19 * 返回最终需要的HTML
16 * @return string 20 * @return string
17 */ 21 */
18 - public function getHtml($project, $route, $lang = [], $page = 0) 22 + public function getHtml($project_id, $route, $lang = [], $page = 0)
19 { 23 {
20 - // 获取页面信息  
21 - $page_info = $this->getInfoByRoute($route);  
22 -  
23 - // 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;  
24 - if ($project && $page_info) {  
25 - $html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);  
26 - } else {  
27 - $html = $this->getHtmlV5(); 24 + $projectModel = new Project();
  25 + $projectInfo = $projectModel->with(['payment', 'deploy_build'])->where(['id'=>$project_id])->first()->toArray();
  26 + $routeMapModel = new RouteMap();
  27 + $routeInfo = $routeMapModel->read(['route'=>$route]);
  28 + if($routeInfo === false){
  29 + if($route == 'top-search' || $route == 'products' || $route == 'news' || $route == 'blog'){
  30 + $html = '';
  31 + }else{
  32 + $html = '';
  33 + }
  34 + }else{
  35 + //TODO::5.0,6.0获取html,自定义页面还需要单独处理
  36 + if(($routeInfo['source'] == RouteMap::SOURCE_PAGE) && ($route != 'index')){
  37 + $customTemplateService = new CustomTemplateService();
  38 + $data = $customTemplateService->getHtml($projectInfo,$routeInfo['source_id']);
  39 + if($data === false){
  40 + return false;
  41 + }
  42 + $html = $data['html'];
  43 + }else{
  44 + $generatePageService = new GeneratePageService();
  45 + $data = $generatePageService->generateHtml($projectInfo,$routeInfo);
  46 + if($data === false){
  47 + return false;
  48 + }
  49 + $html = $data['html'];
  50 + }
28 } 51 }
29 - return $html;  
30 - }  
31 -  
32 - /**  
33 - * 返回5.0页面最终HTML  
34 - * @return string  
35 - */  
36 - public function getHtmlV5()  
37 - {  
38 - $html = '';  
39 - return $html; 52 + //处理页面tdk
  53 + $tdkService = new TdkService();
  54 + $html = $tdkService->pageTdkHandle($projectInfo,$html,$routeInfo['source'],$routeInfo);
  55 + return ['html'=>$html];
40 } 56 }
41 57
42 /** 58 /**
43 * 返回6.0页面最终HTML 59 * 返回6.0页面最终HTML
44 * @return mixed 60 * @return mixed
45 */ 61 */
46 - public function getHtmlV6($master_lang, $lang = [], $page = 0) 62 + public function getHtmlV6($project_id,$route)
47 { 63 {
48 // 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息 64 // 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息
49 -  
50 - $origin_html = $this->originHtml();  
51 - $html = $this->renderData($origin_html, $page); 65 + $origin_html = $this->originHtml($project_id,$route);
  66 + $html = $this->renderData($origin_html);
52 $html = $this->plugHead($html); 67 $html = $this->plugHead($html);
53 $html = $this->processFinal($html); 68 $html = $this->processFinal($html);
54 /** ... 调用其他方法, 直至返回完整的正确的HTML */ 69 /** ... 调用其他方法, 直至返回完整的正确的HTML */
@@ -62,18 +77,26 @@ class CreateHtmlService @@ -62,18 +77,26 @@ class CreateHtmlService
62 */ 77 */
63 public function getInfoByRoute($route) 78 public function getInfoByRoute($route)
64 { 79 {
  80 + $routeMapModel = new RouteMap();
  81 + $routeInfo = $routeMapModel->read(['route'=>$route]);
  82 + if($routeInfo === false){
  83 + if($route == 'top-search' || $route == 'products' || $route == 'news' || $route == 'blog'){
  84 + $routeInfo = $route;
  85 + }else{
  86 + $routeInfo = [];
  87 + }
  88 + }
65 // TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息 89 // TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
66 - return []; 90 + return $routeInfo;
67 } 91 }
68 92
69 /** 93 /**
70 * 获取可视化HTML 94 * 获取可视化HTML
71 * @return string 95 * @return string
72 */ 96 */
73 - public function originHtml() 97 + public function originHtml($project_id,$route)
74 { 98 {
75 - $html = '根据路由查询数据库,并拼装HTML';  
76 - return $html; 99 +
77 } 100 }
78 101
79 /** 102 /**
@@ -113,4 +136,4 @@ class CreateHtmlService @@ -113,4 +136,4 @@ class CreateHtmlService
113 */ 136 */
114 return $html; 137 return $html;
115 } 138 }
116 -}  
  139 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomTemplateService.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/3/11 16:15
  8 + */
  9 +
  10 +namespace App\Services\Html;
  11 +
  12 +use App\Models\Project\PageSetting;
  13 +use App\Models\Service\Service as ServiceSettingModel;
  14 +use App\Models\Template\BTemplate;
  15 +use App\Models\Template\BTemplateCommon;
  16 +use App\Models\Template\Setting;
  17 +
  18 +class CustomTemplateService
  19 +{
  20 + /**
  21 + * @remark :获取当前自定义界面详情
  22 + * @name :customTemplateInfo
  23 + * @author :lyh
  24 + * @method :post
  25 + * @time :2023/6/29 16:23
  26 + */
  27 + public function getHtml($projectInfo,$custom_id){
  28 + $info = $this->model->read(['id'=>$custom_id]);
  29 + if($info === false){
  30 + return false;
  31 + }
  32 + if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
  33 + $html = $this->getBodyHeaderFooter($projectInfo,$info['html'],$info['html_style']);
  34 + $info['html'] = $this->getHeadFooter($html);
  35 + }
  36 + return ['html'=>$info['html']];
  37 + }
  38 +
  39 + /**
  40 + * @remark :获取body的详情
  41 + * @name :getBodyHeaderFooter
  42 + * @author :lyh
  43 + * @method :post
  44 + * @time :2023/7/21 18:08
  45 + */
  46 + public function getBodyHeaderFooter($projectInfo,$preg_html,$html_style){
  47 + if(empty($preg_html)){
  48 + $preg_html = "<main></main>";
  49 + $html_style = "<style id='globalsojs-styles'></style>";
  50 + }
  51 + //获取设置的默认模版
  52 + $bSettingModel = new Setting();
  53 + $info = $bSettingModel->read(['project_id'=>$projectInfo['id']]);
  54 + if($info === false){
  55 + return false;
  56 + }
  57 + //获取type类型
  58 + $commonInfo = $this->getCommonPage($projectInfo,$info['template_id']);
  59 + $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
  60 + $commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
  61 + return ['html'=>$html];
  62 + }
  63 +
  64 + /**
  65 + * @remark :根据类型获取公共头和底
  66 + * @name :getCommonPage
  67 + * @author :lyh
  68 + * @method :post
  69 + */
  70 + public function getCommonPage($projectInfo,$template_id){
  71 + $is_head = $projectInfo['deploy_build']['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  72 + if(isset($is_head) && ($is_head != 0)) {
  73 + //查看页面是否设置自定义头部底部
  74 + $pageSettingModel = new PageSetting();
  75 + $pageInfo = $pageSettingModel->read(['project_id' => $projectInfo['id']]);
  76 + if ($pageInfo !== false) {
  77 + $commonTemplateModel = new BTemplateCommon();
  78 + if ($pageInfo['page_list'] != 0) {
  79 + //使用独立头和底
  80 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $projectInfo['id'], 'type' => 9]);
  81 + }
  82 + }
  83 + }
  84 + if(!isset($commonInfo) || $commonInfo === false){
  85 + //获取首页公共的头部和底部
  86 + $commonTemplateModel = new BTemplateCommon();
  87 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$projectInfo['id'],'type'=>1]);
  88 + }
  89 + return $commonInfo;
  90 + }
  91 +
  92 + /**
  93 + * @remark :拼接获取公共头部底部
  94 + * @name :getHeadFooter
  95 + * @author :lyh
  96 + * @method :post
  97 + */
  98 + public function getHeadFooter($html = ''){
  99 + //获取公共主题头部底部
  100 + $serviceSettingModel = new ServiceSettingModel();
  101 + $list = $serviceSettingModel->list(['type'=>2],'created_at');
  102 + //拼接html
  103 + foreach ($list as $v){
  104 + if($v['key'] == 'head'){
  105 + $html = $v['values'].$html;
  106 + }
  107 + if($v['key'] == 'footer'){
  108 + $html = $html.$v['values'];
  109 + }
  110 + }
  111 + return $html;
  112 + }
  113 +}
@@ -7,19 +7,20 @@ @@ -7,19 +7,20 @@
7 * @time :2024/2/19 15:54 7 * @time :2024/2/19 15:54
8 */ 8 */
9 9
10 -namespace App\Services; 10 +namespace App\Services\Html;
11 11
12 use App\Models\CustomModule\CustomModule; 12 use App\Models\CustomModule\CustomModule;
13 use App\Models\CustomModule\CustomModuleCategory; 13 use App\Models\CustomModule\CustomModuleCategory;
14 use App\Models\CustomModule\CustomModuleContent; 14 use App\Models\CustomModule\CustomModuleContent;
  15 +use App\Models\Project\PageSetting;
15 use App\Models\Project\Project; 16 use App\Models\Project\Project;
16 use App\Models\RouteMap\RouteMap; 17 use App\Models\RouteMap\RouteMap;
17 use App\Models\Template\BTemplate; 18 use App\Models\Template\BTemplate;
18 use App\Models\Template\BTemplateCommon; 19 use App\Models\Template\BTemplateCommon;
19 use App\Models\Template\BTemplateMain; 20 use App\Models\Template\BTemplateMain;
20 use App\Models\Template\Setting; 21 use App\Models\Template\Setting;
21 -use App\Models\Template\Template;  
22 use App\Models\Template\TemplateTypeMain; 22 use App\Models\Template\TemplateTypeMain;
  23 +use App\Services\ProjectServer;
23 use Illuminate\Support\Facades\DB; 24 use Illuminate\Support\Facades\DB;
24 25
25 class GeneratePageService 26 class GeneratePageService
@@ -27,13 +28,8 @@ class GeneratePageService @@ -27,13 +28,8 @@ class GeneratePageService
27 protected $route; 28 protected $route;
28 29
29 protected $param; 30 protected $param;
30 -  
31 protected $project_id = 0; 31 protected $project_id = 0;
32 - public function __construct(){  
33 - $this->param = request()->all();  
34 - $this->route = $this->param['route'];  
35 - $this->project_id = $this->param['project_id'];  
36 - } 32 +
37 33
38 /** 34 /**
39 * @remark :生成单页数据 35 * @remark :生成单页数据
@@ -42,18 +38,14 @@ class GeneratePageService @@ -42,18 +38,14 @@ class GeneratePageService
42 * @method :post 38 * @method :post
43 * @time :2024/2/19 16:57 39 * @time :2024/2/19 16:57
44 */ 40 */
45 - public function generateHtml(){ 41 + public function generateHtml($projectInfo,$routeInfo){
  42 + $this->project_id = $projectInfo['id'];
  43 + $this->route = $routeInfo['route'];
46 ProjectServer::useProject($this->project_id); 44 ProjectServer::useProject($this->project_id);
47 - $routeMapModel = new RouteMap();  
48 - $routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);  
49 - if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){  
50 - //页面管理单独处理  
51 - }else{  
52 - $this->handleParam($routeInfo);  
53 - $this->getTemplateHtml();  
54 - } 45 + $this->handleParam($routeInfo);
  46 + $result = $this->getTemplateHtml($projectInfo);
55 DB::disconnect('custom_mysql'); 47 DB::disconnect('custom_mysql');
56 - return true; 48 + return $this->success($result);
57 } 49 }
58 50
59 /** 51 /**
@@ -129,14 +121,17 @@ class GeneratePageService @@ -129,14 +121,17 @@ class GeneratePageService
129 * @author :lyh 121 * @author :lyh
130 * @method :post 122 * @method :post
131 */ 123 */
132 - public function getTemplateHtml(){ 124 + public function getTemplateHtml($projectInfo){
133 $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块 125 $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
134 $is_list = $this->param['is_list'] ?? 0;//是否为列表页 126 $is_list = $this->param['is_list'] ?? 0;//是否为列表页
135 - $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id 127 + $template_id = $this->getSettingTemplate($projectInfo,$this->param['source'],$is_list,$is_custom);//设置的模版id
  128 + if($template_id === false){
  129 + return false;
  130 + }
136 $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list); 131 $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
137 if($templateInfo === false){ 132 if($templateInfo === false){
138 - if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据  
139 - $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list); 133 + if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
  134 + $html = $this->customizedReturnHtml($projectInfo,$this->param['source'],$template_id,$is_custom,$is_list);
140 if($html !== false){ 135 if($html !== false){
141 return $this->success($html); 136 return $this->success($html);
142 } 137 }
@@ -149,10 +144,10 @@ class GeneratePageService @@ -149,10 +144,10 @@ class GeneratePageService
149 } 144 }
150 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; 145 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
151 } 146 }
152 - $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部 147 + $commonInfo = $this->getCommonHtml($projectInfo,$this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
153 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; 148 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
154 $html = $this->getHeadFooter($html); 149 $html = $this->getHeadFooter($html);
155 - $result = ['html'=>$html,'template_id'=>$template_id]; 150 + $result = ['html'=>$html];
156 return $this->success($result); 151 return $this->success($result);
157 } 152 }
158 153
@@ -185,7 +180,7 @@ class GeneratePageService @@ -185,7 +180,7 @@ class GeneratePageService
185 public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){ 180 public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
186 $templateInfo = $this->model->read([ 181 $templateInfo = $this->model->read([
187 'template_id'=>$template_id, 'source'=>$source, 182 'template_id'=>$template_id, 'source'=>$source,
188 - 'project_id'=>$this->user['project_id'], 'source_id'=>$source_id, 183 + 'project_id'=>$this->project_id, 'source_id'=>$source_id,
189 'is_custom'=>$is_custom, 'is_list'=>$is_list 184 'is_custom'=>$is_custom, 'is_list'=>$is_list
190 ]); 185 ]);
191 return $this->success($templateInfo); 186 return $this->success($templateInfo);
@@ -198,29 +193,35 @@ class GeneratePageService @@ -198,29 +193,35 @@ class GeneratePageService
198 * @method :post 193 * @method :post
199 * @time :2024/1/10 13:46 194 * @time :2024/1/10 13:46
200 */ 195 */
201 - public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){ 196 + public function customizedReturnHtml($projectInfo,$source,$template_id,$is_custom,$is_list){
202 //TODO::扩展模块定制单独处理 197 //TODO::扩展模块定制单独处理
203 if($is_custom == BTemplate::IS_CUSTOM){ 198 if($is_custom == BTemplate::IS_CUSTOM){
204 $customModuleModel = new CustomModule(); 199 $customModuleModel = new CustomModule();
205 $info = $customModuleModel->read(['id'=>$source]); 200 $info = $customModuleModel->read(['id'=>$source]);
206 if($info === false){ 201 if($info === false){
207 - $this->fail('当前扩展模块不存在或已被删除'); 202 + return false;
208 } 203 }
209 //扩展模块定制 204 //扩展模块定制
210 if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){ 205 if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
211 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); 206 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
212 - return $this->success(['html'=>$html,'template_id'=>$template_id]); 207 + if($html === false){
  208 + return false;
  209 + }
  210 + return $this->success(['html'=>$html]);
213 } 211 }
214 if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ 212 if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
215 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); 213 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
216 - return $this->success(['html'=>$html,'template_id'=>$template_id]); 214 + if($html === false){
  215 + return false;
  216 + }
  217 + return $this->success(['html'=>$html]);
217 } 218 }
218 return false; 219 return false;
219 } 220 }
220 //TODO::默认模块定制 221 //TODO::默认模块定制
221 - $html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html  
222 - if(!empty($html)){  
223 - return $this->success(['html'=>$html,'template_id'=>$template_id]); 222 + $html = $this->isCustomizedPage($projectInfo,$source,$is_list,$is_custom);//获取定制页面的html
  223 + if($html !== false){
  224 + return $this->success(['html'=>$html]);
224 } 225 }
225 return false; 226 return false;
226 } 227 }
@@ -237,7 +238,7 @@ class GeneratePageService @@ -237,7 +238,7 @@ class GeneratePageService
237 //TODO::获取初始代码 238 //TODO::获取初始代码
238 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]); 239 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
239 if($customHtmlInfo === false){ 240 if($customHtmlInfo === false){
240 - $this->fail('定制页面,请先上传代码块'); 241 + return false;
241 } 242 }
242 $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部 243 $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
243 if($commonInfo !== false){ 244 if($commonInfo !== false){
@@ -307,17 +308,17 @@ class GeneratePageService @@ -307,17 +308,17 @@ class GeneratePageService
307 * @method :post 308 * @method :post
308 * @time :2023/12/13 10:55 309 * @time :2023/12/13 10:55
309 */ 310 */
310 - public function isCustomizedPage($source,$is_list,$is_custom) 311 + public function isCustomizedPage($projectInfo,$source,$is_list,$is_custom)
311 { 312 {
312 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 313 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
313 //查看当前页面是否定制,是否开启可视化 314 //查看当前页面是否定制,是否开启可视化
314 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 315 + $page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
315 if (in_array($type, $page_array)) {//是定制界面 316 if (in_array($type, $page_array)) {//是定制界面
316 //TODO::获取初始代码 317 //TODO::获取初始代码
317 $bTemplateMainModel = new BTemplateMain(); 318 $bTemplateMainModel = new BTemplateMain();
318 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]); 319 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
319 if($customHtmlInfo === false){ 320 if($customHtmlInfo === false){
320 - $this->fail('定制页面,请先上传代码块'); 321 + return false;
321 } 322 }
322 $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 323 $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
323 if($commonInfo !== false){ 324 if($commonInfo !== false){
@@ -338,7 +339,7 @@ class GeneratePageService @@ -338,7 +339,7 @@ class GeneratePageService
338 public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){ 339 public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
339 $data = [ 340 $data = [
340 'template_id' => 0, 341 'template_id' => 0,
341 - 'project_id' => $this->user['project_id'], 342 + 'project_id' => $this->project_id,
342 'type'=>$type, 343 'type'=>$type,
343 'is_custom'=>$is_custom, 344 'is_custom'=>$is_custom,
344 'is_list'=>$is_list 345 'is_list'=>$is_list
@@ -387,9 +388,9 @@ class GeneratePageService @@ -387,9 +388,9 @@ class GeneratePageService
387 * @method :post 388 * @method :post
388 * @time :2023/12/13 10:48 389 * @time :2023/12/13 10:48
389 */ 390 */
390 - public function getSettingTemplate($source,$is_list,$is_custom){ 391 + public function getSettingTemplate($projectInfo,$source,$is_list,$is_custom){
391 $template_id = 0; 392 $template_id = 0;
392 - if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目 393 + if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
393 if($is_custom == BTemplate::IS_CUSTOM){ 394 if($is_custom == BTemplate::IS_CUSTOM){
394 $customModuleModel = new CustomModule(); 395 $customModuleModel = new CustomModule();
395 $info = $customModuleModel->read(['id'=>$source]); 396 $info = $customModuleModel->read(['id'=>$source]);
@@ -405,16 +406,16 @@ class GeneratePageService @@ -405,16 +406,16 @@ class GeneratePageService
405 }else{ 406 }else{
406 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 407 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
407 //查看当前页面是否定制,是否开启可视化 408 //查看当前页面是否定制,是否开启可视化
408 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 409 + $page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
409 if (in_array($type, $page_array)) {//是定制界面 410 if (in_array($type, $page_array)) {//是定制界面
410 return $this->success($template_id); 411 return $this->success($template_id);
411 } 412 }
412 } 413 }
413 } 414 }
414 $bSettingModel = new Setting(); 415 $bSettingModel = new Setting();
415 - $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 416 + $info = $bSettingModel->read(['project_id'=>$this->project_id]);
416 if($info === false){ 417 if($info === false){
417 - $this->fail('请先选择模版'); 418 + return false;
418 } 419 }
419 $template_id = $info['template_id']; 420 $template_id = $info['template_id'];
420 return $this->success($template_id); 421 return $this->success($template_id);
@@ -427,11 +428,11 @@ class GeneratePageService @@ -427,11 +428,11 @@ class GeneratePageService
427 * @method :post 428 * @method :post
428 * @time :2023/10/21 16:55 429 * @time :2023/10/21 16:55
429 */ 430 */
430 - public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){  
431 - $type = $this->getType($source,$is_list,$is_custom); 431 + public function getCommonHtml($ProjectInfo,$source,$is_list,$template_id,$is_custom = 0,){
  432 + $type = $this->getType($ProjectInfo,$source,$is_list,$is_custom);
432 $data = [ 433 $data = [
433 'template_id' => $template_id, 434 'template_id' => $template_id,
434 - 'project_id' => $this->user['project_id'], 435 + 'project_id' => $this->project_id,
435 'type'=>$type, 436 'type'=>$type,
436 'is_custom'=>0, 437 'is_custom'=>0,
437 ]; 438 ];
@@ -444,4 +445,36 @@ class GeneratePageService @@ -444,4 +445,36 @@ class GeneratePageService
444 return $this->success($commonInfo); 445 return $this->success($commonInfo);
445 } 446 }
446 447
  448 + /**
  449 + * @remark :(非定制)保存时获取获取设置的类型
  450 + * @name :getType
  451 + * @author :lyh
  452 + * @method :post
  453 + * @time :2023/10/21 17:29
  454 + */
  455 + public function getType($projectInfo,$source,$is_list,$is_custom = 0){
  456 + $type = BTemplate::SOURCE_HOME;//首页公共头部底部
  457 + $is_head = $projectInfo['deploy_build']['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  458 + if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
  459 + return $this->success($type);
  460 + }
  461 + //查看页面是否设置自定义头部底部
  462 + if($is_head != BTemplate::IS_NO_HEADER) {
  463 + $pageSettingModel = new PageSetting();
  464 + $pageInfo = $pageSettingModel->read(['project_id' => $projectInfo['id']]);
  465 + if ($pageInfo === false) {
  466 + return $this->success($type);
  467 + }
  468 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
  469 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
  470 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
  471 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
  472 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
  473 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
  474 + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
  475 + }
  476 + return $this->success($type);
  477 + }
  478 +
  479 +
447 } 480 }
  1 +<?php
  2 +
  3 +namespace App\Services;
  4 +
  5 +use App\Models\Blog\Blog;
  6 +use App\Models\Blog\BlogCategory;
  7 +use App\Models\CustomModule\CustomModule;
  8 +use App\Models\CustomModule\CustomModuleCategory;
  9 +use App\Models\Module\Module;
  10 +use App\Models\Module\ModuleCategory;
  11 +use App\Models\News\News;
  12 +use App\Models\News\NewsCategory;
  13 +use App\Models\Product\Category;
  14 +use App\Models\Product\Keyword;
  15 +use App\Models\RouteMap\RouteMap;
  16 +use App\Models\Template\BCustomTemplate;
  17 +use App\Models\WebSetting\WebSetting;
  18 +use App\Models\WebSetting\WebSettingSeo;
  19 +
  20 +use Illuminate\Support\Facades\Cache;
  21 +use phpQuery;
  22 +
  23 +/**
  24 + * C端处理TDK服务
  25 + */
  26 +class TdkService{
  27 + /**
  28 + * 页面TDK处理
  29 + */
  30 + public function pageTdkHandle($projectInfo,$html,$type,$routerMapInfo=null): string
  31 + {
  32 + $titleContent = "";
  33 + $descriptionContent = "";
  34 + $keywordsContent = "";
  35 + $phpQueryDom=phpQuery::newDocument($html);
  36 + //首页TDK设置
  37 + if ($type == RouteMap::SOURCE_INDEX){
  38 + $tdkInfo = $this->indexTDK($projectInfo);
  39 + }
  40 + //单页面TDK设置
  41 + if ($type == RouteMap::SOURCE_PAGE){
  42 + $tdkInfo = $this->pageTDK($projectInfo,$routerMapInfo);
  43 + }
  44 + //自定义模块列表页TDK设置
  45 + if ($type == RouteMap::SOURCE_MODULE_CATE){
  46 + $tdkInfo = $this->moduleCategoryTDK($projectInfo,$routerMapInfo);
  47 + }
  48 + //自定义模块详情页TDK设置
  49 + if ($type == RouteMap::SOURCE_MODULE){
  50 + $tdkInfo = $this->moduleDetailsTDK($projectInfo,$routerMapInfo);
  51 + }
  52 + //新闻详情TDK设置
  53 + if ($type == RouteMap::SOURCE_NEWS){
  54 + $tdkInfo = $this->newsDetailsTDK($projectInfo,$routerMapInfo);
  55 + }
  56 + //博客详情TDK设置
  57 + if ($type == RouteMap::SOURCE_BLOG){
  58 + $tdkInfo = $this->blogDetailsTDK($projectInfo,$routerMapInfo);
  59 + }
  60 + //聚合页TDK设置
  61 + if ($type == RouteMap::SOURCE_PRODUCT_KEYWORD){
  62 + $tdkInfo = $this->productKeywordsTDK($projectInfo,$routerMapInfo);
  63 + }
  64 + //新闻列表页TDK设置
  65 + if ($type == RouteMap::SOURCE_NEWS_CATE){
  66 + $tdkInfo = $this->newsCategoryTDK($projectInfo,$routerMapInfo);
  67 + }
  68 + //博客列表页TDK设置
  69 + if ($type == RouteMap::SOURCE_BLOG_CATE){
  70 + $tdkInfo = $this->blogCategoryTDK($projectInfo,$routerMapInfo);
  71 + }
  72 + //产品列表页TDK设置
  73 + if ($type == RouteMap::SOURCE_PRODUCT_CATE){
  74 + $tdkInfo = $this->productCategoryTDK($projectInfo,$routerMapInfo);
  75 + }
  76 + if (!empty($tdkInfo)){
  77 + $titleContent = strip_tags($tdkInfo["titleContent"]);
  78 + $descriptionContent = strip_tags($tdkInfo["descriptionContent"]);
  79 + $keywordsContent = strip_tags($tdkInfo["keywordsContent"]);
  80 + }
  81 + $phpQueryDom->find('title')->text($titleContent);
  82 + $phpQueryDom->find('meta[name="description"]')->attr('content', $descriptionContent);
  83 + $phpQueryDom->find('meta[name="keywords"]')->attr('content', $keywordsContent);
  84 + $phpQueryDom->find('head')->append("<meta property='og:title' content='".$titleContent."'/>");
  85 + $phpQueryDom->find('head')->append("<meta property='og:type' content='site'/>");
  86 + $phpQueryDom->find('head')->append("<meta property='og:site_name' content='".$titleContent."'/>");
  87 + $content = $phpQueryDom->htmlOuter();
  88 + unset($html,$tdkInfo,$phpQueryDom);
  89 + phpQuery::unloadDocuments();
  90 + return $content;
  91 + }
  92 +
  93 + /**
  94 + * 首页TDK
  95 + */
  96 + public function indexTDK($projectInfo): array
  97 + {
  98 + $tdkInfo = [];
  99 + $webSettingInfo = $this->getWebSetting($projectInfo);
  100 + if (!empty($webSettingInfo)){
  101 + $titleContent = strip_tags($webSettingInfo['title']);
  102 + $descriptionContent = strip_tags($webSettingInfo['remark']);
  103 + $keywordsContent = strip_tags($webSettingInfo['keyword']);
  104 + $tdkInfo["titleContent"] = $titleContent;
  105 + $tdkInfo["descriptionContent"] = $descriptionContent;
  106 + $tdkInfo["keywordsContent"] = $keywordsContent;
  107 + }
  108 + return $tdkInfo;
  109 + }
  110 +
  111 + /**
  112 + * 网站设置
  113 + */
  114 + public function getWebSetting($projectInfo)
  115 + {
  116 + if (Cache::get("project_".$projectInfo['id']."_web_setting") == null) {
  117 + $webSettingModel = new WebSetting();
  118 + $webSettingInfo = $webSettingModel->read(['project_id'=>$projectInfo['id']]);
  119 + if ($webSettingInfo !== false) {
  120 + Cache::add("project_".$projectInfo['id']."_web_setting", json_encode($webSettingInfo));
  121 + return $webSettingInfo;
  122 + }
  123 + return [];
  124 + }
  125 + return (array)json_decode(Cache::get("project_".$projectInfo['id']."_web_setting"));
  126 + }
  127 +
  128 + /**
  129 + * 新闻列表页TDK
  130 + */
  131 + public function newsCategoryTDK($projectInfo,$routerMapInfo): array
  132 + {
  133 + $tdkInfo = [];
  134 + $pageSuffix = "";
  135 + $webSetting = $this->getWebSetting($projectInfo);
  136 + $newsCategoryModel = new NewsCategory();
  137 + $newsCategoryInfo = $newsCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  138 + //seo拼接
  139 + $webSeoModel = new WebSettingSeo();
  140 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  141 + if ($webSeoInfo !== false){
  142 + $pageSuffix = !empty($webSeoInfo['single_page_suffix']) ? " ".$webSeoInfo['single_page_suffix'] : "";
  143 + }
  144 + if ($newsCategoryInfo !== false){
  145 + //title
  146 + if (!empty($newsCategoryInfo['seo_title'])){
  147 + $titleContent = $newsCategoryInfo['seo_title'].$pageSuffix;
  148 + }else{
  149 + $titleContent = $newsCategoryInfo['name'].$pageSuffix;
  150 + }
  151 + //description
  152 + if (!empty($newsCategoryInfo['seo_des'])){
  153 + $descriptionContent = $newsCategoryInfo['seo_des'];
  154 + }else{
  155 + $descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  156 + }
  157 + //keyword
  158 + if (!empty($newsCategoryInfo['seo_keywords'])){
  159 + $keywordsContent = $newsCategoryInfo['seo_keywords'];
  160 + }else{
  161 + $keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  162 + }
  163 + $tdkInfo["titleContent"] = $titleContent;
  164 + $tdkInfo["descriptionContent"] = $descriptionContent;
  165 + $tdkInfo["keywordsContent"] = $keywordsContent;
  166 + }
  167 + return $tdkInfo;
  168 + }
  169 +
  170 + /**
  171 + * 博客列表页TDK
  172 + */
  173 + public function blogCategoryTDK($projectInfo,$routerMapInfo): array
  174 + {
  175 + $tdkInfo = [];
  176 + $pageSuffix = "";
  177 + $webSetting = $this->getWebSetting($projectInfo);
  178 + $blogCategoryModel = new BlogCategory();
  179 + $blogCategoryInfo = $blogCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  180 + //seo拼接
  181 + $webSeoModel = new WebSettingSeo();
  182 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  183 + if ($webSeoInfo !== false){
  184 + $pageSuffix = !empty($webSeoInfo['single_page_suffix']) ? " ".$webSeoInfo['single_page_suffix'] : "";
  185 + }
  186 + if ($blogCategoryInfo !== false){
  187 + //title
  188 + if (!empty($blogCategoryInfo['seo_title'])){
  189 + $titleContent = $blogCategoryInfo['seo_title'].$pageSuffix;
  190 + }else{
  191 + $titleContent = $blogCategoryInfo['name'].$pageSuffix;
  192 + }
  193 + //description
  194 + if (!empty($blogCategoryInfo['seo_des'])){
  195 + $descriptionContent = $blogCategoryInfo['seo_des'];
  196 + }else{
  197 + $descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  198 + }
  199 + //keyword
  200 + if (!empty($blogCategoryInfo['seo_keywords'])){
  201 + $keywordsContent = $blogCategoryInfo['seo_keywords'];
  202 + }else{
  203 + $keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  204 + }
  205 + $tdkInfo["titleContent"] = $titleContent;
  206 + $tdkInfo["descriptionContent"] = $descriptionContent;
  207 + $tdkInfo["keywordsContent"] = $keywordsContent;
  208 + }
  209 + return $tdkInfo;
  210 + }
  211 +
  212 + /**
  213 + * 产品列表页TDK
  214 + */
  215 + public function productCategoryTDK($projectInfo,$routerMapInfo): array
  216 + {
  217 + $tdkInfo = [];
  218 + $prefix = "";
  219 + $suffix = "";
  220 + $webSettingTitle = "";
  221 + $webSettingDescription = "";
  222 + $webSettingKeyword = "";
  223 + $projectCategoryModel = new Category();
  224 + $projectCategoryInfo = $projectCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  225 + $webSetting = $this->getWebSetting($projectInfo);
  226 + //seo拼接
  227 + $webSeoModel = new WebSettingSeo();
  228 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  229 + if ($webSeoInfo !== false){
  230 + $prefix = !empty($webSeoInfo['product_cate_prefix']) ? $webSeoInfo['product_cate_prefix']." " : "";
  231 + $suffix = !empty($webSeoInfo['product_cate_suffix']) ? " ".$webSeoInfo['product_cate_suffix'] : "";
  232 + }
  233 + if ($webSetting !== false){
  234 + $webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
  235 + $webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  236 + $webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  237 + }
  238 + if ($projectCategoryInfo !== false){
  239 + //title
  240 + if (!empty($projectCategoryInfo['seo_title'])){
  241 + $titleContent = $prefix.$projectCategoryInfo['seo_title'].$suffix;
  242 + }else{
  243 + $titleContent = $prefix.$webSettingTitle.$suffix;
  244 + }
  245 + //description
  246 + if (!empty($projectCategoryInfo['seo_des'])){
  247 + $descriptionContent = $projectCategoryInfo['seo_des'];
  248 + }else{
  249 + $descriptionContent = $webSettingDescription;
  250 + }
  251 + //keywords
  252 + if (!empty($projectCategoryInfo['seo_keywords'])){
  253 + $keywordsContent = $projectCategoryInfo['seo_keywords'];
  254 + }else{
  255 + $keywordsContent = $webSettingKeyword;
  256 + }
  257 + }else{
  258 + $titleContent = $prefix.$webSettingTitle.$suffix;
  259 + $descriptionContent = $webSettingDescription;
  260 + $keywordsContent = $webSettingKeyword;
  261 + }
  262 + $tdkInfo["titleContent"] = $titleContent;
  263 + $tdkInfo["descriptionContent"] = $descriptionContent;
  264 + $tdkInfo["keywordsContent"] = $keywordsContent;
  265 + return $tdkInfo;
  266 + }
  267 +
  268 + /**
  269 + * 产品聚合页TDK
  270 + */
  271 + public function productKeywordsTDK($projectInfo,$routerMapInfo): array
  272 + {
  273 + $tdkInfo = [];
  274 + $keywordModel = new Keyword();
  275 + $keywordInfo = $keywordModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  276 + if ($keywordInfo !== false){
  277 + //处理title
  278 + $title = $keywordInfo['seo_title'] ?: $keywordInfo['title'];
  279 + //seo拼接
  280 + $webSeoModel = new WebSettingSeo();
  281 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  282 + $titleContent = $webSeoInfo ? $webSeoInfo['tab_prefix'] . " " . $title . " " . $webSeoInfo['tab_suffix'] : $title;
  283 + //处理description
  284 + $descriptionContent = $keywordInfo['seo_description'] ?: $keywordInfo['title'];
  285 + //处理keywords
  286 + $keywordsContent = $keywordInfo['seo_keywords'] ?: $keywordInfo['title'];
  287 +
  288 + $tdkInfo["titleContent"] = $titleContent;
  289 + $tdkInfo["descriptionContent"] = $descriptionContent;
  290 + $tdkInfo["keywordsContent"] = $keywordsContent;
  291 + }
  292 + return $tdkInfo;
  293 + }
  294 +
  295 + /**
  296 + * 新闻详情页TDK
  297 + */
  298 + public function newsDetailsTDK($projectInfo,$routerMapInfo): array
  299 + {
  300 + $tdkInfo = [];
  301 + $titleContent = "";
  302 + $keywordsContent = "";
  303 + $descriptionContent = "";
  304 + $newsModel = new News();
  305 + $newsInfo = $newsModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>1]);
  306 + return $this->newsBlogTdk($newsInfo, $projectInfo, $titleContent, $descriptionContent, $keywordsContent, $tdkInfo);
  307 + }
  308 +
  309 + /**
  310 + * 新闻详情页TDK
  311 + */
  312 + public function blogDetailsTDK($projectInfo,$routerMapInfo): array
  313 + {
  314 + $tdkInfo = [];
  315 + $titleContent = "";
  316 + $keywordsContent = "";
  317 + $descriptionContent = "";
  318 + $blogMode = new Blog();
  319 + $blogInfo = $blogMode->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>1]);
  320 + return $this->newsBlogTdk($blogInfo, $projectInfo, $titleContent, $descriptionContent, $keywordsContent, $tdkInfo);
  321 + }
  322 +
  323 + /**
  324 + * 自定义模块列表页TDK
  325 + */
  326 + public function moduleDetailsTDK($projectInfo,$routerMapInfo): array
  327 + {
  328 + $tdkInfo = [];
  329 + $moduleModel = new CustomModule();
  330 + $moduleInfo = $moduleModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>0]);
  331 + $webSetting = $this->getWebSetting($projectInfo);
  332 + if ($moduleInfo !== false){
  333 + //title
  334 + $webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
  335 + $titleContent = !empty($moduleInfo['seo_title']) ? $moduleInfo['seo_title'] : $webSettingTitle;
  336 + //description
  337 + $webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  338 + $descriptionContent = !empty($moduleInfo['seo_description']) ? $moduleInfo['seo_description'] : $webSettingDescription;
  339 +
  340 + //keywords
  341 + $webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  342 + $keywordsContent = !empty($moduleInfo['seo_keywords']) ? $moduleInfo['seo_keywords'] : $webSettingKeyword;
  343 + $tdkInfo["titleContent"] = $titleContent;
  344 + $tdkInfo["descriptionContent"] = $descriptionContent;
  345 + $tdkInfo["keywordsContent"] = $keywordsContent;
  346 + }
  347 + return $tdkInfo;
  348 + }
  349 +
  350 + /**
  351 + * 自定义模块列表页TDK
  352 + */
  353 + public function moduleCategoryTDK($projectInfo,$routerMapInfo): array
  354 + {
  355 + $tdkInfo = [];
  356 + $moduleCategoryModel = new CustomModuleCategory();
  357 + $moduleCategoryInfo = $moduleCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  358 + $webSetting = $this->getWebSetting($projectInfo);
  359 + if ($moduleCategoryInfo !== false){
  360 + //title
  361 + $webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
  362 + $titleContent = !empty($moduleCategoryInfo['seo_title']) ? $moduleCategoryInfo['seo_title'] : $webSettingTitle;
  363 +
  364 + //description
  365 + $webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  366 + $descriptionContent = !empty($moduleCategoryInfo['seo_description']) ? $moduleCategoryInfo['seo_description'] : $webSettingDescription;
  367 +
  368 + //keywords
  369 + $webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  370 + $keywordsContent = !empty($moduleCategoryInfo['seo_keywords']) ? $moduleCategoryInfo['seo_keywords'] : $webSettingKeyword;
  371 + $tdkInfo["titleContent"] = $titleContent;
  372 + $tdkInfo["descriptionContent"] = $descriptionContent;
  373 + $tdkInfo["keywordsContent"] = $keywordsContent;
  374 + }
  375 + return $tdkInfo;
  376 + }
  377 +
  378 + /**
  379 + * 单页面TDK
  380 + */
  381 + public function pageTDK($projectInfo,$routerMapInfo): array
  382 + {
  383 + $tdkInfo = [];
  384 + if (!empty($routerMap)){
  385 + $customModel = new BCustomTemplate();
  386 + $webCustomInfo = $customModel->read(['id'=>$routerMapInfo['source_id'],'status'=>1]);
  387 + //seo拼接
  388 + $webSeoModel = new WebSettingSeo();
  389 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  390 + //网站设置
  391 + $webSetting = $this->getWebSetting($projectInfo);
  392 + $descriptionContent = "";
  393 + $keywordsContent = "";
  394 + if ($webCustomInfo !== false){
  395 + //title
  396 + if ($webCustomInfo['title'] == null){
  397 + if (!empty($webSeo)){
  398 + $titleContent = $webCustomInfo['name']." ".$webSeoInfo['single_page_suffix'];
  399 + }else{
  400 + $titleContent = $webCustomInfo['name'];
  401 + }
  402 + }else{
  403 + if (!empty($webSeo)){
  404 + $titleContent = $webCustomInfo['title']." ".$webSeoInfo['single_page_suffix'];
  405 + }else{
  406 + $titleContent = $webCustomInfo['title'];
  407 + }
  408 + }
  409 + //keywords
  410 + if ($webCustomInfo['keywords'] == null){
  411 + if (!empty($webSetting)){
  412 + $keywordsContent = $webSetting['keyword'];
  413 + }
  414 + }else{
  415 + $keywordsContent = $webSetting['keywords'];
  416 + }
  417 + //description
  418 + if ($webCustomInfo['description'] == null){
  419 + if (!empty($webSetting)) {
  420 + $descriptionContent = $webSetting['remark'];
  421 + }
  422 + }else{
  423 + $descriptionContent = $webCustomInfo['description'];
  424 + }
  425 + $tdkInfo["titleContent"] = $titleContent;
  426 + $tdkInfo["descriptionContent"] = $descriptionContent;
  427 + $tdkInfo["keywordsContent"] = $keywordsContent;
  428 + }
  429 + }
  430 + return $tdkInfo;
  431 + }
  432 +
  433 + /**
  434 + * 新闻博客详情通用版块
  435 + */
  436 + public function newsBlogTdk($info, $projectInfo, $titleContent, $descriptionContent, $keywordsContent, array $tdkInfo): array
  437 + {
  438 + if (!empty($info)) {
  439 + //seo拼接
  440 + $pageSuffix = "";
  441 + $webSeoModel = new WebSettingSeo();
  442 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  443 + $webSetting = $this->getWebSetting($projectInfo);
  444 + if (!empty($webSeoInfo)) {
  445 + $pageSuffix = !empty($webSeo['single_page_suffix']) ? " " . $webSeo['single_page_suffix'] : "";
  446 + }
  447 + if ($info['seo_title'] == null) {
  448 + $titleContent = !empty($info['name']) ? $info['name'] . $pageSuffix : "";
  449 + } else {
  450 + $titleContent = $info['seo_title'] . $pageSuffix;
  451 + }
  452 + //处理description
  453 + if ($info['seo_description'] == null) {
  454 + $descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  455 + } else {
  456 + $descriptionContent = $info['seo_description'];
  457 + }
  458 + //处理keywords
  459 + if ($info['seo_keywords'] == null) {
  460 + $keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  461 + } else {
  462 + $keywordsContent = $info['seo_keywords'];
  463 + }
  464 + $tdkInfo["titleContent"] = $titleContent;
  465 + $tdkInfo["descriptionContent"] = $descriptionContent;
  466 + $tdkInfo["keywordsContent"] = $keywordsContent;
  467 + }
  468 +
  469 + return $tdkInfo;
  470 + }
  471 +}
@@ -42,7 +42,7 @@ class HttpUtils @@ -42,7 +42,7 @@ class HttpUtils
42 public static function get($url, $data, $headers = []) 42 public static function get($url, $data, $headers = [])
43 { 43 {
44 LogUtils::info("HttpUtils-GET请求URL:" . $url); 44 LogUtils::info("HttpUtils-GET请求URL:" . $url);
45 - $response = Http::withHeaders($headers)->get($url, $data); 45 + $response = Http::timeout(20)->withHeaders($headers)->get($url, $data);
46 self::checkSuccess($response); 46 self::checkSuccess($response);
47 return $response->getBody()->getContents(); 47 return $response->getBody()->getContents();
48 } 48 }
@@ -50,7 +50,7 @@ class HttpUtils @@ -50,7 +50,7 @@ class HttpUtils
50 public static function post($url, $data, $headers = []) 50 public static function post($url, $data, $headers = [])
51 { 51 {
52 LogUtils::info("HttpUtils-POST请求URL:" . $url); 52 LogUtils::info("HttpUtils-POST请求URL:" . $url);
53 - $response = Http::withHeaders($headers)->post($url, $data); 53 + $response = Http::timeout(20)->withHeaders($headers)->post($url, $data);
54 self::checkSuccess($response); 54 self::checkSuccess($response);
55 return $response->getBody()->getContents(); 55 return $response->getBody()->getContents();
56 } 56 }
@@ -28,3 +28,5 @@ Route::any('getOptimizationReport', [\App\Http\Controllers\Api\OptimizationRepor @@ -28,3 +28,5 @@ Route::any('getOptimizationReport', [\App\Http\Controllers\Api\OptimizationRepor
28 Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback'); 28 Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController::class, 'videoTaskCallback'])->name('api.video_task_callback');
29 // 验证是否为6.0用户 29 // 验证是否为6.0用户
30 Route::any('has_user', [\App\Http\Controllers\Api\PrivateController::class, 'hasUser'])->name('api.has_user'); 30 Route::any('has_user', [\App\Http\Controllers\Api\PrivateController::class, 'hasUser'])->name('api.has_user');
  31 +// 6.0有效用户用户
  32 +Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'validUser'])->name('api.valid_user');