作者 lyh

gx

@@ -7,6 +7,8 @@ use App\Exceptions\BsideGlobalException; @@ -7,6 +7,8 @@ use App\Exceptions\BsideGlobalException;
7 use App\Helper\Common; 7 use App\Helper\Common;
8 use App\Http\Controllers\Controller; 8 use App\Http\Controllers\Controller;
9 use App\Http\Requests\Scene; 9 use App\Http\Requests\Scene;
  10 +use App\Models\Template\BTemplate;
  11 +use App\Models\Template\Setting;
10 use Illuminate\Http\JsonResponse; 12 use Illuminate\Http\JsonResponse;
11 use Illuminate\Http\Request; 13 use Illuminate\Http\Request;
12 use Illuminate\Http\Exceptions\HttpResponseException; 14 use Illuminate\Http\Exceptions\HttpResponseException;
@@ -170,4 +172,53 @@ class BaseController extends Controller @@ -170,4 +172,53 @@ class BaseController extends Controller
170 return \Illuminate\Support\Facades\Request::isMethod('post'); 172 return \Illuminate\Support\Facades\Request::isMethod('post');
171 } 173 }
172 174
  175 +
  176 + /**
  177 + * @remark :获取当前用户选择的模版
  178 + * @name :getTemplateId
  179 + * @author :lyh
  180 + * @method :post
  181 + * @time :2024/1/3 10:52
  182 + */
  183 + public function getTemplateId($source,$is_list){
  184 + $template_id = 0;
  185 + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
  186 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
  187 + //查看当前页面是否定制,是否开启可视化
  188 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  189 + if (in_array($type, $page_array)) {//是定制界面
  190 + return $this->success($template_id);
  191 + }
  192 + }
  193 + $bSettingModel = new Setting();
  194 + $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
  195 + if($info === false){
  196 + $this->fail('请先选择模版');
  197 + }
  198 + $template_id = $info['template_id'];
  199 + return $this->success($template_id);
  200 + }
  201 +
  202 + /**
  203 + * @remark :查看是否已装修
  204 + * @name :getIsRenovation
  205 + * @author :lyh
  206 + * @method :post
  207 + * @time :2023/9/13 14:02
  208 + */
  209 + public function getIsRenovation($source,$is_list,$template_id,$id){
  210 + $webTemplateModel = new BTemplate();
  211 + $param = [
  212 + 'source'=>$source,
  213 + 'project_id'=>$this->user['project_id'],
  214 + 'source_id'=>$id,
  215 + 'template_id'=>$template_id,
  216 + 'is_list'=>$is_list
  217 + ];
  218 + $templateInfo = $webTemplateModel->read($param);
  219 + if($templateInfo !== false){
  220 + return 1;
  221 + }
  222 + return 0;
  223 + }
173 } 224 }
@@ -9,6 +9,7 @@ use App\Http\Requests\Bside\Blog\BlogCategoryRequest; @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\Blog\BlogCategoryRequest;
9 use App\Models\Blog\Blog as BlogModel; 9 use App\Models\Blog\Blog as BlogModel;
10 use App\Models\Blog\BlogCategory as BlogCategoryModel; 10 use App\Models\Blog\BlogCategory as BlogCategoryModel;
11 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
  12 +use App\Models\Template\BTemplate;
