| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\workerapi\lists;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\goods_category\GoodsCategory;
- use app\common\model\spare_part\SparePart;
- /**
- * SparePart列表
- * Class SparePartLists
- * @package app\workerapi\lists
- */
- class SparePartLists extends BaseWorkerDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function setSearch(): array
- {
- $this->params['spare_status'] = 1;
- return [
- '=' => ['spare_status'],
- '%like%' => ['spare_name']
- ];
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function lists(): array
- {
- //去除清洗的所有分类
- $goods_category_id = !empty($this->params['goods_category_id'])?$this->params['goods_category_id']:999999;
- return SparePart::where($this->searchWhere)
- ->where('goods_category_id',$goods_category_id)
- ->field(['id', 'goods_category_id', 'spare_name', 'spare_image', 'spare_number', 'spare_unit', 'company_price', 'original_price', 'offering_price', 'spare_status'])
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- }
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function count(): int
- {
- return SparePart::where($this->searchWhere)->count();
- }
- }
|