作者 lyh

gx分类页前后缀

... ... @@ -76,7 +76,7 @@ class ProductController extends BaseController
}
/**
* @remark :列表
* @remark :下载列表
* @name :index
* @author :lyh
* @method :post
... ... @@ -108,29 +108,6 @@ class ProductController extends BaseController
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取当前页的所有关键字名称
* @name :keywordNameLists
* @author :lyh
* @method :post
* @time :2024/6/3 14:24
*/
public function keywordNameLists($lists){
$keywordId = [];
foreach ($lists as $v){
$keywordId = array_merge($keywordId,$v['keyword_id']);
}
$keywordId = array_values(array_unique($keywordId));
$keywordModel = new Keyword();
$data = [];
$cateList = $keywordModel->list(['id' => ['in',$keywordId]], ['id', 'title']);
if (!empty($cateList)) {
foreach ($cateList as $value) {
$data[$value['id']] = $value['title'];
}
}
return $data;
}
/**
* @remark :不分页产品列表
... ... @@ -146,424 +123,119 @@ class ProductController extends BaseController
}
/**
* @remark :获取时处理图片和文件
* @name :getHandleFileImage
* @remark :详情
* @name :info
* @author :lyh
* @method :post
* @time :2024/1/23 17:43
* @time :2023/8/21 18:12
*/
public function getHandleFileImage($v){
//ToDo::处理图片及文件
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['gallery'])){
foreach ($v['gallery'] as $gallery_k => $gallery_v){
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['gallery'][$gallery_k] = $gallery_v;
}
}
if(!empty($v['icon'])){
foreach ($v['icon'] as $icon_k => $icon_v){
$icon_v = getImageUrl($icon_v,$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['icon'][$icon_k] = $icon_v;
}
}
if(!empty($v['video'])){
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn'] ?? 0);
$v['video']['video_image'] = getImageUrl($v['video']['video_image'] ?? '',$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getFileUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}
return $this->success($v);
public function info(Product $product){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$info = $product->read(['id'=>$this->param['id']]);
$info = $this->handleParam($info);
return $this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :搜索参数处理
* @name :handleReturnParam
* @remark :保存产品数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/14 10:01
* @time :2023/8/17 15:01
*/
public function searchParam(&$query){
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str[] = $this->map['category_id'];
$this->getAllSub($this->map['category_id'],$str);
$categoryRelatedModel = new CategoryRelated();
$product_id_arr = $categoryRelatedModel->whereIn('cate_id',$str)->pluck('product_id')->toArray();
$query = $query->whereIn('id',$product_id_arr);
}
if(isset($this->map['title']) && !empty($this->map['title'])){
$this->map['title'] = str_replace('+',' ',$this->map['title']);
$query = $query->where('title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['keyword_title']) && !empty($this->map['keyword_title'])){
$keywordModel = new Keyword();
$keywordInfo = $keywordModel->read(['title'=>$this->map['keyword_title']],['id']);
if(!empty($keywordInfo)){
$query = $query->where('keyword_id','like','%,'.$keywordInfo['id'].',%');
}
}
if(isset($this->map['status'])){
if($this->map['status'] == 0){
$query = $query->whereIn('status',[0,3]);
}else{
$query = $query->where('status',$this->map['status']);
}
}
if(isset($this->map['created_uid'])){
$query = $query->where('created_uid',$this->map['created_uid']);
}
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
if($this->user['project_id'] == 2059){
$query->where('send_time', '>=' ,$this->param['start_at'].' 00:00:00')->where('send_time', '<=' ,$this->param['end_at'].' 59:59:59');
}else{
$query->where('created_at', '>=' ,$this->param['start_at'].' 00:00:00')->where('created_at', '<=' ,$this->param['end_at'].' 59:59:59');
}
}
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if($this->param['featured_status'] != Category::STATUS_ACTIVE) {
$cateModel = new Category();
$featured_ids = $cateModel->formatQuery(['title'=>['in',['Featured','featured']]])->pluck('id')->toArray();
if(!empty($featured_ids)){
$status = [];
if(isset($this->map['status'])){
$status = ['status'=>$this->map['status']];
}
$cateList = $cateModel->list($status,'id',['id','pid']);
//获取当前的子集
$featured_arr = [];
foreach ($featured_ids as $id){
$featured_arr = array_merge($featured_arr,array_unique(_get_all_sub($id,$cateList)));
}
if(!empty($featured_arr)){
$cateRelated = new CategoryRelated();
$product_ids = $cateRelated->whereIn('cate_id',$featured_arr)->pluck('product_id')->unique()->toArray();
$query = $query->whereNotIn('id',$product_ids);
}
}
}
return $query;
public function save(ProductRequest $request, ProductLogic $logic)
{
$request->validated();
$data = $logic->productSave();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @remark :直接编辑列表数据
* @name :editList
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
* @time :2023/10/26 9:48
*/
public function getAllSub($id,&$str = []){
$cateModel = new Category();
$list = $cateModel->list(['pid'=>$id,'status'=>1],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
public function editList(ProductLogic $logic){
$logic->editList();
$this->response('success');
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @remark :删除
* @name :delete
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
* @time :2023/8/22 13:45
*/
public function getCategoryList(){
$data = Common::get_user_cache('product_category',$this->user['project_id']);
if(empty($data)){
$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'];
}
}
Common::set_user_cache($data,'product_category',$this->user['project_id']);
}
return $data;
public function delete(ProductLogic $logic)
{
$this->request->validate([
'ids'=>['required', new Ids()]
],[
'ids.required' => 'ID不能为空'
]);
$logic->productDelete();
$this->response('success');
}
/**
* @remark :获取分类名称
* @name :categoryName
* @remark :根据状态获取数量
* @name :getStatusNumber
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
* @time :2023/8/21 18:33
*/
public function categoryName($product_id,$data){
$cateRelatedModel = new CategoryRelated();
$category_id = $cateRelatedModel->where('product_id',$product_id)->pluck('cate_id')->toArray();
$category_name = '';
if(!empty($category_id) && !empty($data)){
foreach ($category_id as $v){
if(isset($data[$v])){
$category_name .= $data[$v].',';
}
}
$category_name = trim($category_name,',');
}
return $category_name;
public function getStatusNumber(ProductLogic $logic){
$this->request->validate([
'featured_status'=>'numeric',
],[
'featured_status.numeric' => 'numeric为数字',
]);
$data = $logic->getStatusNumber();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取关键词名称
* @name :categoryName
* @remark :复制产品
* @name :copyProduct
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
* @time :2023/7/29 14:59
*/
public function keywordName($keyword_id,$data){
$keyword_name = '';
if(!empty($keyword_id) && !empty($data)){
foreach ($keyword_id as $v){
if(isset($data[$v])){
$keyword_name .= $data[$v].',';
}
}
$keyword_name = trim($keyword_name,',');
}
return $keyword_name;
public function copyProduct(ProductLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$data = $logic->setCopyProduct();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :详情
* @name :info
* @remark :批量设置产品分类
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/21 18:12
* @time :2023/8/15 17:51
*/
public function info(Product $product){
public function batchSetCategory(ProductLogic $logic){
$this->request->validate([
'id'=>'required'
'id'=>'required',
'category_id'=>'required',
],[
'id.required' => 'ID不能为空'
'id.required' => '产品ID不能为空',
'category_id.required' => '分类ID不能为空',
]);
$info = $product->read(['id'=>$this->param['id']]);
$info = $this->handleParam($info);
return $this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :处理列表参数
* @name :handleParam
* @author :lyh
* @method :post
* @time :2023/8/17 9:15
*/
public function handleParam($v){
$v['keyword_id_text'] = '';
if(!empty($v['keyword_id'])){
$keywordModel = new Keyword();
$keyword_data = $keywordModel->list(['id'=>['in',$v['keyword_id']]]);
foreach ($keyword_data as $v1){
$v['keyword_id_text'] .= $v1['title'].',';
}
$v['keyword_id_text'] = trim($v['keyword_id_text'],',');
}
if(!empty($v['status'])){
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
}else{
$v['status_text'] = '';
}
//ToDo::处理图片及文件
$v = $this->getHandleFileImage($v);
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0);
$v['url'] = $this->user['domain'].($v['route'] ?? '');
//获取当前数据扩展字段及值
$v['extend'] = $this->getExtendInfo($v['id']);
return $v;
}
/**
* @remark :获取扩展字段详情
* @name :getExtendInfo
* @author :lyh
* @method :post
* @time :2023/11/14 9:45
*/
public function getExtendInfo($product_id){
$extendModel = new Extend();
$list = $extendModel->list([],'id',['id','type','key','title']);
if(empty($list)){
return [];
}
$extendInfoModel = new ExtendInfo();
$infoList = $extendInfoModel->list(['product_id'=>$product_id],'created_at');
foreach ($list as $k=>$v){
foreach ($infoList as $values){
if($v['key'] == $values['key']){
$v = $this->setTypValues($v,$values);
break;
}
}
$list[$k] = $v;
}
$list = $this->handleExtentList($list);
return $list;
}
/**
* @remark :处理详情数据(初始化)
* @name :handleList
* @author :lyh
* @method :post
* @time :2024/8/14 18:26
*/
public function handleExtentList($list){
foreach ($list as $k => $v){
if($v['type'] == 3 || $v['type'] == 4){
if(!isset($v['values'])){
$v['values'] = [];
}
}else{
if(!isset($v['values'])){
$v['values'] = '';
}
}
$list[$k] = $v;
}
return $this->success($list);
}
/**
* @remark :扩展字段根据type返回类型
* @name :setTypValues
* @author :lyh
* @method :post
* @time :2023/12/6 14:43
*/
public function setTypValues($v,$info){
if($v['type'] == 3){
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = (array)$v1;
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
}elseif($v['type'] == 4){
$arr1 = json_decode($info['values']);
foreach ($arr1 as $k1=>$v1){
$v1 = (array)$v1;
if(isset($v1['url'])){
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}else{
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}
$arr1[$k1] = $v1;
}
$v['values'] = $arr1;
}else{
$v['values'] = $info['values'];
}
return $v;
}
/**
* @remark :保存产品数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/8/17 15:01
*/
public function save(ProductRequest $request, ProductLogic $logic)
{
$request->validated();
$data = $logic->productSave();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :直接编辑列表数据
* @name :editList
* @author :lyh
* @method :post
* @time :2023/10/26 9:48
*/
public function editList(ProductLogic $logic){
$logic->editList();
$this->response('success');
}
/**
* @remark :删除
* @name :delete
* @author :lyh
* @method :post
* @time :2023/8/22 13:45
*/
public function delete(ProductLogic $logic)
{
$this->request->validate([
'ids'=>['required', new Ids()]
],[
'ids.required' => 'ID不能为空'
]);
$logic->productDelete();
$this->response('success');
}
/**
* @remark :根据状态获取数量
* @name :getStatusNumber
* @author :lyh
* @method :post
* @time :2023/8/21 18:33
*/
public function getStatusNumber(ProductLogic $logic){
$this->request->validate([
'featured_status'=>'numeric',
],[
'featured_status.numeric' => 'numeric为数字',
]);
$data = $logic->getStatusNumber();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :复制产品
* @name :copyProduct
* @author :lyh
* @method :post
* @time :2023/7/29 14:59
*/
public function copyProduct(ProductLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$data = $logic->setCopyProduct();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :批量设置产品分类
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:51
*/
public function batchSetCategory(ProductLogic $logic){
$this->request->validate([
'id'=>'required',
'category_id'=>'required',
],[
'id.required' => '产品ID不能为空',
'category_id.required' => '分类ID不能为空',
]);
$logic->batchSetCategory();
$this->response('success');
$logic->batchSetCategory();
$this->response('success');
}
/**
... ... @@ -812,4 +484,335 @@ class ProductController extends BaseController
$logic->batchSetKeyword();
$this->response('success');
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getCategoryList(){
$data = Common::get_user_cache('product_category',$this->user['project_id']);
if(empty($data)){
$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'];
}
}
Common::set_user_cache($data,'product_category',$this->user['project_id']);
}
return $data;
}
/**
* @remark :获取当前页的所有关键字名称
* @name :keywordNameLists
* @author :lyh
* @method :post
* @time :2024/6/3 14:24
*/
public function keywordNameLists($lists){
$keywordId = [];
foreach ($lists as $v){
$keywordId = array_merge($keywordId,$v['keyword_id']);
}
$keywordId = array_values(array_unique($keywordId));
$keywordModel = new Keyword();
$data = [];
$cateList = $keywordModel->list(['id' => ['in',$keywordId]], ['id', 'title']);
if (!empty($cateList)) {
foreach ($cateList as $value) {
$data[$value['id']] = $value['title'];
}
}
return $data;
}
/**
* @remark :获取时处理图片和文件
* @name :getHandleFileImage
* @author :lyh
* @method :post
* @time :2024/1/23 17:43
*/
public function getHandleFileImage($v){
//ToDo::处理图片及文件
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['gallery'])){
foreach ($v['gallery'] as $gallery_k => $gallery_v){
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['gallery'][$gallery_k] = $gallery_v;
}
}
if(!empty($v['icon'])){
foreach ($v['icon'] as $icon_k => $icon_v){
$icon_v = getImageUrl($icon_v,$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['icon'][$icon_k] = $icon_v;
}
}
if(!empty($v['video'])){
$v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn'] ?? 0);
$v['video']['video_image'] = getImageUrl($v['video']['video_image'] ?? '',$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getFileUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}
return $this->success($v);
}
/**
* @remark :处理详情数据(初始化)
* @name :handleList
* @author :lyh
* @method :post
* @time :2024/8/14 18:26
*/
public function handleExtentList($list){
foreach ($list as $k => $v){
if($v['type'] == 3 || $v['type'] == 4){
if(!isset($v['values'])){
$v['values'] = [];
}
}else{
if(!isset($v['values'])){
$v['values'] = '';
}
}
$list[$k] = $v;
}
return $this->success($list);
}
/**
* @remark :扩展字段根据type返回类型
* @name :setTypValues
* @author :lyh
* @method :post
* @time :2023/12/6 14:43
*/
public function setTypValues($v,$info){
if($v['type'] == 3){
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = (array)$v1;
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
}elseif($v['type'] == 4){
$arr1 = json_decode($info['values']);
foreach ($arr1 as $k1=>$v1){
$v1 = (array)$v1;
if(isset($v1['url'])){
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}else{
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
}
$arr1[$k1] = $v1;
}
$v['values'] = $arr1;
}else{
$v['values'] = $info['values'];
}
return $this->success($v);
}
/**
* @remark :搜索参数处理
* @name :handleReturnParam
* @author :lyh
* @method :post
* @time :2023/9/14 10:01
*/
public function searchParam(&$query){
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str[] = $this->map['category_id'];
$this->getAllSub($this->map['category_id'],$str);
$categoryRelatedModel = new CategoryRelated();
$product_id_arr = $categoryRelatedModel->whereIn('cate_id',$str)->pluck('product_id')->toArray();
$query = $query->whereIn('id',$product_id_arr);
}
if(isset($this->map['title']) && !empty($this->map['title'])){
$this->map['title'] = str_replace('+',' ',$this->map['title']);
$query = $query->where('title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['keyword_title']) && !empty($this->map['keyword_title'])){
$keywordModel = new Keyword();
$keywordInfo = $keywordModel->read(['title'=>$this->map['keyword_title']],['id']);
if(!empty($keywordInfo)){
$query = $query->where('keyword_id','like','%,'.$keywordInfo['id'].',%');
}
}
if(isset($this->map['status'])){
if($this->map['status'] == 0){
$query = $query->whereIn('status',[0,3]);
}else{
$query = $query->where('status',$this->map['status']);
}
}
if(isset($this->map['created_uid'])){
$query = $query->where('created_uid',$this->map['created_uid']);
}
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
if($this->user['project_id'] == 2059){
$query->where('send_time', '>=' ,$this->param['start_at'].' 00:00:00')->where('send_time', '<=' ,$this->param['end_at'].' 59:59:59');
}else{
$query->where('created_at', '>=' ,$this->param['start_at'].' 00:00:00')->where('created_at', '<=' ,$this->param['end_at'].' 59:59:59');
}
}
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if($this->param['featured_status'] != Category::STATUS_ACTIVE) {
$cateModel = new Category();
$featured_ids = $cateModel->formatQuery(['title'=>['in',['Featured','featured']]])->pluck('id')->toArray();
if(!empty($featured_ids)){
$status = [];
if(isset($this->map['status'])){
$status = ['status'=>$this->map['status']];
}
$cateList = $cateModel->list($status,'id',['id','pid']);
//获取当前的子集
$featured_arr = [];
foreach ($featured_ids as $id){
$featured_arr = array_merge($featured_arr,array_unique(_get_all_sub($id,$cateList)));
}
if(!empty($featured_arr)){
$cateRelated = new CategoryRelated();
$product_ids = $cateRelated->whereIn('cate_id',$featured_arr)->pluck('product_id')->unique()->toArray();
$query = $query->whereNotIn('id',$product_ids);
}
}
}
return $query;
}
/**
* @remark :处理列表参数
* @name :handleParam
* @author :lyh
* @method :post
* @time :2023/8/17 9:15
*/
public function handleParam($v){
$v['keyword_id_text'] = '';
if(!empty($v['keyword_id'])){
$keywordModel = new Keyword();
$keyword_data = $keywordModel->list(['id'=>['in',$v['keyword_id']]]);
foreach ($keyword_data as $v1){
$v['keyword_id_text'] .= $v1['title'].',';
}
$v['keyword_id_text'] = trim($v['keyword_id_text'],',');
}
if(!empty($v['status'])){
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
}else{
$v['status_text'] = '';
}
//ToDo::处理图片及文件
$v = $this->getHandleFileImage($v);
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0);
$v['url'] = $this->user['domain'].($v['route'] ?? '');
//获取当前数据扩展字段及值
$v['extend'] = $this->getExtendInfo($v['id']);
return $v;
}
/**
* @remark :获取扩展字段详情
* @name :getExtendInfo
* @author :lyh
* @method :post
* @time :2023/11/14 9:45
*/
public function getExtendInfo($product_id){
$extendModel = new Extend();
$list = $extendModel->list([],'id',['id','type','key','title']);
if(empty($list)){
return [];
}
$extendInfoModel = new ExtendInfo();
$infoList = $extendInfoModel->list(['product_id'=>$product_id],'created_at');
foreach ($list as $k=>$v){
foreach ($infoList as $values){
if($v['key'] == $values['key']){
$v = $this->setTypValues($v,$values);
break;
}
}
$list[$k] = $v;
}
$list = $this->handleExtentList($list);
return $list;
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$cateModel = new Category();
$list = $cateModel->list(['pid'=>$id,'status'=>1],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
* @remark :获取分类名称
* @name :categoryName
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
*/
public function categoryName($product_id,$data){
$cateRelatedModel = new CategoryRelated();
$category_id = $cateRelatedModel->where('product_id',$product_id)->pluck('cate_id')->toArray();
$category_name = '';
if(!empty($category_id) && !empty($data)){
foreach ($category_id 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_id,$data){
$keyword_name = '';
if(!empty($keyword_id) && !empty($data)){
foreach ($keyword_id as $v){
if(isset($data[$v])){
$keyword_name .= $data[$v].',';
}
}
$keyword_name = trim($keyword_name,',');
}
return $keyword_name;
}
}
... ...
... ... @@ -1154,4 +1154,5 @@ class ProductLogic extends BaseLogic
}
return $this->success();
}
}
... ...