update
This commit is contained in:
parent
b00e7e6bc6
commit
9a6e5b668e
|
@ -13,10 +13,15 @@ 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('参数错误');
|
||||||
}
|
}
|
||||||
|
if(!in_array($params['user_type'],[1,2,3])){
|
||||||
|
return $this->fail('用户身份信息错误');
|
||||||
|
}
|
||||||
|
//农户
|
||||||
|
if($params['user_type'] == 3){
|
||||||
$url = env('project.worker_domain').'/api/information/farmerInfo';
|
$url = env('project.worker_domain').'/api/information/farmerInfo';
|
||||||
$curl_result = curl_post($url,[],$params);
|
$curl_result = curl_post($url,[],$params);
|
||||||
if($curl_result['code'] == 0){
|
if($curl_result['code'] == 0){
|
||||||
|
@ -124,15 +129,39 @@ class UserController extends BaseApiController
|
||||||
//返回数据
|
//返回数据
|
||||||
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