修改商品列表查询

This commit is contained in:
liu 2024-06-25 14:36:58 +08:00
parent da38902072
commit bcef6451d6

View File

@ -30,20 +30,10 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
*/
public function setSearch(): array
{
$name = $this->request->get('store_name', '');
// $where['%pipe_like%'] =['name'=>'store_name|bar_code'];
if ($name) {
if (preg_match('/[\x{4e00}-\x{9fff}]+/u', $name) == 1) {
$where['%like%'] = ['store_name' => 'store_name'];
$where['='] = ['store_id', 'bar_code', 'cate_id'];
} else {
$where['='] = ['bar_code', 'cate_id'];
}
} else {
$where['='] = ['store_id', 'bar_code', 'cate_id'];
}
return $where;
return [
'=' => ['store_id', 'cate_id'],
'%pipe_like%' => ['store_name' => 'store_name|bar_code'],
];
}
/**
* @notes 设置支持排序字段
@ -111,21 +101,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
*/
public function count(): int
{
$class_all = $this->request->get('class_all');
if ($class_all) {
//查3级别的
$arr = Cate::where('pid', $class_all)->column('id');
if ($arr) {
$arr2 = Cate::where('pid', 'in', $arr)->column('id');
$this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)];
}else{
$this->searchWhere[] = ['cate_id','=',$class_all];
}
}
$this->searchWhere[] = ['status', '=', 1];
$this->searchWhere[] = ['stock', '>', 0];
return StoreBranchProduct::where($this->searchWhere)
->count();
}