作者 赵彬吉
@@ -31,6 +31,17 @@ class DomainInfoController extends BaseController @@ -31,6 +31,17 @@ class DomainInfoController extends BaseController
31 $this->map['domain'] = ['like','%'.$this->map['domain'],'%']; 31 $this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
32 } 32 }
33 $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order); 33 $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
  34 + if(!empty($lists)){
  35 + $project_model = new Project();
  36 + foreach ($lists['list'] as $k=>$v){
  37 + $company = '';
  38 + $pro_info = $project_model->read(['id'=>$v['project_id']],'company');
  39 + if($pro_info){
  40 + $company = $pro_info['company'];
  41 + }
  42 + $lists['list'][$k]['company'] = $company;
  43 + }
  44 + }
34 return $this->response('success', Code::SUCCESS, $lists); 45 return $this->response('success', Code::SUCCESS, $lists);
35 } 46 }
36 47
@@ -2,10 +2,12 @@ @@ -2,10 +2,12 @@
2 2
3 namespace App\Http\Controllers\Bside\Product; 3 namespace App\Http\Controllers\Bside\Product;
4 4
  5 +use App\Enums\Common\Code;
5 use App\Helper\Arr; 6 use App\Helper\Arr;
6 use App\Http\Controllers\Bside\BaseController; 7 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\Product\DescribeLogic; 8 use App\Http\Logic\Bside\Product\DescribeLogic;
8 use App\Http\Requests\Bside\Product\DescribeRequest; 9 use App\Http\Requests\Bside\Product\DescribeRequest;
  10 +use App\Models\Product\Describe;
9 use App\Rules\Ids; 11 use App\Rules\Ids;
10 use Illuminate\Http\Request; 12 use Illuminate\Http\Request;
11 13
@@ -18,15 +20,14 @@ use Illuminate\Http\Request; @@ -18,15 +20,14 @@ use Illuminate\Http\Request;
18 class DescribeController extends BaseController 20 class DescribeController extends BaseController
19 { 21 {
20 22
21 - public function index(DescribeLogic $logic) 23 + public function index(Describe $describe)
22 { 24 {
23 - $map = [];  
24 - if(!empty($this->param['search'])){  
25 - $map[] = ['title', 'like', "%{$this->param['search']}%"]; 25 + if(!empty($this->map['search'])){
  26 + $this->map['title'] = ['like',"%{$this->param['search']}%"];
  27 + unset($this->map['search']);
26 } 28 }
27 - $sort = ['id' => 'desc'];  
28 - $data = $logic->getList($map, $sort, ['id', 'title', 'text', 'status', 'created_at'],$this->row);  
29 - return $this->success($data); 29 + $data = $describe->lists($this->map,$this->page,$this->row, 'id', ['id', 'title', 'text', 'status', 'created_at']);
  30 + $this->response('success',Code::SUCCESS,$data);
30 } 31 }
31 32
32 public function info(Request $request, DescribeLogic $logic){ 33 public function info(Request $request, DescribeLogic $logic){
@@ -39,10 +40,18 @@ class DescribeController extends BaseController @@ -39,10 +40,18 @@ class DescribeController extends BaseController
39 return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at'])); 40 return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at']));
40 } 41 }
41 42
42 - public function save(DescribeRequest $request, DescribeLogic $logic) 43 + /**
  44 + * @remark :baocun
  45 + * @name :save
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2023/10/17 10:36
  49 + */
  50 + public function save(DescribeRequest $request,DescribeLogic $logic)
