作者 lyh

gx

... ... @@ -179,16 +179,15 @@ class BlogLogic extends BaseLogic
public function paramProcessing($param){
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}else{
$param['category_id'] = '';
}
return $this->success($param);
}
... ... @@ -201,11 +200,8 @@ class BlogLogic extends BaseLogic
* @time :2023/10/20 9:02
*/
public function getCategory($category){
$str = '';
foreach ($category as $v){
$str .= $v.',';
}
return !empty(trim($str,',')) ? ','.$str.',' : '';
$str = implode(',',$category);
return !empty(trim(trim($str,','),',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -191,16 +191,15 @@ class NewsLogic extends BaseLogic
}
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}
}
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getCategory($param['category_id']);
}else{
$param['category_id'] = '';
}
return $this->success($param);
}
... ... @@ -213,11 +212,8 @@ class NewsLogic extends BaseLogic
* @time :2023/10/20 9:02
*/
public function getCategory($category){
$str = '';
foreach ($category as $v){
$str .= $v.',';
}
return !empty(trim($str,',')) ? ','.$str.',' : '';
$str = implode(',',$category);
return !empty(trim(trim($str,','),',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -406,13 +406,26 @@ 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];
}
if($v == 3){
$data[$k] = $this->model->where(['project_id'=>$this->user['project_id']])->count();
$data[$k] = $this->model->formatQuery($map)->count();
}else{
$data[$k] = $this->model->where(['status'=>$v,'project_id'=>$this->user['project_id']])->count();
$map['status'] = $v;
$data[$k] = $this->model->formatQuery($map)->count();
}
}
return $this->success($data);
... ...