正在显示
3 个修改的文件
包含
29 行增加
和
24 行删除
| @@ -179,16 +179,15 @@ class BlogLogic extends BaseLogic | @@ -179,16 +179,15 @@ class BlogLogic extends BaseLogic | ||
| 179 | public function paramProcessing($param){ | 179 | public function paramProcessing($param){ |
| 180 | if(isset($this->param['id'])){ | 180 | if(isset($this->param['id'])){ |
| 181 | $param['operator_id'] = $this->user['id']; | 181 | $param['operator_id'] = $this->user['id']; |
| 182 | - if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 183 | - $param['category_id'] = $this->getCategory($param['category_id']); | ||
| 184 | - } | ||
| 185 | }else{ | 182 | }else{ |
| 186 | $param['create_id'] = $this->user['id']; | 183 | $param['create_id'] = $this->user['id']; |
| 187 | $param['operator_id'] = $this->user['id']; | 184 | $param['operator_id'] = $this->user['id']; |
| 188 | $param['project_id'] = $this->user['project_id']; | 185 | $param['project_id'] = $this->user['project_id']; |
| 189 | - if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 190 | - $param['category_id'] = $this->getCategory($param['category_id']); | ||
| 191 | - } | 186 | + } |
| 187 | + if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 188 | + $param['category_id'] = $this->getCategory($param['category_id']); | ||
| 189 | + }else{ | ||
| 190 | + $param['category_id'] = ''; | ||
| 192 | } | 191 | } |
| 193 | return $this->success($param); | 192 | return $this->success($param); |
| 194 | } | 193 | } |
| @@ -201,11 +200,8 @@ class BlogLogic extends BaseLogic | @@ -201,11 +200,8 @@ class BlogLogic extends BaseLogic | ||
| 201 | * @time :2023/10/20 9:02 | 200 | * @time :2023/10/20 9:02 |
| 202 | */ | 201 | */ |
| 203 | public function getCategory($category){ | 202 | public function getCategory($category){ |
| 204 | - $str = ''; | ||
| 205 | - foreach ($category as $v){ | ||
| 206 | - $str .= $v.','; | ||
| 207 | - } | ||
| 208 | - return !empty(trim($str,',')) ? ','.$str.',' : ''; | 203 | + $str = implode(',',$category); |
| 204 | + return !empty(trim(trim($str,','),',')) ? ','.$str.',' : ''; | ||
| 209 | } | 205 | } |
| 210 | 206 | ||
| 211 | /** | 207 | /** |
| @@ -191,16 +191,15 @@ class NewsLogic extends BaseLogic | @@ -191,16 +191,15 @@ class NewsLogic extends BaseLogic | ||
| 191 | } | 191 | } |
| 192 | if(isset($this->param['id'])){ | 192 | if(isset($this->param['id'])){ |
| 193 | $param['operator_id'] = $this->user['id']; | 193 | $param['operator_id'] = $this->user['id']; |
| 194 | - if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 195 | - $param['category_id'] = $this->getCategory($param['category_id']); | ||
| 196 | - } | ||
| 197 | }else{ | 194 | }else{ |
| 198 | $param['create_id'] = $this->user['id']; | 195 | $param['create_id'] = $this->user['id']; |
| 199 | $param['operator_id'] = $this->user['id']; | 196 | $param['operator_id'] = $this->user['id']; |
| 200 | $param['project_id'] = $this->user['project_id']; | 197 | $param['project_id'] = $this->user['project_id']; |
| 201 | - if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 202 | - $param['category_id'] = $this->getCategory($param['category_id']); | ||
| 203 | - } | 198 | + } |
| 199 | + if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 200 | + $param['category_id'] = $this->getCategory($param['category_id']); | ||
| 201 | + }else{ | ||
| 202 | + $param['category_id'] = ''; | ||
| 204 | } | 203 | } |
| 205 | return $this->success($param); | 204 | return $this->success($param); |
| 206 | } | 205 | } |
| @@ -213,11 +212,8 @@ class NewsLogic extends BaseLogic | @@ -213,11 +212,8 @@ class NewsLogic extends BaseLogic | ||
| 213 | * @time :2023/10/20 9:02 | 212 | * @time :2023/10/20 9:02 |
| 214 | */ | 213 | */ |
| 215 | public function getCategory($category){ | 214 | public function getCategory($category){ |
| 216 | - $str = ''; | ||
| 217 | - foreach ($category as $v){ | ||
| 218 | - $str .= $v.','; | ||
| 219 | - } | ||
| 220 | - return !empty(trim($str,',')) ? ','.$str.',' : ''; | 215 | + $str = implode(',',$category); |
| 216 | + return !empty(trim(trim($str,','),',')) ? ','.$str.',' : ''; | ||
| 221 | } | 217 | } |
| 222 | 218 | ||
| 223 | /** | 219 | /** |
| @@ -406,13 +406,26 @@ class ProductLogic extends BaseLogic | @@ -406,13 +406,26 @@ class ProductLogic extends BaseLogic | ||
| 406 | * @time :2023/8/9 10:17 | 406 | * @time :2023/8/9 10:17 |
| 407 | */ | 407 | */ |
| 408 | public function getStatusNumber(){ | 408 | public function getStatusNumber(){ |
| 409 | + $map = []; | ||
| 409 | //三种状态 0:草稿 1:发布 2:回收站 | 410 | //三种状态 0:草稿 1:发布 2:回收站 |
| 410 | $data = ['dra'=>0,'pub'=>1,'del'=>2,'tal'=>3]; | 411 | $data = ['dra'=>0,'pub'=>1,'del'=>2,'tal'=>3]; |
| 411 | foreach ($data as $k => $v){ | 412 | foreach ($data as $k => $v){ |
| 413 | + if(!isset($this->param['featured'])){ | ||
| 414 | + $cateModel = new Category(); | ||
| 415 | + $ids = $cateModel->where('title', 'not like', '%Featured%')->pluck('id')->toArray(); | ||
| 416 | + if(!empty($ids)){ | ||
| 417 | + $cateRelated = new CategoryRelated(); | ||
| 418 | + $product_ids = $cateRelated->whereIn('cate_id',$ids)->pluck('product_id')->toArray(); | ||
| 419 | + $map['id'] = ['in',$product_ids]; | ||
| 420 | + } | ||
| 421 | + }else{ | ||
| 422 | + $map['id'] = ['in',$ids]; | ||
| 423 | + } | ||
| 412 | if($v == 3){ | 424 | if($v == 3){ |
| 413 | - $data[$k] = $this->model->where(['project_id'=>$this->user['project_id']])->count(); | 425 | + $data[$k] = $this->model->formatQuery($map)->count(); |
| 414 | }else{ | 426 | }else{ |
| 415 | - $data[$k] = $this->model->where(['status'=>$v,'project_id'=>$this->user['project_id']])->count(); | 427 | + $map['status'] = $v; |
| 428 | + $data[$k] = $this->model->formatQuery($map)->count(); | ||
| 416 | } | 429 | } |
| 417 | } | 430 | } |
| 418 | return $this->success($data); | 431 | return $this->success($data); |
-
请 注册 或 登录 后发表评论