|
...
|
...
|
@@ -43,7 +43,10 @@ class ProductController extends BaseController |
|
|
|
$this->map = $this->searchParam();
|
|
|
|
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
|
|
|
|
'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
|
|
|
|
$lists = $product->product_lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed);
|
|
|
|
$this->order = 'sort';
|
|
|
|
$query = $product->orderBy($this->order ,'desc');
|
|
|
|
$query = $this->searchParam($query);
|
|
|
|
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
|
|
|
|
if(!empty($lists) && !empty($lists['list'])){
|
|
|
|
$cate_data = $this->getCategoryList();//分类
|
|
|
|
$key_data = $this->getKeywordsList();//关键字
|
|
...
|
...
|
@@ -62,6 +65,31 @@ class ProductController extends BaseController |
|
|
|
}
|
|
|
|
return $this->response('success',Code::SUCCESS,$lists);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理列表返回参数
|
|
|
|
* @name :handleReturnParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/14 10:01
|
|
|
|
*/
|
|
|
|
public function searchParams(&$query){
|
|
|
|
$query = $query->where('project_id',$this->user['project_id']);
|
|
|
|
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
|
|
|
|
$str = [];
|
|
|
|
$this->getLastLevelIds($this->map['category_id'],$str);
|
|
|
|
$query->where(function ($subQuery) use ($str) {
|
|
|
|
foreach ($str as $v) {
|
|
|
|
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
|
|
|
|
$query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
|
|
|
|
}
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :搜索参数处理
|
|
|
|
* @name :searchParam
|
...
|
...
|
|