43 { 51 {
44 - $data = $logic->save($this->param);  
45 - return $this->success($data); 52 + $request->validated();
  53 + $logic->describeSave();
  54 + return $this->success();
46 } 55 }
47 56
48 public function delete(Request $request, DescribeLogic $logic) 57 public function delete(Request $request, DescribeLogic $logic)
@@ -113,7 +113,7 @@ class ProjectLogic extends BaseLogic @@ -113,7 +113,7 @@ class ProjectLogic extends BaseLogic
113 DB::commit(); 113 DB::commit();
114 }catch (\Exception $e){ 114 }catch (\Exception $e){
115 DB::rollBack(); 115 DB::rollBack();
116 - $this->fail('error'); 116 + $this->fail('请填写完整后再提交');
117 } 117 }
118 return $this->success(); 118 return $this->success();
119 } 119 }
@@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\BTemplate; @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\BTemplate;
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\Service\Service as ServiceSettingModel; 13 use App\Models\Service\Service as ServiceSettingModel;
14 use App\Models\Template\BTemplate; 14 use App\Models\Template\BTemplate;
  15 +use App\Models\Template\BTemplateCommon;
15 use App\Models\Template\BTemplateLog; 16 use App\Models\Template\BTemplateLog;
16 17
17 class BTemplateLogLogic extends BaseLogic 18 class BTemplateLogLogic extends BaseLogic
@@ -41,12 +42,17 @@ class BTemplateLogLogic extends BaseLogic @@ -41,12 +42,17 @@ class BTemplateLogLogic extends BaseLogic
41 if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ 42 if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
42 $this->fail('演示项目仅支持演示功能,无法更改首页'); 43 $this->fail('演示项目仅支持演示功能,无法更改首页');
43 } 44 }
  45 + try {
44 $data = $this->setParam($info); 46 $data = $this->setParam($info);
45 $BTemplateModel = new BTemplate(); 47 $BTemplateModel = new BTemplate();
46 - $rs = $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);  
47 - if($rs === false){  
48 - $this->fail('error'); 48 + $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
  49 + $commonData = $this->setCommonParam($info);
  50 + $commonTemplateModel = new BTemplateCommon();
  51 + $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
  52 + }catch (\Exception $e){
  53 + $this->fail('系统错误,请联系管理员');
49 } 54 }
  55 + //同步更新公共头和底
50 return $this->success(); 56 return $this->success();
51 } 57 }
52 58
@@ -71,6 +77,23 @@ class BTemplateLogLogic extends BaseLogic @@ -71,6 +77,23 @@ class BTemplateLogLogic extends BaseLogic
71 } 77 }
72 78
73 /** 79 /**
  80 + * @remark :设置回滚公共参数参数
  81 + * @name :setParam
  82 + * @author :lyh
  83 + * @method :post
  84 + * @time :2023/8/23 14:18
  85 + */
  86 + public function setCommonParam($info){
  87 + $data = [
  88 + 'head_html'=>$info['head_html'],
  89 + 'head_css'=>$info['head_css'],
  90 + 'footer_html'=>$info['footer_html'],
  91 + 'footer_css'=>$info['footer_css'],
  92 + ];
  93 + return $this->success($data);
  94 + }
  95 +
  96 + /**
74 * @remark :获取数据详情 97 * @remark :获取数据详情
75 * @name :templateLogInfo 98 * @name :templateLogInfo
76 * @author :lyh 99 * @author :lyh
@@ -104,9 +104,14 @@ class BTemplateLogic extends BaseLogic @@ -104,9 +104,14 @@ class BTemplateLogic extends BaseLogic
104 $ATemplateModel = new Template(); 104 $ATemplateModel = new Template();
105 $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); 105 $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
106 }else{ 106 }else{
107 - //渲染首页数据 107 + $commonTemplateModel = new BTemplateCommon();
  108 + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
  109 + if($commonInfo !== false){
  110 + $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
  111 + $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
  112 + }
108 $ATemplateModel = new Template(); 113 $ATemplateModel = new Template();
109 - $ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); 114 + $ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']],['name','image']);
110 $TemplateInfo['name'] = $ATemplateInfo['name']; 115 $TemplateInfo['name'] = $ATemplateInfo['name'];
111 $TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']); 116 $TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
112 } 117 }
@@ -122,24 +127,35 @@ class BTemplateLogic extends BaseLogic @@ -122,24 +127,35 @@ class BTemplateLogic extends BaseLogic
122 * @time :2023/7/25 16:40 127 * @time :2023/7/25 16:40
123 */ 128 */
124 public function productHtml($info,$source,$source_id){ 129 public function productHtml($info,$source,$source_id){
125 - //查看当前模板是否已编辑保存web_template  
126 - $TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);  
127 - if($TemplateInfo === false){  
128 - //获取首页数据  
129 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); 130 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
130 if($homeTemplateInfo === false){ 131 if($homeTemplateInfo === false){
131 $this->fail('请先装修首页'); 132 $this->fail('请先装修首页');
132 } 133 }
  134 + //查看当前模板是否已编辑保存web_template
  135 + $TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
  136 + if($TemplateInfo === false){
  137 + //兼容老数据
  138 + $commonTemplateModel = new BTemplateCommon();
  139 + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
  140 + if($commonInfo !== false){
  141 + $html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
  142 + $commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
  143 + }else{
133 $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']); 144 $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
134 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html); 145 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
135 - }else{  
136 - $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);  
137 - if($homeTemplateInfo === false){  
138 - $this->fail('请先装修首页');  
139 } 146 }
  147 + }else{
  148 + //兼容老数据
  149 + $commonTemplateModel = new BTemplateCommon();
  150 + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
  151 + if($commonInfo !== false){
  152 + $html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
  153 + $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
  154 + }else{
140 $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']); 155 $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
141 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html); 156 $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
142 } 157 }
  158 + }
