新增后台商品列表一级分类查询商品逻辑
This commit is contained in:
parent
379c8aea4c
commit
f9b10e51ce
@ -4,6 +4,7 @@ namespace app\admin\lists\store_product;
|
|||||||
|
|
||||||
|
|
||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\cate\Cate;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
@ -45,6 +46,17 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
|
$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];
|
||||||
|
}
|
||||||
|
}
|
||||||
return StoreProduct::where($this->searchWhere)
|
return StoreProduct::where($this->searchWhere)
|
||||||
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
|
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user