作者 赵彬吉

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Http\Logic\Aside\Project\DomainInfoLogic;
  6 +use App\Models\Com\UpdateNotify;
  7 +use App\Models\Devops\DevopsTask as DevopsTaskModel;
  8 +use App\Models\Devops\DevopsTaskLog;
  9 +use App\Models\Domain\DomainInfo;
  10 +use App\Models\File\File;
  11 +use App\Models\File\Image;
  12 +use App\Models\Product\CategoryRelated;
  13 +use App\Models\Product\Product;
  14 +use App\Models\Project\Project;
  15 +use App\Models\RouteMap\RouteMap;
  16 +use App\Models\Template\BCustomTemplate;
  17 +use App\Services\ProjectServer;
  18 +use Illuminate\Console\Command;
  19 +use Illuminate\Database\QueryException;
  20 +use Illuminate\Support\Facades\DB;
  21 +
  22 +/**
  23 + * 测试
  24 + * Class Traffic
  25 + * @package App\Console\Commands
  26 + * @author zbj
  27 + * @date 2023/5/18
  28 + */
  29 +class Test extends Command
  30 +{
  31 + /**
  32 + * The name and signature of the console command.
  33 + *
  34 + * @var string
  35 + */
  36 + protected $signature = 'test';
  37 +
  38 + /**
  39 + * The console command description.
  40 + *
  41 + * @var string
  42 + */
  43 + protected $description = '测试';
  44 +
  45 + /**
  46 + * Create a new command instance.
  47 + *
  48 + * @return void
  49 + */
  50 + public function __construct()
  51 + {
  52 + parent::__construct();
  53 + }
  54 +
  55 + /**
  56 + * @return bool
  57 + */
  58 + public function handle()
  59 + {
  60 + $projects = Project::all();
  61 + foreach ($projects as $project){
  62 + echo "project " . $project->id;
  63 +
  64 + if(!ProjectServer::useProject($project->id)){
  65 + echo '-->' . '未配置数据库' . PHP_EOL;
  66 + continue;
  67 + }
  68 +
  69 + try {
  70 + $page = BCustomTemplate::where('url', '404')->first();
  71 + if(!$page){
  72 + $page = new BCustomTemplate();
  73 + }
  74 + $page->project_id = $project->id;
  75 + $page->name = '404';
  76 + $page->status = 1;
  77 + $page->url = '404';
  78 + $page->html = '<main>
  79 + <section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
  80 + id="sectionIdyxqu938">
  81 + <div class="layout" data-unable="demo01-error404">
  82 + <img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" />
  83 + </div>
  84 + <p style="text-align: center">SORRY. THE PAGE HAS EITHER MOVED OR CANNOT BE FOUND.</p>
  85 + <style>
  86 + .section-block-error404 .layout {
  87 + height: 700px;
  88 + display: flex;
  89 + align-items: center;
  90 + justify-content: center;
  91 + }
  92 + .section-block-error404 img {
  93 + width: 400px;
  94 + }
  95 + @media only screen and (max-width:500) {
  96 + .section-block-error404 img {
  97 + max-width: 100%;
  98 + }
  99 + }
  100 + </style>
  101 + <script>
  102 + </script>
  103 + </section>
  104 + </main>';
  105 + $page->html_style = '<style id="globalsojs-styles"></style>';
  106 + $page->description = 'Sorry. The page has either moved or cannot be found.';
  107 + $page->title = '404-Page not found';
  108 + $page->save();
  109 +
  110 + $domain = (new DomainInfo())->getDomain($project['deploy_optimize']['domain']);
  111 + $url = $domain.'api/delHtml/?project_id='.$project->id.'&route=404';
  112 + curlGet($url);
  113 + }catch (QueryException | \Exception $e){
  114 + echo '-->' . $e->getMessage() . PHP_EOL;
  115 + continue;
  116 + }
  117 + echo '-->成功:' . PHP_EOL;
  118 + }
  119 + }
  120 +
  121 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :PageSettingController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/10/21 15:25
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\BCom;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Models\Project\PageSetting;
  15 +
  16 +class PageSettingController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :根据项目设置获取页面是否使用公共头部底部
  20 + * @name :read
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/10/21 15:26
  24 + */
  25 + public function info(){
  26 + $pageSettingModel = new PageSetting();
  27 + $info = $pageSettingModel->read(['project_id'=>$this->user['project_id']]);
  28 + if($info === false){
  29 + $info = [
  30 + 'project_id'=>$this->user['project_id'],
  31 + 'product_list'=>0,
  32 + 'product_details'=>0,
  33 + 'page_keyword'=>0,
  34 + 'blog_lists'=>0,
  35 + 'blog_details'=>0,
  36 + 'news_list'=>0,
  37 + 'news_details'=>0,
  38 + 'polymerization'=>0,
  39 + ];
  40 + $pageSettingModel->add($info);
  41 + }
  42 + $this->response('success',Code::SUCCESS,$info);
  43 + }
  44 +
  45 + /**
  46 + * @remark :设置是否使用公共头和底
  47 + * @name :edit
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2023/10/21 15:36
  51 + */
  52 + public function edit(){
  53 + $pageSettingModel = new PageSetting();
  54 + $rs = $pageSettingModel->edit($this->param,['project_id'=>$this->user['project_id']]);
  55 + if($rs === false){
  56 + $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR);
  57 + }
  58 + $this->response('success');
  59 + }
  60 +}
