update
This commit is contained in:
parent
b00e7e6bc6
commit
9a6e5b668e
|
@ -13,126 +13,155 @@ class UserController extends BaseApiController
|
||||||
public function userInfo(): Json
|
public function userInfo(): Json
|
||||||
{
|
{
|
||||||
//获取参数
|
//获取参数
|
||||||
$params = $this->request->get(['user_id']);
|
$params = $this->request->get(['user_id','user_type']);
|
||||||
if(empty($params['user_id'])){
|
if(empty($params['user_id']) || empty($params['user_type'])){
|
||||||
return $this->fail('参数错误');
|
return $this->fail('参数错误');
|
||||||
}
|
}
|
||||||
$url = env('project.worker_domain').'/api/information/farmerInfo';
|
if(!in_array($params['user_type'],[1,2,3])){
|
||||||
$curl_result = curl_post($url,[],$params);
|
return $this->fail('用户身份信息错误');
|
||||||
if($curl_result['code'] == 0){
|
|
||||||
return $this->fail($curl_result['msg']);
|
|
||||||
}
|
}
|
||||||
//判断是否是种植农户
|
//农户
|
||||||
if($curl_result['data']['is_zz_user']){
|
if($params['user_type'] == 3){
|
||||||
$lands = $curl_result['data']['land_detail'];
|
$url = env('project.worker_domain').'/api/information/farmerInfo';
|
||||||
foreach($lands as $k=>$v) {
|
$curl_result = curl_post($url,[],$params);
|
||||||
//查找种植信息
|
if($curl_result['code'] == 0){
|
||||||
$land_crop = Db::name('farmer_land_crop')->where([
|
return $this->fail($curl_result['msg']);
|
||||||
['user_id','=',$params['user_id']],
|
|
||||||
['land_id','=',$v['land_id']],
|
|
||||||
])->order('id desc')->findOrEmpty();
|
|
||||||
if(!empty($land_crop)){
|
|
||||||
$lands[$k]['is_cropped'] = true;
|
|
||||||
$lands[$k]['source_code'] = $land_crop['source_code'];
|
|
||||||
$lands[$k]['crop_name'] = $land_crop['crop_name'];
|
|
||||||
$lands[$k]['crop_variety'] = $land_crop['crop_variety'];
|
|
||||||
$lands[$k]['crop_brand'] = $land_crop['crop_brand'];
|
|
||||||
$lands[$k]['crop_yield'] = $land_crop['crop_yield'];
|
|
||||||
$lands[$k]['seed_time'] = date('Y-m-d H:i:s',$land_crop['seed_time']);
|
|
||||||
$lands[$k]['ripe_time'] = !empty($land_crop['ripe_time']) && !empty($land_crop['crop_yield']) ? date('Y-m-d H:i:s',$land_crop['ripe_time']) : $land_crop['ripe_time'];
|
|
||||||
}else{
|
|
||||||
$lands[$k]['is_cropped'] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$curl_result['data']['land_detail'] = $lands;
|
//判断是否是种植农户
|
||||||
}
|
if($curl_result['data']['is_zz_user']){
|
||||||
//判断是否是家畜养殖户
|
$lands = $curl_result['data']['land_detail'];
|
||||||
if($curl_result['data']['is_dw_user']){
|
foreach($lands as $k=>$v) {
|
||||||
//获取家畜养殖数量
|
//查找种植信息
|
||||||
$animalCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->count();
|
$land_crop = Db::name('farmer_land_crop')->where([
|
||||||
//获取家畜是公的数量
|
['user_id','=',$params['user_id']],
|
||||||
$maleCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_gender',1)->count();
|
['land_id','=',$v['land_id']],
|
||||||
//获取家畜是母的数量
|
])->order('id desc')->findOrEmpty();
|
||||||
$maternalCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_gender',2)->count();
|
if(!empty($land_crop)){
|
||||||
//获取家畜养殖种类
|
$lands[$k]['is_cropped'] = true;
|
||||||
$animalKind = Db::name('farmer_animal_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('animal_kind');
|
$lands[$k]['source_code'] = $land_crop['source_code'];
|
||||||
//获取家畜养殖具体品种
|
$lands[$k]['crop_name'] = $land_crop['crop_name'];
|
||||||
$animalBreed = Db::name('farmer_animal_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('animal_breed');
|
$lands[$k]['crop_variety'] = $land_crop['crop_variety'];
|
||||||
$curl_result['data']['animal_detail'] = [
|
$lands[$k]['crop_brand'] = $land_crop['crop_brand'];
|
||||||
'total_count' => $animalCount,
|
$lands[$k]['crop_yield'] = $land_crop['crop_yield'];
|
||||||
'male_count' => $maleCount,
|
$lands[$k]['seed_time'] = date('Y-m-d H:i:s',$land_crop['seed_time']);
|
||||||
'maternal_count' => $maternalCount,
|
$lands[$k]['ripe_time'] = !empty($land_crop['ripe_time']) && !empty($land_crop['crop_yield']) ? date('Y-m-d H:i:s',$land_crop['ripe_time']) : $land_crop['ripe_time'];
|
||||||
'kind' => $animalKind,
|
|
||||||
'breed' => $animalBreed
|
|
||||||
];
|
|
||||||
}
|
|
||||||
//判断是否是家禽养殖户
|
|
||||||
if($curl_result['data']['is_jq_user']){
|
|
||||||
//获取家畜养殖数量
|
|
||||||
$poultryCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->count();
|
|
||||||
//获取家畜是公的数量
|
|
||||||
$maleCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('gender',1)->count();
|
|
||||||
//获取家畜是母的数量
|
|
||||||
$maternalCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('gender',2)->count();
|
|
||||||
//获取家畜养殖种类
|
|
||||||
$poultryKind = Db::name('farmer_poultry_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('kind');
|
|
||||||
//获取家畜养殖具体品种
|
|
||||||
$poultryBreed = Db::name('farmer_poultry_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('breed');
|
|
||||||
$curl_result['data']['poultry_detail'] = [
|
|
||||||
'total_count' => $poultryCount,
|
|
||||||
'male_count' => $maleCount,
|
|
||||||
'maternal_count' => $maternalCount,
|
|
||||||
'kind' => $poultryKind,
|
|
||||||
'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{
|
}else{
|
||||||
$ponds[$k]['pic_detail'] = [];
|
$lands[$k]['is_cropped'] = false;
|
||||||
}
|
}
|
||||||
//获取养殖时间
|
|
||||||
$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']['land_detail'] = $lands;
|
||||||
}
|
}
|
||||||
$curl_result['data']['pond_detail'] = $ponds;
|
//判断是否是家畜养殖户
|
||||||
|
if($curl_result['data']['is_dw_user']){
|
||||||
|
//获取家畜养殖数量
|
||||||
|
$animalCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->count();
|
||||||
|
//获取家畜是公的数量
|
||||||
|
$maleCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_gender',1)->count();
|
||||||
|
//获取家畜是母的数量
|
||||||
|
$maternalCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_gender',2)->count();
|
||||||
|
//获取家畜养殖种类
|
||||||
|
$animalKind = Db::name('farmer_animal_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('animal_kind');
|
||||||
|
//获取家畜养殖具体品种
|
||||||
|
$animalBreed = Db::name('farmer_animal_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('animal_breed');
|
||||||
|
$curl_result['data']['animal_detail'] = [
|
||||||
|
'total_count' => $animalCount,
|
||||||
|
'male_count' => $maleCount,
|
||||||
|
'maternal_count' => $maternalCount,
|
||||||
|
'kind' => $animalKind,
|
||||||
|
'breed' => $animalBreed
|
||||||
|
];
|
||||||
|
}
|
||||||
|
//判断是否是家禽养殖户
|
||||||
|
if($curl_result['data']['is_jq_user']){
|
||||||
|
//获取家畜养殖数量
|
||||||
|
$poultryCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->count();
|
||||||
|
//获取家畜是公的数量
|
||||||
|
$maleCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('gender',1)->count();
|
||||||
|
//获取家畜是母的数量
|
||||||
|
$maternalCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('gender',2)->count();
|
||||||
|
//获取家畜养殖种类
|
||||||
|
$poultryKind = Db::name('farmer_poultry_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('kind');
|
||||||
|
//获取家畜养殖具体品种
|
||||||
|
$poultryBreed = Db::name('farmer_poultry_breed')->distinct(true)->where('user_id',$params['user_id'])->limit(4)->column('breed');
|
||||||
|
$curl_result['data']['poultry_detail'] = [
|
||||||
|
'total_count' => $poultryCount,
|
||||||
|
'male_count' => $maleCount,
|
||||||
|
'maternal_count' => $maternalCount,
|
||||||
|
'kind' => $poultryKind,
|
||||||
|
'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);
|
||||||
}
|
}
|
||||||
//返回数据
|
//生产队长
|
||||||
return json($curl_result);
|
if($params['user_type'] == 2){
|
||||||
|
$url = env('project.worker_domain').'/api/information/captainInfo';
|
||||||
|
$curl_result = curl_post($url,[],$params);
|
||||||
|
return json($curl_result);
|
||||||
|
}
|
||||||
|
//小组服务公司
|
||||||
|
if($params['user_type'] == 1){
|
||||||
|
$url = env('project.worker_domain').'/api/information/groupServiceInfo';
|
||||||
|
$curl_result = curl_post($url,[],$params);
|
||||||
|
return json($curl_result);
|
||||||
|
}
|
||||||
|
return $this->fail('数据不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取操作信息
|
//获取操作信息
|
||||||
public function actions(): Json
|
public function actions(): Json
|
||||||
{
|
{
|
||||||
//获取参数
|
//获取参数
|
||||||
$params = $this->request->get(['type']);
|
$params = $this->request->get(['type','crop_id','pond_id']);
|
||||||
if(empty($params['type']) || !in_array($params['type'],[1,2,3,4])){
|
if(empty($params['type']) || !in_array($params['type'],[1,2,3,4])){
|
||||||
return $this->fail('参数错误');
|
return $this->fail('参数错误');
|
||||||
}
|
}
|
||||||
|
if($params['type'] == 1){
|
||||||
|
if(empty($params['crop_id'])){
|
||||||
|
return $this->fail('参数错误');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($params['type'] == 4){
|
||||||
|
if(empty($params['pond_id'])){
|
||||||
|
return $this->fail('参数c错误');
|
||||||
|
}
|
||||||
|
}
|
||||||
//获取数据
|
//获取数据
|
||||||
$actions = Db::name('farmer_action')->where('farmer_type',$params['type'])->select()->each(function($item){
|
$actions = Db::name('farmer_action')->where('farmer_type',$params['type'])->select()->each(function($item){
|
||||||
$actionType = Db::name('farmer_action_type')->where('id',$item['type_id'])->findOrEmpty();
|
$actionType = Db::name('farmer_action_type')->where('id',$item['type_id'])->findOrEmpty();
|
||||||
|
@ -155,7 +184,7 @@ class UserController extends BaseApiController
|
||||||
foreach($arr1 as $k=>$v) {
|
foreach($arr1 as $k=>$v) {
|
||||||
$actionIds = array_column($v['actions'],'id');
|
$actionIds = array_column($v['actions'],'id');
|
||||||
$actionsInfo = $v['actions'];
|
$actionsInfo = $v['actions'];
|
||||||
$arr1[$k]['action_record'] = Db::name('farmer_pond_record')->where('action_id','in',$actionIds)->order('id desc')->limit(5)->select()->each(function($item)use($actionsInfo){
|
$arr1[$k]['action_record'] = Db::name('farmer_pond_record')->where('action_id','in',$actionIds)->where('pond_id',$params['pond_id'])->order('id desc')->limit(5)->select()->each(function($item)use($actionsInfo){
|
||||||
foreach ($actionsInfo as $val){
|
foreach ($actionsInfo as $val){
|
||||||
if($item['action_id'] == $val['id']){
|
if($item['action_id'] == $val['id']){
|
||||||
$item['action_name'] = $val['name'];
|
$item['action_name'] = $val['name'];
|
||||||
|
@ -200,7 +229,7 @@ class UserController extends BaseApiController
|
||||||
foreach($arr1 as $k=>$v) {
|
foreach($arr1 as $k=>$v) {
|
||||||
$actionIds = array_column($v['actions'],'id');
|
$actionIds = array_column($v['actions'],'id');
|
||||||
$actionsInfo = $v['actions'];
|
$actionsInfo = $v['actions'];
|
||||||
$arr1[$k]['action_record'] = Db::name('farmer_land_crop_record')->where('action_id','in',$actionIds)->order('id desc')->limit(5)->select()->each(function($item)use($actionsInfo){
|
$arr1[$k]['action_record'] = Db::name('farmer_land_crop_record')->where('action_id','in',$actionIds)->where('crop_id',$params['crop_id'])->order('id desc')->limit(5)->select()->each(function($item)use($actionsInfo){
|
||||||
foreach ($actionsInfo as $val){
|
foreach ($actionsInfo as $val){
|
||||||
if($item['action_id'] == $val['id']){
|
if($item['action_id'] == $val['id']){
|
||||||
$item['action_name'] = $val['name'];
|
$item['action_name'] = $val['name'];
|
||||||
|
|
Loading…
Reference in New Issue