diff --git a/app/api/controller/FishBreedController.php b/app/api/controller/FishBreedController.php index 85906924..ff8b18c6 100644 --- a/app/api/controller/FishBreedController.php +++ b/app/api/controller/FishBreedController.php @@ -191,14 +191,17 @@ public function fishRecordList(): Json { //获取参数 - $params = $this->request->get(['pond_id','page_no','page_size']); - if(empty($params['pond_id'])){ + $params = $this->request->get(['pond_id','action_type_id','page_no','page_size']); + if(empty($params['pond_id']) || empty($params['action_type_id'])){ return $this->fail('参数错误'); } //设置分页条件 $pageNo = empty($params['page_no']) || $params['page_no'] < 0 ? 1 : $params['page_no']; $pageSize = empty($params['page_size']) || $params['page_size'] < 0 ? 10 : $params['page_size']; - $data = Db::name('farmer_pond_record')->where('pond_id',$params['pond_id'])->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ + //获取操作分类下的操作id + $actions = Db::name('farmer_action')->where('type_id',$params['action_type_id'])->select()->toArray(); + $actionIds = array_column($actions,'id'); + $data = Db::name('farmer_pond_record')->where('pond_id',$params['pond_id'])->where('action_id','in',$actionIds)->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ $item['action_name'] = Db::name('farmer_action')->where('id',$item['action_id'])->findOrEmpty()['name']; $item['action_content'] = json_decode($item['action_content'],true); $item['create_time'] = date('Y-m-d H:i:s',$item['create_time']); diff --git a/app/api/controller/LandPlantController.php b/app/api/controller/LandPlantController.php index 285f0566..05c98d08 100644 --- a/app/api/controller/LandPlantController.php +++ b/app/api/controller/LandPlantController.php @@ -192,14 +192,17 @@ public function landCropRecordList(): Json { //获取参数 - $params = $this->request->get(['crop_id','page_no','page_size']); - if(empty($params['crop_id'])){ + $params = $this->request->get(['crop_id','action_type_id','page_no','page_size']); + if(empty($params['crop_id']) || empty($params['action_type_id'])){ return $this->fail('参数错误'); } //设置分页条件 $pageNo = empty($params['page_no']) || $params['page_no'] < 0 ? 1 : $params['page_no']; $pageSize = empty($params['page_size']) || $params['page_size'] < 0 ? 10 : $params['page_size']; - $data = Db::name('farmer_land_crop_record')->where('crop_id',$params['crop_id'])->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ + //获取操作分类下的操作id + $actions = Db::name('farmer_action')->where('type_id',$params['action_type_id'])->select()->toArray(); + $actionIds = array_column($actions,'id'); + $data = Db::name('farmer_land_crop_record')->where('crop_id',$params['crop_id'])->where('action_id','in',$actionIds)->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ $item['action_name'] = Db::name('farmer_action')->where('id',$item['action_id'])->findOrEmpty()['name']; $item['action_content'] = json_decode($item['action_content'],true); $item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);