@@ -65,6 +65,9 @@ class BlogController extends BaseController @@ -65,6 +65,9 @@ class BlogController extends BaseController
65 if(isset($this->map['status'])){ 65 if(isset($this->map['status'])){
66 $query = $query->where('status',$this->map['status']); 66 $query = $query->where('status',$this->map['status']);
67 } 67 }
  68 + if(isset($this->map['name']) && !empty($this->map['name'])){
  69 + $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
  70 + }
68 if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){ 71 if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
69 $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); 72 $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
70 } 73 }
@@ -65,6 +65,9 @@ class NewsController extends BaseController @@ -65,6 +65,9 @@ class NewsController extends BaseController
65 if(isset($this->map['status'])){ 65 if(isset($this->map['status'])){
66 $query = $query->where('status',$this->map['status']); 66 $query = $query->where('status',$this->map['status']);
67 } 67 }
  68 + if(isset($this->map['name']) && !empty($this->map['name'])){
  69 + $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
  70 + }
68 if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){ 71 if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
69 $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); 72 $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
70 } 73 }
@@ -65,8 +65,8 @@ class KeywordController extends BaseController @@ -65,8 +65,8 @@ class KeywordController extends BaseController
65 ],[ 65 ],[
66 'id.required' => 'ID不能为空' 66 'id.required' => 'ID不能为空'
67 ]); 67 ]);
68 - $data = $logic->getInfo($this->param['id']);  
69 - return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at', 'route', 'url'])); 68 + $data = $logic->getKeywordInfo();
  69 + return $this->success($data);
70 } 70 }
71 71
72 /** 72 /**
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AggregationSettingController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/10/23 11:06
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Setting;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Helper\Arr;
  14 +use App\Http\Controllers\Bside\BaseController;
  15 +use App\Models\WebSetting\AggregationSetting;
  16 +
  17 +/**
  18 + * @remark :聚合页
  19 + * @name :AggregationSettingController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2023/10/23 11:06
  23 + */
  24 +class AggregationSettingController extends BaseController
  25 +{
  26 + /**
  27 + * @remark :获取聚合页设置详情
  28 + * @name :info
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/10/23 11:08
  32 + */
  33 + public function info(){
  34 + $aggSettingModel = new AggregationSetting();
  35 + $info = $aggSettingModel->read(['project_id'=>$this->user['project_id']]);
  36 + if($info === false){
  37 + $data = [
  38 + 'title'=>'',
  39 + 'content'=>'',
  40 + 'top_banner'=>json_encode([]),
  41 + 'foot_banner'=>json_encode([]),
  42 + 'project_id'=>$this->user['project_id']
  43 + ];
  44 + $aggSettingModel->add($data);
  45 + $info = $data;
  46 + }
  47 + $this->response('success',Code::SUCCESS,$info);
  48 + }
  49 +
  50 + /**
  51 + * @remark :修改聚合页设置
  52 + * @name :edit
  53 + * @author :lyh
  54 + * @method :post
  55 + * @time :2023/10/23 11:11
  56 + */
  57 + public function edit(){
  58 + $aggSettingModel = new AggregationSetting();
  59 + if(isset($this->param['top_banner']) && !empty($this->param['top_banner'])){
  60 + $this->param['top_banner'] = Arr::a2s($this->param['top_banner']);
  61 + }
  62 + if(isset($this->param['foot_banner']) && !empty($this->param['foot_banner'])){
  63 + $this->param['foot_banner'] = Arr::a2s($this->param['foot_banner']);
  64 + }
  65 + $rs = $aggSettingModel->edit($this->param,['project_id'=>$this->user['project_id']]);
  66 + if($rs === false){
  67 + $this->response('系统错误请联系管理员',Code::SYSTEM_ERROR);
  68 + }
  69 + $this->response('success');
  70 + }
  71 +}
