作者 lyh

gx视频任务

@@ -422,6 +422,11 @@ class ProductController extends BaseController @@ -422,6 +422,11 @@ class ProductController extends BaseController
422 * @time :2023/8/21 18:33 422 * @time :2023/8/21 18:33
423 */ 423 */
424 public function getStatusNumber(ProductLogic $logic){ 424 public function getStatusNumber(ProductLogic $logic){
  425 + $this->request->validate([
  426 + 'featured_status'=>'numeric',
  427 + ],[
  428 + 'featured_status.numeric' => 'numeric为数字',
  429 + ]);
425 $data = $logic->getStatusNumber(); 430 $data = $logic->getStatusNumber();
426 $this->response('success',Code::SUCCESS,$data); 431 $this->response('success',Code::SUCCESS,$data);
427 } 432 }
@@ -536,10 +541,9 @@ class ProductController extends BaseController @@ -536,10 +541,9 @@ class ProductController extends BaseController
536 $setNumModel = new SettingNum(); 541 $setNumModel = new SettingNum();
537 $info = $setNumModel->read(['type'=>$setNumModel::TYPE_PRODUCT_SORT]); 542 $info = $setNumModel->read(['type'=>$setNumModel::TYPE_PRODUCT_SORT]);
538 if($info === false){ 543 if($info === false){
539 - $info = [];  
540 - }else{  
541 - $info['data'] = json_decode($info['data']); 544 + $this->response('success');
542 } 545 }
  546 + $info['data'] = json_decode($info['data']);
543 $this->response('success',Code::SUCCESS,$info); 547 $this->response('success',Code::SUCCESS,$info);
544 } 548 }
545 549
@@ -397,7 +397,8 @@ class ProductLogic extends BaseLogic @@ -397,7 +397,8 @@ class ProductLogic extends BaseLogic
397 //查詢所有分類 397 //查詢所有分類
398 $cateModel = new Category(); 398 $cateModel = new Category();
399 $cateList = $cateModel->list(['status'=>1],'id',['id','pid']); 399 $cateList = $cateModel->list(['status'=>1],'id',['id','pid']);
400 - if(!empty($cateList) && !isset($this->param['featured_status'])){ 400 + $this->param['featured_status'] = $this->param['featured_status'] ?? 0;
  401 + if(!empty($cateList) && ($this->param['featured_status'] != $cateModel::STATUS_ACTIVE)){
401 $featured_ids = $cateModel->where('title', 'like', '%Featured%')->pluck('id')->toArray(); 402 $featured_ids = $cateModel->where('title', 'like', '%Featured%')->pluck('id')->toArray();
402 //获取当前的子集 403 //获取当前的子集
403 $featured_arr = []; 404 $featured_arr = [];
@@ -862,7 +863,8 @@ class ProductLogic extends BaseLogic @@ -862,7 +863,8 @@ class ProductLogic extends BaseLogic
862 { 863 {
863 $categoryModel = new Category(); 864 $categoryModel = new Category();
864 $this->param['deleted_at'] = null; 865 $this->param['deleted_at'] = null;
865 - if(!isset($this->param['featured_status'])) { 866 + $this->param['featured_status'] = $this->param['featured_status'] ?? 0;
  867 + if(($this->param['featured_status'] != Category::STATUS_ACTIVE)) {
866 $this->param['title'] = ['not like','%Featured%']; 868 $this->param['title'] = ['not like','%Featured%'];
867 } 869 }
868 $list = $categoryModel->list($this->param, ['sort', 'id'], ['id', 'pid', 'title']); 870 $list = $categoryModel->list($this->param, ['sort', 'id'], ['id', 'pid', 'title']);