feat: 实现商品列表查询功能

This commit is contained in:
mkm 2024-06-25 09:43:30 +08:00
parent 49ee6b0c1c
commit 630ef10fd6

View File

@ -4,6 +4,7 @@ namespace app\api\lists\product;
use app\admin\lists\BaseAdminDataLists; use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsExtendInterface;
use app\common\lists\ListsSortInterface; use app\common\lists\ListsSortInterface;
use app\common\model\dict\DictType; use app\common\model\dict\DictType;
use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_branch_product\StoreBranchProduct;
@ -19,7 +20,7 @@ use think\facade\Db;
* Class goods * Class goods
* @package app\api\goods * @package app\api\goods
*/ */
class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface,ListsExtendInterface
{ {
@ -103,12 +104,9 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
$this->searchWhere[] = ['cate_id', '=', $class_all]; $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[] = ['status', '=', 1];
$this->searchWhere[] = ['stock', '>', 0]; $this->searchWhere[] = ['stock', '>', 0];
return StoreBranchProduct::where($this->searchWhere) return StoreBranchProduct::where($this->searchWhere)
@ -118,7 +116,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
->order($this->sortOrder) ->order($this->sortOrder)
// ->page($this->limitOffset +1,$this->limitLength) // ->page($this->limitOffset +1,$this->limitLength)
->select()->toArray(); ->select()->toArray();
} }
@ -160,4 +157,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
return StoreBranchProduct::where($this->searchWhere) return StoreBranchProduct::where($this->searchWhere)
->count(); ->count();
} }
public function extend(){
$off_activity = Config::where('name', 'off_activity')->value('value');
return [
'off_activity'=>$off_activity,
'price'=>'cost',
'op_price'=>'price',
];
}
} }