From b5b1be9578a7f2dd9d3c6aae484cf7b7f0b9cdf2 Mon Sep 17 00:00:00 2001 From: weiz Date: Thu, 26 Oct 2023 16:10:26 +0800 Subject: [PATCH] update --- app/api/controller/FishBreedController.php | 4 +-- app/api/controller/UserController.php | 35 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app/api/controller/FishBreedController.php b/app/api/controller/FishBreedController.php index f42937c4..7b196df5 100644 --- a/app/api/controller/FishBreedController.php +++ b/app/api/controller/FishBreedController.php @@ -171,7 +171,7 @@ return $resust ? $this->success('删除成功') : $this->fail('删除失败'); } - //删除水产养殖操作记录 + //编辑水产养殖操作记录 public function ediFishRecord(): Json { $params = $this->request->post(['record_id','action_content']); @@ -207,7 +207,7 @@ return $this->success('请求成功',$data); } - //获取农户土地监测数据实时数据 + //农户池塘环境监测数据实时数据 public function pondEnvData(): Json { $params = $this->request->get(['user_id']); diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php index a3d372a0..4a70457f 100644 --- a/app/api/controller/UserController.php +++ b/app/api/controller/UserController.php @@ -86,6 +86,41 @@ class UserController extends BaseApiController 'breed' => $poultryBreed ]; } + //判断是否是水产养殖户 + if($curl_result['data']['is_sc_user']){ + $ponds = $curl_result['data']['pond_detail']; + foreach($ponds as $k=>$v) { + //获取养殖信息 + $breedData = Db::name('farmer_pond_breed')->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->sum('number'); + //获取捕捞信息 + $catchData = Db::name('farmer_pond_catch')->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->sum('number'); + if($breedData - $catchData != 0){ + $ponds[$k]['is_culture'] = true; + $ponds[$k]['total_num'] = $breedData - $catchData; + //获取水产养殖种类 + $fishKind = Db::name('farmer_pond_breed')->distinct(true)->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->limit(4)->column('kind'); + //获取水产养殖具体品种 + $fiskBreed = Db::name('farmer_pond_breed')->distinct(true)->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->limit(4)->column('breed'); + $ponds[$k]['kind'] = $fishKind; + $ponds[$k]['breed'] = $fiskBreed; + //获取去最新的图片 + $pic = Db::name('farmer_pond_pic')->field('pic,create_time')->where('pond_id',$v['pond_id'])->findOrEmpty(); + if(!empty($pic)){ + $ponds[$k]['pic_detail'] = $pic; + $ponds[$k]['pic_detail']['create_time'] = date('Y-m-d H:i:s',$pic['create_time']); + }else{ + $ponds[$k]['pic_detail'] = []; + } + //获取养殖时间 + $firstBreed = Db::name('farmer_pond_breed')->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->findOrEmpty(); + $ponds[$k]['source_code'] = $firstBreed['source_code']; + $ponds[$k]['create_time'] = date('Y-m-d H:i:s',$firstBreed['create_time']); + }else{ + $ponds[$k]['is_culture'] = false; + } + } + $curl_result['data']['pond_detail'] = $ponds; + } //返回数据 return json($curl_result); }