作者 lyh

gx

... ... @@ -406,26 +406,15 @@ class ProductLogic extends BaseLogic
* @time :2023/8/9 10:17
*/
public function getStatusNumber(){
$map = [];
//三种状态 0:草稿 1:发布 2:回收站
$data = ['dra'=>0,'pub'=>1,'del'=>2,'tal'=>3];
foreach ($data as $k => $v){
if(!isset($this->param['featured'])){
$cateModel = new Category();
$ids = $cateModel->where('title', 'not like', '%Featured%')->pluck('id')->toArray();
if(!empty($ids)){
$cateRelated = new CategoryRelated();
$product_ids = $cateRelated->whereIn('cate_id',$ids)->pluck('product_id')->toArray();
$map['id'] = ['in',$product_ids];
}
}else{
$map['id'] = ['in',$ids];
}
$cateModel = new Category();
$ids = $cateModel->where('title', 'not like', '%Featured%')->pluck('id')->toArray();
if($v == 3){
$data[$k] = $this->model->formatQuery($map)->count();
$data[$k] = $this->model->where(['project_id'=>$this->user['project_id']])->whereIn('id',$ids)->count();
}else{
$map['status'] = $v;
$data[$k] = $this->model->formatQuery($map)->count();
$data[$k] = $this->model->where(['status'=>$v,'project_id'=>$this->user['project_id'],''])->count();
}
}
return $this->success($data);
... ...