搜索相关兼容
This commit is contained in:
parent
e9843de7b3
commit
f0a6491adb
@ -4,6 +4,7 @@ namespace app\admin\lists\store_branch_product;
|
|||||||
|
|
||||||
|
|
||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\cate\Cate;
|
||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
@ -47,7 +48,16 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$status = $this->params['status'] ?? '';
|
$status = $this->params['status'] ?? '';
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
$class_all=$this->request->get('class_all');
|
||||||
|
$where=[];
|
||||||
|
if($class_all){
|
||||||
|
$arr=Cate::where('pid',$class_all)->column('id');
|
||||||
|
if($arr){
|
||||||
|
$arr2=Cate::where('pid','in',$arr)->column('id');
|
||||||
|
$where[]=['cate_id','in',array_merge($arr,$arr2)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||||
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status'])
|
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status'])
|
||||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->adminInfo['store_id']);
|
$query->where('store_id', $this->adminInfo['store_id']);
|
||||||
@ -85,7 +95,16 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
$status = $this->params['status'] ?? '';
|
$status = $this->params['status'] ?? '';
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
$class_all=$this->request->get('class_all');
|
||||||
|
$where=[];
|
||||||
|
if($class_all){
|
||||||
|
$arr=Cate::where('pid',$class_all)->column('id');
|
||||||
|
if($arr){
|
||||||
|
$arr2=Cate::where('pid','in',$arr)->column('id');
|
||||||
|
$where[]=['cate_id','in',array_merge($arr,$arr2)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->adminInfo['store_id']);
|
$query->where('store_id', $this->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user