正在显示
1 个修改的文件
包含
29 行增加
和
1 行删除
| @@ -43,7 +43,10 @@ class ProductController extends BaseController | @@ -43,7 +43,10 @@ class ProductController extends BaseController | ||
| 43 | $this->map = $this->searchParam(); | 43 | $this->map = $this->searchParam(); |
| 44 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' , | 44 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' , |
| 45 | 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']; | 45 | 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']; |
| 46 | - $lists = $product->product_lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed); | 46 | + $this->order = 'sort'; |
| 47 | + $query = $product->orderBy($this->order ,'desc'); | ||
| 48 | + $query = $this->searchParam($query); | ||
| 49 | + $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); | ||
| 47 | if(!empty($lists) && !empty($lists['list'])){ | 50 | if(!empty($lists) && !empty($lists['list'])){ |
| 48 | $cate_data = $this->getCategoryList();//分类 | 51 | $cate_data = $this->getCategoryList();//分类 |
| 49 | $key_data = $this->getKeywordsList();//关键字 | 52 | $key_data = $this->getKeywordsList();//关键字 |
| @@ -62,6 +65,31 @@ class ProductController extends BaseController | @@ -62,6 +65,31 @@ class ProductController extends BaseController | ||
| 62 | } | 65 | } |
| 63 | return $this->response('success',Code::SUCCESS,$lists); | 66 | return $this->response('success',Code::SUCCESS,$lists); |
| 64 | } | 67 | } |
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * @remark :处理列表返回参数 | ||
| 71 | + * @name :handleReturnParam | ||
| 72 | + * @author :lyh | ||
| 73 | + * @method :post | ||
| 74 | + * @time :2023/9/14 10:01 | ||
| 75 | + */ | ||
| 76 | + public function searchParams(&$query){ | ||
| 77 | + $query = $query->where('project_id',$this->user['project_id']); | ||
| 78 | + if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | ||
| 79 | + $str = []; | ||
| 80 | + $this->getLastLevelIds($this->map['category_id'],$str); | ||
| 81 | + $query->where(function ($subQuery) use ($str) { | ||
| 82 | + foreach ($str as $v) { | ||
| 83 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 84 | + } | ||
| 85 | + }); | ||
| 86 | + } | ||
| 87 | + if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){ | ||
| 88 | + $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); | ||
| 89 | + } | ||
| 90 | + return $query; | ||
| 91 | + } | ||
| 92 | + | ||
| 65 | /** | 93 | /** |
| 66 | * @remark :搜索参数处理 | 94 | * @remark :搜索参数处理 |
| 67 | * @name :searchParam | 95 | * @name :searchParam |
-
请 注册 或 登录 后发表评论