@@ -7,6 +7,7 @@ use App\Models\Blog\BlogCategory; @@ -7,6 +7,7 @@ use App\Models\Blog\BlogCategory;
7 use App\Models\News\NewsCategory; 7 use App\Models\News\NewsCategory;
8 use App\Models\Product\Category; 8 use App\Models\Product\Category;
9 use App\Models\Product\Product; 9 use App\Models\Product\Product;
  10 +use App\Models\Project\PageSetting;
10 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
11 use App\Models\Service\Service as ServiceSettingModel; 12 use App\Models\Service\Service as ServiceSettingModel;
12 use App\Models\Template\BTemplateCommon; 13 use App\Models\Template\BTemplateCommon;
@@ -61,12 +62,10 @@ class BTemplateLogic extends BaseLogic @@ -61,12 +62,10 @@ class BTemplateLogic extends BaseLogic
61 if($info === false){ 62 if($info === false){
62 $this->fail('请先选择模版'); 63 $this->fail('请先选择模版');
63 } 64 }
64 - $TemplateInfo = [];  
65 if($this->param['source'] == $this->model::SOURCE_HOME){//首页 65 if($this->param['source'] == $this->model::SOURCE_HOME){//首页
66 $TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']); 66 $TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
67 - }  
68 - if($this->param['source'] == $this->model::SOURCE_PRODUCT){//产品页  
69 - $TemplateInfo = $this->productHtml($info,$this->param['source'],$this->param['source_id']); 67 + }else{
  68 + $TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']);
70 } 69 }
71 return $this->success($TemplateInfo); 70 return $this->success($TemplateInfo);
72 } 71 }
@@ -105,7 +104,7 @@ class BTemplateLogic extends BaseLogic @@ -105,7 +104,7 @@ class BTemplateLogic extends BaseLogic
105 $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); 104 $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
106 }else{ 105 }else{
107 $commonTemplateModel = new BTemplateCommon(); 106 $commonTemplateModel = new BTemplateCommon();
108 - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>$source]); 107 + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
109 if($commonInfo !== false){ 108 if($commonInfo !== false){
110 $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. 109 $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
111 $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html']; 110 $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
@@ -126,7 +125,7 @@ class BTemplateLogic extends BaseLogic @@ -126,7 +125,7 @@ class BTemplateLogic extends BaseLogic
126 * @method :post 125 * @method :post
127 * @time :2023/7/25 16:40 126 * @time :2023/7/25 16:40
128 */ 127 */
129 - public function productHtml($info,$source,$source_id){ 128 + public function otherHtml($info,$source,$source_id){
130 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); 129 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
131 if($homeTemplateInfo === false){ 130 if($homeTemplateInfo === false){
132 $this->fail('请先装修首页'); 131 $this->fail('请先装修首页');
@@ -140,9 +139,7 @@ class BTemplateLogic extends BaseLogic @@ -140,9 +139,7 @@ class BTemplateLogic extends BaseLogic
140 $main_html = $TemplateInfo['main_html']; 139 $main_html = $TemplateInfo['main_html'];
141 $main_style = $TemplateInfo['main_css']; 140 $main_style = $TemplateInfo['main_css'];
142 } 141 }
143 - //兼容老数据  
144 - $commonTemplateModel = new BTemplateCommon();  
145 - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]); 142 + $commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']);
146 if($commonInfo !== false){ 143 if($commonInfo !== false){
147 $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other']. 144 $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
148 $commonInfo['head_html'].$main_html.$commonInfo['footer_html']; 145 $commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
@@ -155,6 +152,76 @@ class BTemplateLogic extends BaseLogic @@ -155,6 +152,76 @@ class BTemplateLogic extends BaseLogic
155 } 152 }
156 153
157 /** 154 /**
  155 + * @remark :根据类型获取公共头和底
  156 + * @name :getCommonPage
  157 + * @author :lyh
  158 + * @method :post
  159 + * @time :2023/10/21 16:55
  160 + */
  161 + public function getCommonPage($source,$source_id,$template_id){
  162 + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
  163 + //查看页面是否设置自定义头部底部
  164 + $pageSettingModel = new PageSetting();
  165 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  166 + if ($pageInfo != false) {
  167 + $commonTemplateModel = new BTemplateCommon();
  168 + if ($source == 2) {//产品页
  169 + if ($source_id != 0) {//产品详情页
  170 + if ($pageInfo['product_list'] != 0) {
  171 + //使用独立头和底
  172 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 3]);
  173 + }
  174 + } else {//产品列表页
  175 + if ($pageInfo['product_details'] != 0) {
  176 + //使用独立头和底
  177 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 2]);
  178 + }
  179 + }
  180 + }
  181 + if ($source == 3) {//博客页
  182 + if ($source_id != 0) {//博客详情页
  183 + if ($pageInfo['blog_lists'] != 0) {
  184 + //使用独立头和底
  185 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 4]);
  186 + }
  187 + } else {//产品列表页
  188 + if ($pageInfo['blog_details'] != 0) {
  189 + //使用独立头和底
  190 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 5]);
  191 + }
  192 + }
  193 + }
  194 + if ($source == 4) {//新闻页
  195 + if ($source_id != 0) {//新闻详情页
  196 + if ($pageInfo['news_lists'] != 0) {
  197 + //使用独立头和底
  198 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 6]);
  199 + }
  200 + } else {//新闻列表页
  201 + if ($pageInfo['news_details'] != 0) {
  202 + //使用独立头和底
  203 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 7]);
  204 + }
  205 + }
  206 + }
  207 + if ($source == 5) {//聚合页
  208 + if ($pageInfo['polymerization'] != 0) {
  209 + //使用独立头和底
  210 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 8]);
  211 + }
  212 + }
  213 + }
  214 + }
  215 + //获取首页公共的头部和底部
  216 + if(!isset($commonInfo) || $commonInfo === false){
  217 + $commonTemplateModel = new BTemplateCommon();
  218 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
  219 + }
  220 + return $commonInfo;
  221 + }
  222 +
  223 +
  224 + /**
158 * @remark :设置模板 225 * @remark :设置模板
159 * @name :setTemplate 226 * @name :setTemplate
160 * @author :lyh 227 * @author :lyh
@@ -197,6 +264,7 @@ class BTemplateLogic extends BaseLogic @@ -197,6 +264,7 @@ class BTemplateLogic extends BaseLogic
197 $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']); 264 $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
198 //字符串截取 265 //字符串截取
199 $this->param = $this->stringProcessing($this->param); 266 $this->param = $this->stringProcessing($this->param);
  267 + //保存头部信息
200 $this->saveCommonTemplate($this->param); 268 $this->saveCommonTemplate($this->param);
201 $this->param = $this->templateSaveParam($this->param);//组装数据 269 $this->param = $this->templateSaveParam($this->param);//组装数据
202 if($info === false){ 270 if($info === false){
@@ -224,8 +292,9 @@ class BTemplateLogic extends BaseLogic @@ -224,8 +292,9 @@ class BTemplateLogic extends BaseLogic
224 * @time :2023/10/13 14:27 292 * @time :2023/10/13 14:27
225 */ 293 */
226 public function saveCommonTemplate($param){ 294 public function saveCommonTemplate($param){
  295 + $type = $this->getType($param['source'],$param['source_id']);
227 $templateCommonModel = new BTemplateCommon(); 296 $templateCommonModel = new BTemplateCommon();
228 - $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]); 297 + $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
229 $data = [ 298 $data = [
230 'head_html'=>$param['head_html'], 299 'head_html'=>$param['head_html'],
231 'head_css'=>$param['head_css'], 300 'head_css'=>$param['head_css'],
@@ -236,7 +305,7 @@ class BTemplateLogic extends BaseLogic @@ -236,7 +305,7 @@ class BTemplateLogic extends BaseLogic
236 if($info === false){ 305 if($info === false){
237 $data['template_id'] = $param['template_id']; 306 $data['template_id'] = $param['template_id'];
238 $data['project_id'] = $this->user['project_id']; 307 $data['project_id'] = $this->user['project_id'];
239 - $data['type'] = 1; 308 + $data['type'] = $type;
240 $templateCommonModel->add($data); 309 $templateCommonModel->add($data);
241 }else{ 310 }else{
242 $templateCommonModel->edit($data,['id'=>$info['id']]); 311 $templateCommonModel->edit($data,['id'=>$info['id']]);
@@ -245,6 +314,63 @@ class BTemplateLogic extends BaseLogic @@ -245,6 +314,63 @@ class BTemplateLogic extends BaseLogic
245 } 314 }
246 315
247 /** 316 /**
  317 + * @remark :获取设置的类型
  318 + * @name :getType
  319 + * @author :lyh
  320 + * @method :post
  321 + * @time :2023/10/21 17:29
  322 + */
  323 + public function getType($source,$source_id){
  324 + $type = 1;//首页公共头部底部
  325 + //查看页面是否设置自定义头部底部
  326 + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
  327 + $pageSettingModel = new PageSetting();
  328 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  329 + if ($pageInfo !== false) {
  330 + if ($source == 2) {
  331 + if ($source_id != 0) {
  332 + if ($pageInfo['product_list'] != 0) {
  333 + $type = 3;
  334 + }
  335 + } else {
  336 + if ($pageInfo['product_details'] != 0) {
  337 + $type = 2;
  338 + }
  339 + }
  340 + }
  341 + if ($source == 3) {
  342 + if ($source_id != 0) {
  343 + if ($pageInfo['blog_list'] != 0) {
  344 + $type = 4;
  345 + }
  346 + } else {
  347 + if ($pageInfo['blog_details'] != 0) {
  348 + $type = 5;
  349 + }
  350 + }
  351 + }
  352 + if ($source == 4) {
  353 + if ($source_id != 0) {
  354 + if ($pageInfo['news_list'] != 0) {
  355 + $type = 6;
  356 + }
  357 + } else {
  358 + if ($pageInfo['news_details'] != 0) {
  359 + $type = 7;
  360 + }
  361 + }
  362 + }
  363 + if ($source == 5) {
  364 + if ($pageInfo['polymerization'] != 0) {
  365 + $type = 8;
  366 + }
  367 + }
  368 + }
  369 + }
  370 + return $type;
  371 + }
  372 +
  373 + /**
248 * @remark :生成记录 374 * @remark :生成记录
249 * @name :setTemplateLog 375 * @name :setTemplateLog
250 * @author :lyh 376 * @author :lyh
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Logic\Bside\BTemplate; 3 namespace App\Http\Logic\Bside\BTemplate;
4 4
5 use App\Http\Logic\Bside\BaseLogic; 5 use App\Http\Logic\Bside\BaseLogic;
  6 +use App\Models\Project\PageSetting;
6 use App\Models\RouteMap\RouteMap; 7 use App\Models\RouteMap\RouteMap;
7 use App\Models\Service\Service as ServiceSettingModel; 8 use App\Models\Service\Service as ServiceSettingModel;
8 use App\Models\Template\BCustomTemplate; 9 use App\Models\Template\BCustomTemplate;
@@ -109,30 +110,49 @@ class CustomTemplateLogic extends BaseLogic @@ -109,30 +110,49 @@ class CustomTemplateLogic extends BaseLogic
109 * @method :post 110 * @method :post
110 * @time :2023/10/13 14:27 111 * @time :2023/10/13 14:27
111 */ 112 */
112 - public function saveCommonTemplate($html){  
113 - //获取设置的默认模版  
114 - $bSettingModel = new Setting();  
115 - $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);  
116 - if($settingInfo === false){  
117 - $this->fail('请先设置模版');  
118 - }  
119 - //查看当前 113 + public function saveCommonTemplate($param){
  114 + $type = $this->getType();
120 $templateCommonModel = new BTemplateCommon(); 115 $templateCommonModel = new BTemplateCommon();
121 - $commonInfo = $templateCommonModel->read(['template_id'=>$settingInfo['template_id'],'project_id'=>$this->user['project_id']]);  
122 - if($commonInfo === false){  
123 - $this->fail('请先装修首页');  
124 - } 116 + $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
125 $data = [ 117 $data = [
126 - 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),  
127 - 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),  
128 - 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),  
129 - 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),  
130 - 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")), 118 + 'head_html'=>$param['head_html'],
  119 + 'head_css'=>$param['head_css'],
  120 + 'footer_html'=>$param['footer_html'],
  121 + 'footer_css'=>$param['footer_css'],
  122 + 'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
