|
...
|
...
|
@@ -38,21 +38,23 @@ class ProductController extends BaseController |
|
|
|
*/
|
|
|
|
public function index(Product $product)
|
|
|
|
{
|
|
|
|
$this->order = 'sort';
|
|
|
|
if(isset($this->map['title']) && !empty($this->map['title'])){
|
|
|
|
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
|
|
|
|
}
|
|
|
|
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
|
|
|
|
$this->map['category_id'] = ['like','%'.$this->map['category_id'].'%'];
|
|
|
|
}
|
|
|
|
$this->map['project_id'] = $this->user['project_id'];
|
|
|
|
$this->map = $this->searchParam();
|
|
|
|
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
|
|
|
|
'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
|
|
|
|
$lists = $product->lists($this->map,$this->page,$this->row,$this->order,$filed);
|
|
|
|
$lists = $product->lists($this->map,$this->page,$this->row,$this->order = 'sort',$filed);
|
|
|
|
if(!empty($lists['list'])){
|
|
|
|
//获取当前用户选择的模版
|
|
|
|
$templateSettingModel = new BSetting();
|
|
|
|
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
$cate_data = $this->getCategoryList();
|
|
|
|
$key_data = $this->getKeywordsList();
|
|
|
|
$userModel = new User();
|
|
|
|
foreach ($lists['list'] as $k=>$v){
|
|
|
|
//处理参数
|
|
|
|
$v = $this->handleParam($v);
|
|
|
|
$v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
|
|
|
|
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
|
|
|
|
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
|
|
|
|
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
|
|
|
|
$lists['list'][$k] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -60,15 +62,31 @@ class ProductController extends BaseController |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :搜索参数处理
|
|
|
|
* @name :searchParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/14 14:32
|
|
|
|
*/
|
|
|
|
public function searchParam(){
|
|
|
|
if(isset($this->map['title']) && !empty($this->map['title'])){
|
|
|
|
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
|
|
|
|
}
|
|
|
|
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
|
|
|
|
$this->map['category_id'] = ['like','%'.$this->map['category_id'].'%'];
|
|
|
|
}
|
|
|
|
$this->map['project_id'] = $this->user['project_id'];
|
|
|
|
return $this->map;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :查看产品是否已装修
|
|
|
|
* @name :getProductIsRenovation
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/13 14:02
|
|
|
|
*/
|
|
|
|
public function getProductIsRenovation($id){
|
|
|
|
$templateSettingModel = new BSetting();
|
|
|
|
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
public function getProductIsRenovation($info,$id){
|
|
|
|
if($info !== false){
|
|
|
|
$webTemplateModel = new BTemplate();
|
|
|
|
$param = [
|
|
...
|
...
|
@@ -86,6 +104,86 @@ class ProductController extends BaseController |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取所有分类
|
|
|
|
* @name :getCategoryList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/14 13:56
|
|
|
|
*/
|
|
|
|
public function getCategoryList(){
|
|
|
|
$categoryModel = new Category();
|
|
|
|
$data = [];
|
|
|
|
$cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','title']);
|
|
|
|
if(!empty($cateList)){
|
|
|
|
foreach ($cateList as $value){
|
|
|
|
$data[$value['id']] = $value['title'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取所有关键词
|
|
|
|
* @name :getCategoryList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/14 13:56
|
|
|
|
*/
|
|
|
|
public function getKeywordsList(){
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$data = [];
|
|
|
|
$cateList = $keywordModel->list(['project_id'=>$this->user['project_id']],['id','title']);
|
|
|
|
if(!empty($cateList)){
|
|
|
|
foreach ($cateList as $value){
|
|
|
|
$data[$value['id']] = $value['title'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取分类名称
|
|
|
|
* @name :categoryName
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/14 13:58
|
|
|
|
*/
|
|
|
|
public function categoryName($category_id,$data){
|
|
|
|
$category_name = '';
|
|
|
|
if(!empty($category_id) && !empty($data)){
|
|
|
|
$arr = explode(',',trim($category_id,','));
|
|
|
|
foreach ($arr as $v){
|
|
|
|
if(isset($data[$v])){
|
|
|
|
$category_name .= $data[$v].',';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$category_name = trim($category_name,',');
|
|
|
|
}
|
|
|
|
return $category_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取关键词名称
|
|
|
|
* @name :categoryName
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/14 13:58
|
|
|
|
*/
|
|
|
|
public function keywordName($keyword,$data){
|
|
|
|
$keyword_name = '';
|
|
|
|
if(!empty($keyword) && !empty($data)){
|
|
|
|
$arr = explode(',',trim($keyword,','));
|
|
|
|
foreach ($arr as $v){
|
|
|
|
if(isset($data[$v])){
|
|
|
|
$keyword_name .= $data[$v].',';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$keyword_name = trim($keyword_name,',');
|
|
|
|
}
|
|
|
|
return $keyword_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理列表参数
|
|
|
|
* @name :handleParam
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -112,11 +210,10 @@ class ProductController extends BaseController |
|
|
|
$v['keyword_id_text'] = trim($v['keyword_id_text'],',');
|
|
|
|
}
|
|
|
|
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
|
|
|
|
$v['created_uid_text'] = (new User())->read(['id'=>$v['created_uid']])['name'] ?? '';
|
|
|
|
$v['url'] = $this->user['domain'].$v['route'];
|
|
|
|
$v['is_renovation'] = $this->getProductIsRenovation($v['id']);
|
|
|
|
return $v;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :详情
|
|
|
|
* @name :info
|
...
|
...
|
|