Merge pull request 'fix_address' (#12) from fix_address into main

Reviewed-on: #12
This commit is contained in:
mkm 2024-06-25 14:38:32 +08:00
commit 61175aa684

View File

@ -30,19 +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'];
} 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 设置支持排序字段
@ -77,20 +68,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
*/
public function lists(): array
{
$found = false;
if ($this->searchWhere) {
foreach ($this->searchWhere as $subArray) {
if (in_array('store_id', $subArray)) {
$found = true;
break; // 找到后退出循环
}
}
}
if (!$found) {
$store_id = DictType::where('type', 'store')->value('remark') ?? 5;
$this->searchWhere[] = ['store_id', '=', $store_id];
}
$class_all = $this->request->get('class_all');
if ($class_all) {
//查3级别的
@ -124,33 +101,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
*/
public function count(): int
{
$found = false;
if ($this->searchWhere) {
foreach ($this->searchWhere as $subArray) {
if (in_array('store_id', $subArray)) {
$found = true;
break; // 找到后退出循环
}
}
}
if (!$found) {
$store_id = DictType::where('type', 'store')->value('remark') ?? 5;
$this->searchWhere[] = ['store_id', '=', $store_id];
}
$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();
}