131 ]; 123 ];
132 - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); 124 + if($info === false){
  125 + $data['template_id'] = $param['template_id'];
  126 + $data['project_id'] = $this->user['project_id'];
  127 + $data['type'] = $type;
  128 + $templateCommonModel->add($data);
  129 + }else{
  130 + $templateCommonModel->edit($data,['id'=>$info['id']]);
  131 + }
133 return $this->success(); 132 return $this->success();
134 } 133 }
135 134
  135 + /**
  136 + * @remark :获取设置的类型
  137 + * @name :getType
  138 + * @author :lyh
  139 + * @method :post
  140 + * @time :2023/10/21 17:29
  141 + */
  142 + public function getType(){
  143 + $type = 1;//首页公共头部底部
  144 + //查看页面是否设置自定义头部底部
  145 + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
  146 + $pageSettingModel = new PageSetting();
  147 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  148 + if ($pageInfo !== false) {
  149 + if ($pageInfo['page_list'] != 0) {
  150 + $type = 9;
  151 + }
  152 + }
  153 + }
  154 + return $type;
  155 + }
136 156
137 /** 157 /**
138 * @remark :查看路由是否更新 158 * @remark :查看路由是否更新
@@ -224,9 +244,8 @@ class CustomTemplateLogic extends BaseLogic @@ -224,9 +244,8 @@ class CustomTemplateLogic extends BaseLogic
224 if($info === false){ 244 if($info === false){
225 $this->fail('请先设置模版'); 245 $this->fail('请先设置模版');
226 } 246 }
227 -  
228 - $commonTemplateModel = new BTemplateCommon();  
229 - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); 247 + //获取type类型
  248 + $commonInfo = $this->getCommonPage($info['template_id']);
230 $html = ''; 249 $html = '';
231 if($commonInfo !== false){ 250 if($commonInfo !== false){
232 $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other']. 251 $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
@@ -249,6 +268,34 @@ class CustomTemplateLogic extends BaseLogic @@ -249,6 +268,34 @@ class CustomTemplateLogic extends BaseLogic
249 } 268 }
250 269
251 /** 270 /**
  271 + * @remark :根据类型获取公共头和底
  272 + * @name :getCommonPage
  273 + * @author :lyh
  274 + * @method :post
  275 + * @time :2023/10/21 16:55
  276 + */
  277 + public function getCommonPage($template_id){
  278 + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
  279 + //查看页面是否设置自定义头部底部
  280 + $pageSettingModel = new PageSetting();
  281 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  282 + if ($pageInfo !== false) {
  283 + $commonTemplateModel = new BTemplateCommon();
  284 + if ($pageInfo['page_list'] != 0) {
  285 + //使用独立头和底
  286 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 9]);
  287 + }
  288 + }
  289 + }
  290 + if(!isset($commonInfo) || $commonInfo === false){
  291 + //获取首页公共的头部和底部
  292 + $commonTemplateModel = new BTemplateCommon();
  293 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
  294 + }
  295 + return $commonInfo;
  296 + }
  297 +
  298 + /**
252 * @remark :拼接获取公共头部底部 299 * @remark :拼接获取公共头部底部
253 * @name :getHeadFooter 300 * @name :getHeadFooter
254 * @author :lyh 301 * @author :lyh
@@ -241,10 +241,12 @@ class CategoryLogic extends BaseLogic @@ -241,10 +241,12 @@ class CategoryLogic extends BaseLogic
241 */ 241 */
242 public function categoryDelete(){ 242 public function categoryDelete(){
243 $ids = $this->param['ids']; 243 $ids = $this->param['ids'];
244 - DB::beginTransaction();  
245 - try {  
246 - $productModel = new Product();  
247 foreach ($ids as $id){ 244 foreach ($ids as $id){
  245 + $info = $this->model->read(['pid'=>$id],['id']);
  246 + if($info !== false){
  247 + $this->fail('分类id:'.$id.'拥有子集不允许删除');
  248 + }
  249 + $productModel = new Product();
248 $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]); 250 $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);
249 if($product_info !== false){ 251 if($product_info !== false){
250 $this->fail('当前分类拥有产品不允许删除'); 252 $this->fail('当前分类拥有产品不允许删除');
@@ -255,11 +257,6 @@ class CategoryLogic extends BaseLogic @@ -255,11 +257,6 @@ class CategoryLogic extends BaseLogic
255 } 257 }
256 //清除缓存 258 //清除缓存
257 Common::del_user_cache('product_category',$this->user['project_id']); 259 Common::del_user_cache('product_category',$this->user['project_id']);
258 - DB::commit();  
259 - }catch (\Exception $e){  
260 - DB::rollBack();  
261 - $this->fail('删除失败');  
262 - }  
263 return $this->success(); 260 return $this->success();
264 } 261 }
265 262
@@ -34,9 +34,9 @@ class KeywordLogic extends BaseLogic @@ -34,9 +34,9 @@ class KeywordLogic extends BaseLogic
34 * @method :post 34 * @method :post
35 * @time :2023/8/23 16:50 35 * @time :2023/8/23 16:50
36 */ 36 */
37 - public function getInfo($id) 37 + public function getKeywordInfo()
38 { 38 {
39 - $info = parent::getInfo($id); 39 + $info = $this->model->read($this->param);
40 $info['url'] = $this->user['domain'] . $info['route']; 40 $info['url'] = $this->user['domain'] . $info['route'];
41 return $this->success($info); 41 return $this->success($info);
42 } 42 }
@@ -51,6 +51,7 @@ class KeywordLogic extends BaseLogic @@ -51,6 +51,7 @@ class KeywordLogic extends BaseLogic
51 public function keywordSave(){ 51 public function keywordSave(){
52 DB::beginTransaction(); 52 DB::beginTransaction();
53 try { 53 try {
  54 + $this->param = $this->handleSaveParam($this->param);
54 if(isset($this->param['id']) && !empty($this->param['id'])){ 55 if(isset($this->param['id']) && !empty($this->param['id'])){
55 $info = $this->model->read(['id'=>$this->param['id']],['id','route']); 56 $info = $this->model->read(['id'=>$this->param['id']],['id','route']);
56 $route = $info['route']; 57 $route = $info['route'];
@@ -77,6 +78,23 @@ class KeywordLogic extends BaseLogic @@ -77,6 +78,23 @@ class KeywordLogic extends BaseLogic
77 } 78 }
78 79
79 /** 80 /**
  81 + * @remark :保存数据时参数处理
  82 + * @name :handleSaveParam
  83 + * @author :lyh
  84 + * @method :post
  85 + * @time :2023/10/23 14:47
  86 + */
  87 + public function handleSaveParam($param){
  88 + if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){
  89 + $param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner']);
  90 + }
  91 + if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){
  92 + $param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner']);
  93 + }
  94 + return $param;
  95 + }
  96 +
  97 + /**
80 * @remark :批量添加数据 98 * @remark :批量添加数据
81 * @name :batchAdd 99 * @name :batchAdd
82 * @author :lyh 100 * @author :lyh
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace App\Models\Product; 3 namespace App\Models\Product;
4 4
  5 +use App\Helper\Arr;
5 use App\Models\Base; 6 use App\Models\Base;
6 use Illuminate\Database\Eloquent\SoftDeletes; 7 use Illuminate\Database\Eloquent\SoftDeletes;
7 8
@@ -19,4 +20,26 @@ class Keyword extends Base @@ -19,4 +20,26 @@ class Keyword extends Base
19 // public function getRouteAttribute(){ 20 // public function getRouteAttribute(){
20 // return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id); 21 // return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id);
21 // } 22 // }
  23 +
  24 + /**
  25 + * @remark :图
  26 + * @name :getKeywordTopBannerAttribute
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/7/21 11:11
  30 + */
  31 + public function getKeywordTopBannerAttribute($value){
  32 + return getImageUrl($value);
  33 + }
  34 +
  35 + /**
  36 + * @remark :图
  37 + * @name :getKeywordTopBannerAttribute
  38 + * @author :lyh
  39 + * @method :post
  40 + * @time :2023/7/21 11:11
  41 + */
  42 + public function getKeywordFootBannerAttribute($value){
  43 + return getImageUrl($value);
  44 + }
22 } 45 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :PageSetting.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/10/21 15:24
  8 + */
  9 +
  10 +namespace App\Models\Project;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :项目页面头部底部设置
  16 + * @name :PageSetting
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2023/10/21 15:24
  20 + */
  21 +class PageSetting extends Base
  22 +{
  23 + protected $table = 'gl_project_page_setting';
  24 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AggregationSetting.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/10/23 10:45
  8 + */
  9 +
  10 +namespace App\Models\WebSetting;
  11 +
  12 +use App\Helper\Arr;
  13 +use App\Models\Base;
  14 +
  15 +/**
  16 + * @remark :产品关键字聚合页设置
  17 + * @name :AggregationSetting
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2023/10/23 10:48
  21 + */
  22 +class AggregationSetting extends Base
  23 +{
  24 + //设置关联表名
  25 + protected $table = 'gl_aggregation_setting';
  26 +
  27 + /**
  28 + * @remark :顶部banner获取器
  29 + * @name :getGalleryAttribute
  30 + * @author :lyh
  31 + * @method :post
  32 + * @time :2023/7/21 11:11
  33 + */
  34 + public function getTopBannerAttribute($value){
  35 + if(!empty($value)){
  36 + $value = Arr::s2a($value);
  37 + foreach ($value as $k => $v){
  38 + $v = getImageUrl($v);
  39 + $value[$k] = $v;
  40 + }
  41 + }
  42 + return $value;
  43 + }
  44 +
  45 + /**
  46 + * @remark :底部banner获取器
  47 + * @name :getGalleryAttribute
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2023/7/21 11:11
  51 + */
  52 + public function getFootBannerAttribute($value){
  53 + if(!empty($value)){
  54 + $value = Arr::s2a($value);
  55 + foreach ($value as $k => $v){
  56 + $v = getImageUrl($v);
  57 + $value[$k] = $v;
  58 + }
  59 + }
  60 + return $value;
  61 + }
  62 +}
@@ -26,7 +26,11 @@ Route::middleware(['bloginauth'])->group(function () { @@ -26,7 +26,11 @@ Route::middleware(['bloginauth'])->group(function () {
26 Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list'); 26 Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list');
27 Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del'); 27 Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del');
28 }); 28 });
29 - 29 + //项目独立头部和底部设置
  30 + Route::prefix('pageSetting')->group(function () {
  31 + Route::any('/info', [\App\Http\Controllers\Bside\BCom\PageSettingController::class, 'info'])->name('pageSetting_info');
  32 + Route::any('/edit',[\App\Http\Controllers\Bside\BCom\PageSettingController::class, 'edit'])->name('pageSetting_edit');
  33 + });
30 //站内信 34 //站内信
31 Route::prefix('mail')->group(function () { 35 Route::prefix('mail')->group(function () {
32 Route::any('/', [\App\Http\Controllers\Bside\Mail\MailController::class, 'lists'])->name('mail_lists'); 36 Route::any('/', [\App\Http\Controllers\Bside\Mail\MailController::class, 'lists'])->name('mail_lists');
@@ -178,6 +182,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -178,6 +182,12 @@ Route::middleware(['bloginauth'])->group(function () {
178 Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingImageController::class, 'save'])->name('web_image_save'); 182 Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingImageController::class, 'save'])->name('web_image_save');
179 }); 183 });
180 184
  185 + //聚合页相关配置
  186 + Route::prefix('aggregation')->group(function () {
  187 + Route::any('/info', [\App\Http\Controllers\Bside\Setting\AggregationSettingController::class, 'info'])->name('aggregation_info');
  188 + Route::any('/edit',[\App\Http\Controllers\Bside\Setting\AggregationSettingController::class, 'edit'])->name('aggregation_edit');
  189 + });
  190 +
181 }); 191 });
182 //产品 192 //产品
183 Route::prefix('product')->group(function () { 193 Route::prefix('product')->group(function () {