Merge pull request 'fixed' (#148) from zhangwei into dev

Reviewed-on: #148
This commit is contained in:
weiz 2023-11-01 11:25:24 +08:00
commit 4aff89c800
2 changed files with 92 additions and 5 deletions

View File

@ -13,7 +13,7 @@ use think\response\Json;
class InformationController extends BaseApiController
{
public array $notNeedLogin = ['groupServiceInfo','captainInfo','farmerInfo','farmerLandInfo','farmerPondInfo'];
public array $notNeedLogin = ['groupServiceInfo','captainInfo','farmerInfo','farmerLandInfo','farmerPondInfo','farmerList'];
public function list()
{
@ -410,4 +410,91 @@ class InformationController extends BaseApiController
];
return $this->success('请求成功',$resData);
}
//获取农户列表
public function farmerList() {
$params = $this->request->post(['farmer_name','farmer_phone','group_name','captain_name','page_no','page_size']);
if(empty($params['page_no']) || empty($params['page_size'])){
return $this->fail('参数错误');
}
$data = UserInformationg::alias('f')
->field('f.id as farmer_id,f.create_user_id,f.company_id,f.name as farmer_name,f.phone as farmer_phone,c.company_name,u.nickname as captain_name,g.nickname as group_name')
->leftJoin('company c','f.company_id = c.id')
->leftJoin('user u','u.id = f.create_user_id')
->leftJoin('user g','g.id = c.user_id')
->page($params['page_no'],$params['page_size'])->order('id desc')->select()->toArray();
/*
$data = UserInformationg::field('id,create_user_id,company_id,name,phone,area_id,street_id,village_id,brigade_id,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name,address')->page($params['page_no'],$params['page_size'])->order('id desc')->select()->each(function($item){
$item['address'] = $item['area_name'].$item['street_name'].$item['village_name'].$item['brigade_name'].$item['address'];
unset($item['area_name'],$item['street_name'],$item['village_name'],$item['brigade_name'],$item['area_id'],$item['street_id'],$item['village_id'],$item['brigade_id']);
//获取公司信息
$company = Company::field('company_name,user_id')->where('id',$item['company_id'])->findOrEmpty();
$item['company_name'] = $company['company_name'];
//获取生产队长信息
$captain = User::field('nickname')->where('id',$item['create_user_id'])->findOrEmpty();
$item['captain_name'] = $captain['nickname'];
//获取小组服务公司用户信息
$group = User::field('nickname')->where('id',$company['user_id'])->findOrEmpty();
$item['group_name'] = $group['nickname'];
$userInformationgDemand = UserInformationgDemand::field('id,category_child,data')->where('information_id', $item['id'])->where('category_id',6)->where('category_child','in','7,32')->order('id', 'desc')->select()->toArray();
//是否是种植户
$is_zz_user = false;
//是否是水产养殖户
$is_sc_user = false;
//是否是家禽养殖户
$is_jq_user = false;
//是否是大型动物养殖户
$is_dw_user = false;
//土地总面积
$total_land_area = 0;
//池塘总面积
$total_pond_area = 0;
//家禽养殖场总面积
$total_henhouse_area = 0;
//动物养殖场总面积
$total_pasture_area = 0;
foreach($userInformationgDemand as $v){
if($v['category_child'] == 7){
$is_zz_user = true;
$total_land_area += floatval($v['data']['area']);
}
if($v['category_child'] == 32){
if($v['data']['breeding_type'] == 1){//水产
$is_sc_user = true;
$total_pond_area += floatval($v['data']['area']);
}elseif ($v['data']['breeding_type'] == 2) {//脯乳动物
$is_jq_user = true;
$total_henhouse_area += floatval($v['data']['area']);
}elseif ($v['data']['breeding_type'] == 3){//家禽
$is_dw_user = true;
$total_pasture_area += floatval($v['data']['area']);
}
}
}
$str = [];
$area = [];
if($is_zz_user){
$str[] = '种植户';
$area[] = $total_land_area;
}
if($is_sc_user){
$str[] = '水产养殖户';
$area[] = $total_pond_area;
}
if($is_jq_user){
$str[] = '家禽养殖户';
$area[] = $total_henhouse_area;
}
if($is_dw_user){
$str[] = '家畜养殖户';
$area[] = $total_pasture_area;
}
$item['farmer_type'] = implode('/',$str);
$item['farmer_area'] = implode('/',$area);
return $item;
})->toArray();
*/
dump($data);
}
}

View File

@ -236,11 +236,11 @@ class VehicleController extends BaseApiController
return $this->fail('当前小组服务公司未签约');
}
//获取签约信息
$contract = Contract::where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->find();
$contract = Contract::where('party_b',$this->userInfo['company_id'])->where('signing_timer',2)->findOrEmpty();
if(empty($contract) || empty($party_a)){
return $this->fail('未找到签约镇街公司');
}
$party_a = Company::field('id,company_name,master_name,master_phone,master_email,is_contract,organization_code,company_type')->where('id',$contract['party_a'])->find();
if(empty($contract) || empty($party_a)){
return $this->fail('未找到签约镇街公司');
}
if($party_a['company_type'] != 16){
return $this->fail('不能与非镇街公司签约');
}