143 $TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据 159 $TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
144 return $this->success($TemplateInfo); 160 return $this->success($TemplateInfo);
145 } 161 }
@@ -187,17 +203,19 @@ class BTemplateLogic extends BaseLogic @@ -187,17 +203,19 @@ class BTemplateLogic extends BaseLogic
187 $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']); 203 $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
188 //字符串截取 204 //字符串截取
189 $this->param = $this->stringProcessing($this->param); 205 $this->param = $this->stringProcessing($this->param);
190 - $this->param = $this->templateSaveParam($this->param); 206 + $this->saveCommonTemplate($this->param);
  207 + $this->param = $this->templateSaveParam($this->param);//组装数据
191 if($info === false){ 208 if($info === false){
192 $this->model->add($this->param); 209 $this->model->add($this->param);
193 }else{ 210 }else{
194 $this->model->edit($this->param,['id'=>$info['id']]); 211 $this->model->edit($this->param,['id'=>$info['id']]);
195 } 212 }
  213 + //写入操作模版记录
196 $this->setTemplateLog($this->param); 214 $this->setTemplateLog($this->param);
197 DB::commit(); 215 DB::commit();
198 }catch (\Exception $e){ 216 }catch (\Exception $e){
199 DB::rollBack(); 217 DB::rollBack();
200 - $this->fail('error'); 218 + $this->fail('系统错误,请联系管理员');
201 } 219 }
202 //通知更新 220 //通知更新
203 $this->homeOrProduct($this->param['source'],$this->param['source_id']); 221 $this->homeOrProduct($this->param['source'],$this->param['source_id']);
@@ -205,6 +223,34 @@ class BTemplateLogic extends BaseLogic @@ -205,6 +223,34 @@ class BTemplateLogic extends BaseLogic
205 } 223 }
206 224
207 /** 225 /**
  226 + * @remark :保存头部公共数据
  227 + * @name :saveCommonTemplate
  228 + * @author :lyh
  229 + * @method :post
  230 + * @time :2023/10/13 14:27
  231 + */
  232 + public function saveCommonTemplate($param){
  233 + $templateCommonModel = new BTemplateCommon();
  234 + $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id']]);
  235 +// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
  236 + $data = [
  237 + 'head_html'=>$param['head_html'],
  238 + 'head_css'=>$param['head_css'],
  239 + 'footer_html'=>$param['footer_html'],
  240 + 'footer_css'=>$param['footer_css'],
  241 + 'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
  242 + ];
  243 + if($info === false){
  244 + $data['template_id'] = $param['template_id'];
  245 + $data['project_id'] = $this->user['project_id'];
  246 + $templateCommonModel->add($data);
  247 + }else{
  248 + $templateCommonModel->edit($data,['id'=>$info['id']]);
  249 + }
  250 + return $this->success();
  251 + }
  252 +
  253 + /**
208 * @remark :生成记录 254 * @remark :生成记录
209 * @name :setTemplateLog 255 * @name :setTemplateLog
210 * @author :lyh 256 * @author :lyh
@@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic;
6 use App\Models\RouteMap\RouteMap; 6 use App\Models\RouteMap\RouteMap;
7 use App\Models\Service\Service as ServiceSettingModel; 7 use App\Models\Service\Service as ServiceSettingModel;
8 use App\Models\Template\BCustomTemplate; 8 use App\Models\Template\BCustomTemplate;
  9 +use App\Models\Template\BTemplateCommon;
9 use App\Models\Template\Setting; 10 use App\Models\Template\Setting;
10 use App\Models\Template\BTemplate; 11 use App\Models\Template\BTemplate;
11 12
@@ -179,26 +180,20 @@ class CustomTemplateLogic extends BaseLogic @@ -179,26 +180,20 @@ class CustomTemplateLogic extends BaseLogic
179 * @time :2023/7/21 18:08 180 * @time :2023/7/21 18:08
180 */ 181 */
181 public function getBodyHeaderFooter($preg_html,$html_style){ 182 public function getBodyHeaderFooter($preg_html,$html_style){
  183 + if(empty($preg_html)){
  184 + $preg_html = "<main></main>";
  185 + $html_style = "<style id='globalsojs-styles'></style>";
  186 + }
182 //获取设置的默认模版 187 //获取设置的默认模版
183 $bSettingModel = new Setting(); 188 $bSettingModel = new Setting();
184 $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 189 $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
185 - //获取模板详情  
186 - $bTemplateModel = new BTemplate();  
187 - $TemplateInfo = $bTemplateModel->read([  
188 - 'template_id'=>$info['template_id'],  
189 - 'project_id'=>$this->user['project_id'],  
190 - 'source'=>1//首页  
191 - ]); 190 + //兼容老数据
  191 + $commonTemplateModel = new BTemplateCommon();
  192 + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
192 $html = ''; 193 $html = '';
193 - if($TemplateInfo !== false){  
194 - if(empty($preg_html)){  
195 - $preg_html = "<main></main>";  
196 - $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $TemplateInfo['html']);  
197 - }else{  
198 - $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s',$html_style , $TemplateInfo['html']);  
199 - }  
200 - //内容  
201 - $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html); 194 + if($commonInfo !== false){
  195 + $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
  196 + $commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
202 } 197 }
203 return $html; 198 return $html;
204 } 199 }
@@ -17,7 +17,26 @@ class DescribeLogic extends BaseLogic @@ -17,7 +17,26 @@ class DescribeLogic extends BaseLogic
17 public function __construct() 17 public function __construct()
18 { 18 {
19 parent::__construct(); 19 parent::__construct();
20 - 20 + $this->param = $this->requestAll;
21 $this->model = new Describe(); 21 $this->model = new Describe();
22 } 22 }
  23 +
  24 + /**
  25 + * @remark :保存通用描述
  26 + * @name :describeSave
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/10/17 10:37
  30 + */
  31 + public function describeSave(){
  32 + if(isset($this->param['id']) && !empty($this->param['id'])){
  33 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  34 + }else{
  35 + $rs = $this->model->add($this->param);
  36 + }
  37 + if($rs === false){
  38 + $this->fail('系统错误,请联系管理员');
  39 + }
  40 + return $this->success();
  41 + }
23 } 42 }
@@ -13,7 +13,7 @@ use App\Models\Base; @@ -13,7 +13,7 @@ use App\Models\Base;
13 13
14 class BTemplateCommon extends Base 14 class BTemplateCommon extends Base
15 { 15 {
16 - protected $table = 'gl_template_common'; 16 + protected $table = 'gl_web_template_common';
17 //连接数据库 17 //连接数据库
18 protected $connection = 'custom_mysql'; 18 protected $connection = 'custom_mysql';
19 } 19 }