作者 lyh

更新产品

... ... @@ -169,7 +169,26 @@ class ProductController extends BaseController
}
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if($this->param['featured_status'] != Category::STATUS_ACTIVE) {
$query = $query->where('title','not like','Featured%');
$cateModel = new Category();
$featured_ids = $cateModel->where('title', 'like', '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;
}
... ...
... ... @@ -395,7 +395,7 @@ class ProductLogic extends BaseLogic
foreach ($data as $k => $v){
$map = [];
$cateModel = new Category();
$cateList = $cateModel->list(['status'=>1],'id',['id','pid']);
$cateList = $cateModel->list(['status'=>$v],'id',['id','pid']);
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
if(!empty($cateList) && ($this->param['featured_status'] != $cateModel::STATUS_ACTIVE)){
$featured_ids = $cateModel->where('title', 'like', 'Featured%')->pluck('id')->toArray();
... ...