作者 lyh

gx

@@ -436,6 +436,7 @@ if (!function_exists('getImageUrl')) { @@ -436,6 +436,7 @@ if (!function_exists('getImageUrl')) {
436 return $url; 436 return $url;
437 } 437 }
438 } 438 }
  439 +
439 if (!function_exists('getFileUrl')) { 440 if (!function_exists('getFileUrl')) {
440 /** 441 /**
441 * @remark :获取文件链接 442 * @remark :获取文件链接
@@ -38,21 +38,23 @@ class ProductController extends BaseController @@ -38,21 +38,23 @@ class ProductController extends BaseController
38 */ 38 */
39 public function index(Product $product) 39 public function index(Product $product)
40 { 40 {
41 - $this->order = 'sort';  
42 - if(isset($this->map['title']) && !empty($this->map['title'])){  
43 - $this->map['title'] = ['like','%'.$this->map['title'].'%'];  
44 - }  
45 - if(isset($this->map['category_id']) && !empty($this->map['category_id'])){  
46 - $this->map['category_id'] = ['like','%'.$this->map['category_id'].'%'];  
47 - }  
48 - $this->map['project_id'] = $this->user['project_id']; 41 + $this->map = $this->searchParam();
49 $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' , 42 $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
50 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']; 43 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
51 - $lists = $product->lists($this->map,$this->page,$this->row,$this->order,$filed); 44 + $lists = $product->lists($this->map,$this->page,$this->row,$this->order = 'sort',$filed);
52 if(!empty($lists['list'])){ 45 if(!empty($lists['list'])){
  46 + //获取当前用户选择的模版
  47 + $templateSettingModel = new BSetting();
  48 + $info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
  49 + $cate_data = $this->getCategoryList();
  50 + $key_data = $this->getKeywordsList();
  51 + $userModel = new User();
53 foreach ($lists['list'] as $k=>$v){ 52 foreach ($lists['list'] as $k=>$v){
54 //处理参数 53 //处理参数
55 - $v = $this->handleParam($v); 54 + $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
  55 + $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
  56 + $v['created_uid_text'] = $userModel->getName($v['created_uid']);
  57 + $v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
56 $lists['list'][$k] = $v; 58 $lists['list'][$k] = $v;
57 } 59 }
58 } 60 }
@@ -60,15 +62,31 @@ class ProductController extends BaseController @@ -60,15 +62,31 @@ class ProductController extends BaseController
60 } 62 }
61 63
62 /** 64 /**
  65 + * @remark :搜索参数处理
  66 + * @name :searchParam
  67 + * @author :lyh
  68 + * @method :post
  69 + * @time :2023/9/14 14:32
  70 + */
  71 + public function searchParam(){
  72 + if(isset($this->map['title']) && !empty($this->map['title'])){
  73 + $this->map['title'] = ['like','%'.$this->map['title'].'%'];
  74 + }
  75 + if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
  76 + $this->map['category_id'] = ['like','%'.$this->map['category_id'].'%'];
  77 + }
  78 + $this->map['project_id'] = $this->user['project_id'];
  79 + return $this->map;
  80 + }
  81 +
  82 + /**
63 * @remark :查看产品是否已装修 83 * @remark :查看产品是否已装修
64 * @name :getProductIsRenovation 84 * @name :getProductIsRenovation
65 * @author :lyh 85 * @author :lyh
66 * @method :post 86 * @method :post
67 * @time :2023/9/13 14:02 87 * @time :2023/9/13 14:02
68 */ 88 */
69 - public function getProductIsRenovation($id){  
70 - $templateSettingModel = new BSetting();  
71 - $info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]); 89 + public function getProductIsRenovation($info,$id){
72 if($info !== false){ 90 if($info !== false){
73 $webTemplateModel = new BTemplate(); 91 $webTemplateModel = new BTemplate();
74 $param = [ 92 $param = [
@@ -86,6 +104,86 @@ class ProductController extends BaseController @@ -86,6 +104,86 @@ class ProductController extends BaseController
86 } 104 }
87 105
88 /** 106 /**
  107 + * @remark :获取所有分类
  108 + * @name :getCategoryList
  109 + * @author :lyh
  110 + * @method :post
  111 + * @time :2023/9/14 13:56
  112 + */
  113 + public function getCategoryList(){
  114 + $categoryModel = new Category();
  115 + $data = [];
  116 + $cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','title']);
  117 + if(!empty($cateList)){
  118 + foreach ($cateList as $value){
  119 + $data[$value['id']] = $value['title'];
  120 + }
  121 + }
  122 + return $data;
  123 + }
  124 +
  125 + /**
  126 + * @remark :获取所有关键词
  127 + * @name :getCategoryList
  128 + * @author :lyh
  129 + * @method :post
  130 + * @time :2023/9/14 13:56
  131 + */
  132 + public function getKeywordsList(){
  133 + $keywordModel = new Keyword();
  134 + $data = [];
  135 + $cateList = $keywordModel->list(['project_id'=>$this->user['project_id']],['id','title']);
  136 + if(!empty($cateList)){
  137 + foreach ($cateList as $value){
  138 + $data[$value['id']] = $value['title'];
  139 + }
  140 + }
  141 + return $data;
  142 + }
  143 +
  144 + /**
  145 + * @remark :获取分类名称
  146 + * @name :categoryName
  147 + * @author :lyh
  148 + * @method :post
  149 + * @time :2023/9/14 13:58
  150 + */
  151 + public function categoryName($category_id,$data){
  152 + $category_name = '';
  153 + if(!empty($category_id) && !empty($data)){
  154 + $arr = explode(',',trim($category_id,','));
  155 + foreach ($arr as $v){
  156 + if(isset($data[$v])){
  157 + $category_name .= $data[$v].',';
  158 + }
  159 + }
  160 + $category_name = trim($category_name,',');
  161 + }
  162 + return $category_name;
  163 + }
  164 +
  165 + /**
  166 + * @remark :获取关键词名称
  167 + * @name :categoryName
  168 + * @author :lyh
  169 + * @method :post
  170 + * @time :2023/9/14 13:58
  171 + */
  172 + public function keywordName($keyword,$data){
  173 + $keyword_name = '';
  174 + if(!empty($keyword) && !empty($data)){
  175 + $arr = explode(',',trim($keyword,','));
  176 + foreach ($arr as $v){
  177 + if(isset($data[$v])){
  178 + $keyword_name .= $data[$v].',';
  179 + }
  180 + }
  181 + $keyword_name = trim($keyword_name,',');
  182 + }
  183 + return $keyword_name;
  184 + }
  185 +
  186 + /**
89 * @remark :处理列表参数 187 * @remark :处理列表参数
90 * @name :handleParam 188 * @name :handleParam
91 * @author :lyh 189 * @author :lyh
@@ -112,11 +210,10 @@ class ProductController extends BaseController @@ -112,11 +210,10 @@ class ProductController extends BaseController
112 $v['keyword_id_text'] = trim($v['keyword_id_text'],','); 210 $v['keyword_id_text'] = trim($v['keyword_id_text'],',');
113 } 211 }
114 $v['status_text'] = Product::statusMap()[$v['status']] ?? ''; 212 $v['status_text'] = Product::statusMap()[$v['status']] ?? '';
115 - $v['created_uid_text'] = (new User())->read(['id'=>$v['created_uid']])['name'] ?? '';  
116 $v['url'] = $this->user['domain'].$v['route']; 213 $v['url'] = $this->user['domain'].$v['route'];
117 - $v['is_renovation'] = $this->getProductIsRenovation($v['id']);  
118 return $v; 214 return $v;
119 } 215 }
  216 +
120 /** 217 /**
121 * @remark :详情 218 * @remark :详情
122 * @name :info 219 * @name :info