feat: 实现商品列表查询功能
This commit is contained in:
parent
49ee6b0c1c
commit
630ef10fd6
@ -4,6 +4,7 @@ namespace app\api\lists\product;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
@ -19,7 +20,7 @@ use think\facade\Db;
|
||||
* Class goods
|
||||
* @package app\api\goods
|
||||
*/
|
||||
class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
|
||||
class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface,ListsExtendInterface
|
||||
{
|
||||
|
||||
|
||||
@ -64,7 +65,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return [ 'price' => 'asc','id' => 'desc'];
|
||||
return ['price' => 'asc', 'id' => 'desc'];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,16 +100,13 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
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];
|
||||
} else {
|
||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||
}
|
||||
}
|
||||
$off_activity=Config::where('name','off_activity')->value('value');
|
||||
if($off_activity==1){
|
||||
$field='id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch';
|
||||
}else{
|
||||
$field='id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch';
|
||||
}
|
||||
|
||||
$field = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch';
|
||||
|
||||
$this->searchWhere[] = ['status', '=', 1];
|
||||
$this->searchWhere[] = ['stock', '>', 0];
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
@ -116,9 +114,8 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
->with(['className', 'unitName'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
// ->page($this->limitOffset +1,$this->limitLength)
|
||||
// ->page($this->limitOffset +1,$this->limitLength)
|
||||
->select()->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -150,8 +147,8 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
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];
|
||||
} else {
|
||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,4 +157,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->count();
|
||||
}
|
||||
public function extend(){
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
return [
|
||||
'off_activity'=>$off_activity,
|
||||
'price'=>'cost',
|
||||
'op_price'=>'price',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user