12 13
13 class BlogCategoryController extends BaseController 14 class BlogCategoryController extends BaseController
14 { 15 {
@@ -25,9 +26,11 @@ class BlogCategoryController extends BaseController @@ -25,9 +26,11 @@ class BlogCategoryController extends BaseController
25 $data = []; 26 $data = [];
26 if(!empty($lists)){ 27 if(!empty($lists)){
27 $blogModel = new BlogModel(); 28 $blogModel = new BlogModel();
  29 + $template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
28 foreach ($lists as $k => $v){ 30 foreach ($lists as $k => $v){
29 $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); 31 $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
30 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG_CATE,$v['id']); 32 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG_CATE,$v['id']);
  33 + $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST,$template_id,$v['id']);
31 $lists[$k] = $v; 34 $lists[$k] = $v;
32 } 35 }
33 if(!isset($this->map['name'])){ 36 if(!isset($this->map['name'])){
@@ -32,18 +32,15 @@ class BlogController extends BaseController @@ -32,18 +32,15 @@ class BlogController extends BaseController
32 $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); 32 $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
33 if(!empty($lists)){ 33 if(!empty($lists)){
34 $lists = $lists->toArray(); 34 $lists = $lists->toArray();
35 -// //获取当前项目的所有分类  
36 $data = $this->getCategoryList(); 35 $data = $this->getCategoryList();
37 - //获取当前用户选择的模版  
38 - $templateSettingModel = new Setting();  
39 - $info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]); 36 + $template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL);
40 $user = new User(); 37 $user = new User();
41 foreach ($lists['list'] as $k => $v){ 38 foreach ($lists['list'] as $k => $v){
42 $v['category_name'] = $this->categoryName($v['category_id'],$data); 39 $v['category_name'] = $this->categoryName($v['category_id'],$data);
43 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']); 40 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);
44 $v['image_link'] = getImageUrl($v['image']); 41 $v['image_link'] = getImageUrl($v['image']);
45 $v['operator_name'] = $user->getName($v['operator_id']); 42 $v['operator_name'] = $user->getName($v['operator_id']);
46 - $v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']); 43 + $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
47 $lists['list'][$k] = $v; 44 $lists['list'][$k] = $v;
48 } 45 }
49 } 46 }
@@ -51,31 +48,6 @@ class BlogController extends BaseController @@ -51,31 +48,6 @@ class BlogController extends BaseController
51 } 48 }
52 49
53 /** 50 /**
54 - * @remark :查看产品是否已装修  
55 - * @name :getProductIsRenovation  
56 - * @author :lyh  
57 - * @method :post  
58 - * @time :2023/9/13 14:02  
59 - */  
60 - public function getProductIsRenovation($info,$id){  
61 - if($info !== false){  
62 - $webTemplateModel = new BTemplate();  
63 - $param = [  
64 - 'source'=>BTemplate::SOURCE_BLOG,  
65 - 'project_id'=>$this->user['project_id'],  
66 - 'source_id'=>$id,  
67 - 'template_id'=>$info['template_id'],  
68 - 'is_list'=>0  
69 - ];  
70 - $templateInfo = $webTemplateModel->read($param);  
71 - if($templateInfo !== false){  
72 - return 1;  
73 - }  
74 - }  
75 - return 0;  
76 - }  
77 -  
78 - /**  
79 * @remark :处理列表返回参数 51 * @remark :处理列表返回参数
80 * @name :handleReturnParam 52 * @name :handleReturnParam
81 * @author :lyh 53 * @author :lyh
@@ -9,6 +9,7 @@ use App\Http\Requests\Bside\News\NewsCategoryRequest; @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\News\NewsCategoryRequest;
9 use App\Models\News\News as NewsModel; 9 use App\Models\News\News as NewsModel;
10 use App\Models\News\NewsCategory as NewsCategoryModel; 10 use App\Models\News\NewsCategory as NewsCategoryModel;
11 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
  12 +use App\Models\Template\BTemplate;
12 13
13 class NewsCategoryController extends BaseController 14 class NewsCategoryController extends BaseController
14 { 15 {
@@ -25,9 +26,11 @@ class NewsCategoryController extends BaseController @@ -25,9 +26,11 @@ class NewsCategoryController extends BaseController
25 $data = []; 26 $data = [];
26 if(!empty($lists)){ 27 if(!empty($lists)){
27 $newsModel = new NewsModel(); 28 $newsModel = new NewsModel();
  29 + $template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
28 foreach ($lists as $k => $v){ 30 foreach ($lists as $k => $v){
29 $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); 31 $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
30 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id']); 32 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id']);
  33 + $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_LIST,$template_id,$v['id']);
31 $lists[$k] = $v; 34 $lists[$k] = $v;
32 } 35 }
33 if(!isset($this->map['name'])){ 36 if(!isset($this->map['name'])){
@@ -36,15 +36,14 @@ class NewsController extends BaseController @@ -36,15 +36,14 @@ class NewsController extends BaseController
36 // //获取当前项目的所有分类 36 // //获取当前项目的所有分类
37 $data = $this->getCategoryList(); 37 $data = $this->getCategoryList();
38 //获取当前用户选择的模版 38 //获取当前用户选择的模版
39 - $templateSettingModel = new Setting();  
40 - $info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]); 39 + $template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id
41 $user = new User(); 40 $user = new User();
42 foreach ($lists['list'] as $k => $v){ 41 foreach ($lists['list'] as $k => $v){
43 $v['category_name'] = $this->categoryName($v['category_id'],$data); 42 $v['category_name'] = $this->categoryName($v['category_id'],$data);
44 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']); 43 $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
45 $v['image_link'] = getImageUrl($v['image']); 44 $v['image_link'] = getImageUrl($v['image']);
46 $v['operator_name'] = $user->getName($v['operator_id']); 45 $v['operator_name'] = $user->getName($v['operator_id']);
47 - $v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']); 46 + $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']);
48 $lists['list'][$k] = $v; 47 $lists['list'][$k] = $v;
49 } 48 }
50 } 49 }
@@ -52,31 +51,6 @@ class NewsController extends BaseController @@ -52,31 +51,6 @@ class NewsController extends BaseController
52 } 51 }
53 52
54 /** 53 /**
55 - * @remark :查看产品是否已装修  
56 - * @name :getProductIsRenovation  
57 - * @author :lyh  
58 - * @method :post  
59 - * @time :2023/9/13 14:02  
60 - */  
61 - public function getProductIsRenovation($info,$id){  
62 - if($info !== false){  
63 - $webTemplateModel = new BTemplate();  
64 - $param = [  
65 - 'source'=>4,  
66 - 'project_id'=>$this->user['project_id'],  
67 - 'source_id'=>$id,  
68 - 'template_id'=>$info['template_id'],  
69 - 'is_list'=>0  
70 - ];  
71 - $templateInfo = $webTemplateModel->read($param);  
72 - if($templateInfo !== false){  
73 - return 1;  
74 - }  
75 - }  
76 - return 0;  
77 - }  
78 -  
79 - /**  
80 * @remark :处理列表返回参数 54 * @remark :处理列表返回参数
81 * @name :handleReturnParam 55 * @name :handleReturnParam
82 * @author :lyh 56 * @author :lyh
@@ -10,6 +10,7 @@ use App\Models\Product\Category; @@ -10,6 +10,7 @@ use App\Models\Product\Category;
10 use App\Models\Product\CategoryRelated; 10 use App\Models\Product\CategoryRelated;
11 use App\Models\Product\Product; 11 use App\Models\Product\Product;
12 use App\Models\RouteMap\RouteMap; 12 use App\Models\RouteMap\RouteMap;
  13 +use App\Models\Template\BTemplate;
13 use App\Rules\Ids; 14 use App\Rules\Ids;
14 use Illuminate\Http\Request; 15 use Illuminate\Http\Request;
15 16
@@ -36,10 +37,12 @@ class CategoryController extends BaseController @@ -36,10 +37,12 @@ class CategoryController extends BaseController
36 $list = $category->list($this->map,['sort','id'],$filed); 37 $list = $category->list($this->map,['sort','id'],$filed);
37 $data = []; 38 $data = [];
38 if(!empty($list)){ 39 if(!empty($list)){
  40 + $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
39 foreach ($list as $k =>$v){ 41 foreach ($list as $k =>$v){
40 $v['url'] = $this->user['domain'] . $v['route'].'/'; 42 $v['url'] = $this->user['domain'] . $v['route'].'/';
41 $v['product_num'] = Category::getProductNum($v['id']); 43 $v['product_num'] = Category::getProductNum($v['id']);
42 $v['image_link'] = getImageUrl($v['image']); 44 $v['image_link'] = getImageUrl($v['image']);
  45 + $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
43 $list[$k] = $v; 46 $list[$k] = $v;
44 } 47 }
45 if(!isset($this->map['title'])){ 48 if(!isset($this->map['title'])){
@@ -7,6 +7,7 @@ use App\Exceptions\BsideGlobalException; @@ -7,6 +7,7 @@ use App\Exceptions\BsideGlobalException;
7 use App\Helper\Arr; 7 use App\Helper\Arr;
8 use App\Helper\Common; 8 use App\Helper\Common;
9 use App\Http\Controllers\Bside\BaseController; 9 use App\Http\Controllers\Bside\BaseController;
  10 +use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
10 use App\Http\Logic\Bside\Product\ProductLogic; 11 use App\Http\Logic\Bside\Product\ProductLogic;
11 use App\Http\Requests\Bside\Product\ProductRequest; 12 use App\Http\Requests\Bside\Product\ProductRequest;
12 use App\Models\Product\Category; 13 use App\Models\Product\Category;
@@ -52,15 +53,13 @@ class ProductController extends BaseController @@ -52,15 +53,13 @@ class ProductController extends BaseController
52 $lists = $lists->toArray(); 53 $lists = $lists->toArray();
53 $cate_data = $this->getCategoryList();//分类 54 $cate_data = $this->getCategoryList();//分类
54 $key_data = $this->getKeywordsList();//关键字 55 $key_data = $this->getKeywordsList();//关键字
55 - //获取当前用户选择的模版  
56 - $templateSettingModel = new Setting();  
57 - $info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]); 56 + $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
58 $userModel = new User(); 57 $userModel = new User();
59 foreach ($lists['list'] as $k=>$v){ 58 foreach ($lists['list'] as $k=>$v){
60 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data); 59 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
61 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data); 60 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
62 $v['created_uid_text'] = $userModel->getName($v['created_uid']); 61 $v['created_uid_text'] = $userModel->getName($v['created_uid']);
63 - $v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']); 62 + $v['is_renovation'] = $this->getIsRenovation(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
64 $v['url'] = $this->user['domain'].$v['route'].'/'; 63 $v['url'] = $this->user['domain'].$v['route'].'/';
65 $lists['list'][$k] = $v; 64 $lists['list'][$k] = $v;
66 } 65 }
@@ -119,31 +118,6 @@ class ProductController extends BaseController @@ -119,31 +118,6 @@ class ProductController extends BaseController
119 } 118 }
120 119
121 /** 120 /**
122 - * @remark :查看产品是否已装修  
123 - * @name :getProductIsRenovation  
124 - * @author :lyh  
125 - * @method :post  
126 - * @time :2023/9/13 14:02  
127 - */  
128 - public function getProductIsRenovation($info,$id){  
129 - if($info !== false){  
130 - $webTemplateModel = new BTemplate();  
131 - $param = [  
132 - 'source'=>2,  
133 - 'project_id'=>$this->user['project_id'],  
134 - 'source_id'=>$id,  
135 - 'template_id'=>$info['template_id'],  
136 - 'is_list'=>0  
137 - ];  
138 - $templateInfo = $webTemplateModel->read($param);  
139 - if($templateInfo !== false){  
140 - return 1;  
141 - }  
142 - }  
143 - return 0;  
144 - }  
145 -  
146 - /**  
147 * @remark :获取所有分类 121 * @remark :获取所有分类
148 * @name :getCategoryList 122 * @name :getCategoryList
149 * @author :lyh 123 * @author :lyh
@@ -266,9 +240,8 @@ class ProductController extends BaseController @@ -266,9 +240,8 @@ class ProductController extends BaseController
266 } 240 }
267 $v['status_text'] = Product::statusMap()[$v['status']] ?? ''; 241 $v['status_text'] = Product::statusMap()[$v['status']] ?? '';
268 //获取当前用户选择的模版 242 //获取当前用户选择的模版
269 - $templateSettingModel = new Setting();  
270 - $templateInfo = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);  
271 - $v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']); 243 + $template_id = $this->getTemplateId(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
  244 + $v['is_renovation'] = $this->getIsRenovation(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
272 $v['url'] = $this->user['domain'].$v['route']; 245 $v['url'] = $this->user['domain'].$v['route'];
273 //获取当前数据扩展字段及值 246 //获取当前数据扩展字段及值
274 $v['extend'] = $this->getExtendInfo($v['id']); 247 $v['extend'] = $this->getExtendInfo($v['id']);
@@ -45,6 +45,7 @@ class BTemplate extends Base @@ -45,6 +45,7 @@ class BTemplate extends Base
45 * 其他相关定义 45 * 其他相关定义
46 */ 46 */
47 const IS_LIST = 1;//列表页 47 const IS_LIST = 1;//列表页
  48 + const IS_DETAIL = 0;//详情页
48 const IS_HEADER = 1;//独立头部底部 49 const IS_HEADER = 1;//独立头部底部
49 const IS_NO_HEADER = 0;//非独立头部底部 50 const IS_NO_HEADER = 0;//非独立头部底部
50 const IS_CUSTOM = 1;//为扩展模块 51 const IS_CUSTOM = 1;//为扩展模块