adminInfo = get_login_admin(); $this->category_id = 305; $this->url = [ '/admin/nk.user/index?category_id=' . $this->category_id, '/admin/nk.user/add', '/admin/nk.user/edit', '/admin/nk.user/del', '/admin/nk.user/read', '/admin/nk.user/auths', '/admin/nk.user/postedit', ]; } /** * 查看 */ public function index() { if (request()->isAjax()) { $mmm = []; $post = get_params(); if (!empty($post['keywords'])) { $mmm[] = ['m.name', 'LIKE', '%' . $post['keywords'] . '%']; } if (!empty($post['phone'])) { $mmm[] = ['m.phone', 'LIKE', '%' . $post['phone'] . '%']; } //权限组信息 if ($this->adminInfo['position_id'] != 1) { $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->adminInfo['id'])->find(); if ($find) { if ($find['auth_range'] == 1) { $mmm['village_id'] = $find['village_id']; } elseif ($find['auth_range'] == 2) { $mmm['street_id'] = $find['street_id']; } elseif ($find['auth_range'] == 3) { $mmm['area_id'] = $find['area_id']; } } } if ($post) { if (isset($post['area_id']) && !empty($post['area_id'])) { $mmm['area_id'] = $post['area_id']; } if (isset($post['street_id']) && !empty($post['street_id'])) { $mmm['street_id'] = $post['street_id']; } if (isset($post['village_id']) && !empty($post['village_id'])) { $mmm['village_id'] = $post['village_id']; } if (isset($post['brigade_id']) && !empty($post['brigade_id'])) { $mmm['brigade_id'] = $post['brigade_id']; } } //权限组信息 $total = Db::table('fa_szxc_information_usermsg') ->alias('m') ->where($mmm) ->count(); $list = Db::table('fa_szxc_information_usermsg') ->alias('m') ->where($mmm) ->join(['fa_user' => 'u'], 'm.user_id=u.id') ->join(['fa_user_group' => 'g'], 'g.id=u.group_id') ->field('u.id,m.name,m.phone,u.avatar,u.group_id,u.status,m.gender,m.age,g.name group_name,m.householder_id') ->withAttr('count', function ($value, $data) { if ($data['householder_id'] != 0) { $count = Db::table('fa_szxc_information_usermsg')->where('householder_id', $data['householder_id'])->count(); } else { $count = '未绑定户主无法查询'; } return $count; }) ->withAttr('gender', function ($value, $data) { if ($value == 1) { return '男'; } elseif ($value == 2) { return '女'; } }) ->order('id DESC') ->page($post['page']) ->limit($post['limit']) ->select(); $result = ['total' => $total, 'data' => $list]; return table_assign(0, '', $result); } //权限组信息 if ($this->adminInfo['position_id'] != 1) { //不是超级管理员 $www['admin_id'] = $this->adminInfo['id']; $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); if ($user_address) { if ($user_address['auth_range'] == 1) { $select = Db::table('fa_geo_area')->where('city_code', '510500')->where('area_code', $user_address['area_id'])->select(); } elseif ($user_address['auth_range'] == 2) { $select = Db::table('fa_geo_area')->where('city_code', '510500')->where('area_code', $user_address['area_id'])->select(); } elseif ($user_address['auth_range'] == 3) { $select = Db::table('fa_geo_area')->where('city_code', '510500')->where('area_code', $user_address['area_id'])->select(); } elseif ($user_address['auth_range'] == 4) { $select = Db::table('fa_geo_area')->where('city_code', '510500')->select(); } else { $select = Db::table('fa_geo_area')->where('city_code', '510500')->select(); } View::assign('row', $user_address); } else { $user_address['area_id'] = ''; $user_address['street_id'] = ''; $user_address['village_code'] = ''; $user_address['auth_range'] = '1'; $select = Db::table('fa_geo_area')->where('city_code', '510500')->select(); View::assign('row', $user_address); } $is_admin = 0; } else { $user_address['area_id'] = ''; $user_address['street_id'] = ''; $user_address['village_code'] = ''; $user_address['auth_range'] = ''; $select = Db::table('fa_geo_area')->where('city_code', '510500')->select(); View::assign('row', $user_address); $is_admin = 1; } View::assign('arealist', $select); View::assign('is_admin', $is_admin); View::assign('url', $this->url); return view(); } /** * 添加 */ public function add() { if (request()->isAjax()) { $params = get_params(); $params['category_id'] = $this->category_id; (new Article())->add($params); } else { View::assign('editor', get_system_config('other', 'editor')); View::assign('url', $this->url); return view('nk/article/add'); } } /** * 修改 */ public function edit() { $params = get_params(); $find = Db::table('fa_szxc_information_usermsg') ->where('user_id', $params['id'])->find(); //获取所有分类 $www2[] = ['type', 'in', ['Nation', 'Education', 'Occupation', 'Zzmm', 'Family', 'Nature_of_land', 'Blood_type', 'Drug_allergy', 'Exposure_history', 'History_of_disease', 'Whether_disabled', 'Cfpfss', 'Fuel_type', 'Drinking_water', 'Toilet_msg', 'Poultry_corral', 'Insurance_type', 'House', 'Car', 'Grade', 'Insurance', 'Medical_insurance_type', 'FamilyHistory', 'Marriage']]; $all_category = Db::table('fa_category')->where($www2)->field('id,type,name,pid')->select(); //种植信息 $planting = Db::table('fa_szxc_information_planting')->where('user_id', $params['id']) ->find(); $strlen = strlen($planting['breed_msg']); if ($strlen != 0 || $strlen > 10) { $planting['breed_msg'] = json_decode($planting['breed_msg'], true); } $strlen1 = strlen($planting['crops_msg']); if ($strlen1 != 0 || $strlen1 > 10) { $planting['crops_msg'] = json_decode($planting['crops_msg'], true); } $strlen2 = strlen($planting['tools_msg']); if ($strlen2 != 0 || $strlen2 > 10) { $planting['tools_msg'] = json_decode($planting['tools_msg'], true); } //保险信息 $insurancearr = Db::table('fa_szxc_information_insurance')->where('user_id', $params['id'])->find(); //健康信息 $healthyarr = Db::table('fa_szxc_information_healthy')->where('user_id', $params['id'])->find(); if ($planting == null) { $planting = [ "tools_msg" => "", "crops_msg" => "", "land_area" => "", "is_wz" => '', "nature_of_land" => "", ]; } if ($insurancearr == null) { $insurancearr = [ "endowment_insurance_status" => "", "is_subsidy" => "", "insurance_reason" => "", "medical_insurance_type" => "", "whether_disabled" => "", "disability_num" => "", "disability_type" => "", "disability_level" => "", "insurance_type" => "", "ny_insurance" => "", "sy_insurance" => "", ]; } if ($healthyarr == null) { $healthyarr = [ "medical_insurance_type" => "", "insurance_type" => "", "blood_type" => "", "drug_allergy" => "", "exposure_history" => "", "history_of_disease" => "", "history_of_surgery" => "", "family_history" => "", "familial_diseases" => "", "genetic_history" => "", "genetic_name" => "", "whether_disabled" => "", "cfpfss" => "", "fuel_type" => "", "drinking_water" => "", "toilet_msg" => "", "poultry_corral" => "", ]; } View::assign('user_id', $params['id']); View::assign('healthyarr', $healthyarr); View::assign('insurancearr', $insurancearr); View::assign('planting', $planting); View::assign('all_category', $all_category); View::assign('user', $find); View::assign('url', $this->url); View::assign('editor', get_system_config('other', 'editor')); return view(); } /** * 提交修改 */ public function postedit() { $params = get_params(); // halt($params); if ($params['type'] == 1) { unset($params['type']); $res = Db::table('fa_szxc_information_usermsg')->where('user_id', $params['user_id'])->update($params); if ($res) { return to_assign(0, '操作成功'); } else { return to_assign(1, '操作失败'); } } if ($params['type'] == 2) { $params['crops_msg'] = json_encode($params['crops_msg']); unset($params['type']); $find = Db::table('fa_szxc_information_planting')->where('user_id', $params['user_id'])->find(); if ($find) { $res = Db::table('fa_szxc_information_planting')->where('id', $find['id'])->update($params); $id = $find['id']; } else { $res = Db::table('fa_szxc_information_planting')->where('user_id', $params['user_id'])->insertGetId($params); $id = $res; } if ($res) { $time = time(); // 新增写入种植表 Db::table('fa_szxc_planting')->where('user_id',$params['user_id'])->delete(); $mianji = 0; if($params['crops_msg']){ $crops_msg_arr = json_decode($params['crops_msg'],1); foreach ($crops_msg_arr as $k=>$v){ // 根据名字查询分类 if($v['name']){ $type = Db::table('fa_szxc_planting_type')->where('name',$v['name'])->find(); if($type){ $planting_data['type_id'] = $type['id']; }else{ $type_data['name'] = $v['name']; $type_data['createtime'] = $time; $type_id = Db::table('fa_szxc_planting_type')->strict(false)->insertGetId($type_data); $planting_data['type_id'] = $type_id; } $planting_data['user_id'] = $params['user_id']; $planting_data['num'] = $v['num']??0; $planting_data['measure'] = $v['mianji']??0; $planting_data['createtime'] = $time; Db::table('fa_szxc_planting')->strict(false)->insertGetId($planting_data); } // 计算面积 if($v['mianji']){ $mianji += $v['mianji']; } } } // 新增写入养殖表 Db::table('fa_szxc_breed')->where('user_id',$params['user_id'])->delete(); // $mianji = 0; if(isset($params['breed_msg']) && !empty($params['breed_msg'])){ $breed_msg_arr = json_decode($params['breed_msg'],1); foreach ($breed_msg_arr as $k=>$v){ // 根据名字查询分类 if($v['name']){ $type = Db::table('fa_szxc_breed_type')->where('name',$v['name'])->find(); if($type){ $breed_data['type_id'] = $type['id']; }else{ $type_data['name'] = $v['name']; $type_data['createtime'] = $time; $type_id = Db::table('fa_szxc_breed_type')->strict(false)->insertGetId($type_data); $breed_data['type_id'] = $type_id; } $breed_data['user_id'] = $params['user_id']; $breed_data['num'] = $v['num']??0; $breed_data['measure'] = $v['mianji']??0; $breed_data['createtime'] = $time; Db::table('fa_szxc_breed')->strict(false)->insertGetId($breed_data); } } } $waste_land_area = $params['land_area'] - $mianji; if($waste_land_area < 0){ $waste_land_area = 0; } $ddd['waste_land_area'] = $waste_land_area; Db::table('fa_szxc_information_planting')->where('id', $id)->update($ddd); return to_assign(0, '操作成功'); } else { return to_assign(1, '操作失败'); } } if ($params['type'] == 3) { unset($params['type']); $find = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->find(); if ($find) { $res = Db::table('fa_szxc_information_insurance')->where('id', $find['id'])->update($params); } else { $res = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->insert($params); } if ($res) { return to_assign(0, '操作成功'); } else { return to_assign(1, '操作失败'); } } if ($params['type'] == 4) { unset($params['type']); $find = Db::table('fa_szxc_information_healthy')->where('user_id', $params['user_id'])->find(); if ($find) { $res = Db::table('fa_szxc_information_healthy')->where('id', $find['id'])->update($params); } else { $res = Db::table('fa_szxc_information_healthy')->where('user_id', $params['user_id'])->insert($params); } if ($res) { return to_assign(0, '操作成功'); } else { return to_assign(1, '操作失败'); } } } /** * 查看信息 */ public function read() { $params = get_params(); $find = Db::table('fa_szxc_information_usermsg') ->withAttr('gender', function ($value, $data) { if ($value == 1) { return '男'; } return '女'; })->withAttr('education', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('nation', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('political_outlook', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('house_msg', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('car_msg', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('marital_status', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); }) ->where('user_id', $params['id'])->find(); //家庭信息 if ($find == null || $find['householder_id'] == 0) { $family = []; } else { if ($find['householder_id'] == $find['user_id']) { $family['name'] = '本人'; } else { $family['name'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $find['householder_id'])->value('name'); $family['relation'] = Db::table('fa_category')->where('id', $find['family_relation'])->value('name'); } $family['list'] = Db::table('fa_szxc_information_usermsg')->where('householder_id', $find['householder_id'])->where('user_id', '<>', $find['householder_id'])->field('user_id,name,age,gender,phone')->select(); } //种植信息 if ($find || $find['householder_id'] == $params['id']) { $Planting['is'] = 1; $Planting['list'] = []; $finds = Db::table('fa_szxc_information_planting')->where('user_id', $params['id']) ->withAttr('crops_msg', function ($value, $data) { return json_decode($value, true); }) ->withAttr('breed_msg', function ($value, $data) { return json_decode($value, true); }) ->withAttr('tools_msg', function ($value, $data) { return json_decode($value, true); }) ->withAttr('nature_of_land', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); }) ->withAttr('is_wz', function ($value, $data) { return $value == 0 ? '否' : '是'; }) ->find(); if ($find) { $Planting['list'] = $finds; } } else { $Planting['is'] = 0; } $insurancearr = Db::table('fa_szxc_information_insurance') ->withAttr('endowment_insurance_status', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('insurance_type', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('whether_disabled', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('disability_level', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('ny_insurance', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('sy_insurance', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); }) ->where('user_id', $params['id'])->find(); $healthyarr = Db::table('fa_szxc_information_healthy') ->withAttr('blood_type', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('drug_allergy', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('exposure_history', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('history_of_disease', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('history_of_surgery', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('family_history', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('familial_diseases', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('genetic_history', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('cfpfss', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('fuel_type', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('drinking_water', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('toilet_msg', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('poultry_corral', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); })->withAttr('genetic_name', function ($value, $data) { return Db::table('fa_category')->where('id', $value)->value('name'); }) ->where('user_id', $params['id'])->find(); View::assign('id', $params['id']); View::assign('read', $find); View::assign('family', $family); View::assign('planting', $Planting); View::assign('insurancearr', $insurancearr); View::assign('healthyarr', $healthyarr); return view(); } public function auths() { $params = get_params(); if (request()->isPost()) { $admin = Db::name('Admin')->where('user_id', $params['id'])->find(); $user = Db::table('fa_user')->where('id', $params['id'])->find(); if ($params['village_id'] != '') { $village = Db::table('fa_geo_village')->where('village_code', $params['village_id'])->find(); } // 组装地址名 if ($params['area_id'] != '') { $area_name = Db::table('fa_geo_area')->where('area_code', $params['area_id'])->value('area_name'); } if ($params['street_id'] != '') { $street_name = Db::table('fa_geo_street')->where('street_code', $params['street_id'])->value('street_name'); } if ($params['brigade_id'] != '') { $brigade_name = Db::table('fa_geo_brigade')->where('id', $params['brigade_id'])->value('brigade_name'); } $address_name = $area_name . $street_name . $village['village_name'] . $brigade_name; if ($admin) { Db::startTrans(); try { if ($params['groupdata'] == 0) { Db::name('admin_group_access')->where('uid', $admin['id'])->delete(); Db::name('Admin')->where('id', $admin['id'])->update(['status' => 0]); } else { $is_have_admin = Db::name('admin_group_access')->where('uid', $admin['id'])->find(); if ($is_have_admin) { Db::name('admin_group_access')->where('uid', $admin['id'])->update(['group_id' => $params['groupdata']]); } else { $group_access2 = ['uid' => $admin['id'], 'group_id' => $params['groupdata']]; //写入权限组 Db::name('admin_group_access')->insert($group_access2); } Db::name('Admin')->where('id', $admin['id'])->update(['status' => 1]); } $useraddress = [ 'area_id' => $params['area_id'], 'street_id' => $params['street_id'], 'village_code' => $params['village_id'], 'brigade_id' => $params['brigade_id'], 'auth_range' => $params['auth_range'], 'village_id' => $params['village_id'] != '' ? $village['village_id'] : 0, 'admin_id' => $admin['id'], ]; Db::table('fa_szxc_information_useraddress')->where('user_id', $params['id'])->update($useraddress); // 修改user表 $ddd['is_admin'] = 1; $ddd['group_id'] = $params['group_id']; Db::table('fa_user')->where('id', $params['id'])->update($ddd); // 修改商城关系表 $nk_user['n_user_id'] = $params['id']; $is_nk_user = Db::connect('shop')->name('nk_user')->where($nk_user)->find(); if ($is_nk_user) { $nk_data['group_id'] = $params['group_id']; Db::connect('shop')->name('nk_user')->where($nk_user)->update($nk_data); } // 修改用户详细地址 $u_msg['address_name'] = $address_name; $u_msg['area_id'] = $params['area_id']; $u_msg['street_id'] = $params['street_id']; $u_msg['village_id'] = $params['village_id'] != '' ? $village['village_id'] : 0; $u_msg['brigade_id'] = $params['brigade_id']; Db::table('fa_szxc_information_usermsg')->where('user_id', $params['id'])->update($u_msg); // 提交事务 Db::commit(); } catch (\Exception $e) { // 回滚事务 Db::rollback(); return to_assign(1, '操作失败,原因:' . $e->getMessage()); } return to_assign(0, '操作成功'); } else { $salt = set_salt(20); $data = [ 'user_id' => $params['id'], 'username' => $user['username'], 'nickname' => $user['nickname'], 'thumb' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230104/32a639be4ee32349705e947fbbd1e114.png', 'mobile' => 13688888886, 'did' => 1, 'position_id' => 3, 'salt' => $salt, 'pwd' => set_password(123456, $salt), 'email' => '', ]; Db::startTrans(); try { $w['user_id'] = $params['id']; $is_have = Db::table('fa_szxc_information_useraddress')->where($w)->find(); // 创建管理员账号 $admin_id = Db::name('Admin')->insertGetId($data); // 写入权限组 Db::name('AdminGroupAccess')->strict(false)->field(true)->insert([ 'uid' => $admin_id, 'group_id' => $params['group_id'], ]); add_log('add', $this->adminInfo['id'], $params); // Db::table('fa_auth_group_access')->insert($group_access); // 修改user表 $ddd['is_admin'] = 1; $ddd['group_id'] = $params['group_id']; Db::table('fa_user')->where('id', $params['id'])->update($ddd); // 修改商城关系表 $nk_user['n_user_id'] = $params['id']; $is_nk_user = Db::connect('shop')->name('nk_user')->where($nk_user)->find(); if ($is_nk_user) { $nk_data['group_id'] = $params['group_id']; Db::connect('shop')->name('nk_user')->where($nk_user)->update($nk_data); } if ($is_have) { $useraddress = [ 'user_id' => $params['id'], 'admin_id' => $admin_id, 'area_id' => $params['area_id'], 'street_id' => $params['street_id'], 'village_code' => $params['village_id'], 'village_id' => $village['village_id'], 'brigade_id' => $params['brigade_id'], 'auth_range' => $params['auth_range'], ]; Db::table('fa_szxc_information_useraddress')->where($w)->update($useraddress); } else { $useraddress = [ 'user_id' => $params['id'], 'admin_id' => $admin_id->id, 'area_id' => $params['area_id'], 'street_id' => $params['street_id'], 'village_code' => $params['village_id'], 'village_id' => $village['village_id'], 'brigade_id' => $params['brigade_id'], 'auth_range' => $params['auth_range'], 'createtime' => date('Y-m-d H:i:s') ]; Db::table('fa_szxc_information_useraddress')->insert($useraddress); } // 修改用户详细地址 $u_msg['address_name'] = $address_name; $u_msg['area_id'] = $params['area_id']; $u_msg['street_id'] = $params['street_id']; $u_msg['village_id'] = $params['village_id'] != '' ? $village['village_id'] : 0; $u_msg['brigade_id'] = $params['brigade_id']; Db::table('fa_szxc_information_usermsg')->where('user_id', $params['id'])->update($u_msg); // 提交事务 Db::commit(); } catch (\Exception $e) { // 回滚事务 Db::rollback(); return to_assign(1, '操作失败,原因:' . $e->getMessage()); } return to_assign(0, '操作成功'); } } $user = Db::table('fa_user')->where('id', $params['id'])->field('id,nickname,group_id')->find(); // $geo_brigade = Db::table('fa_geo_brigade')->select(); $useraddress = [ 'area_id' => 0, 'street_id' => 0, 'village_id' => 0, 'village_code' => 0, 'brigade_id' => 0, 'admin_group' => 0, 'auth_range' => 1, ]; $address = Db::table('fa_szxc_information_useraddress')->where('user_id', $params['id'])->find(); if ($address) { $useraddress['area_id'] = $address['area_id']; $useraddress['street_id'] = $address['street_id']; $useraddress['village_id'] = $address['village_id']; $useraddress['brigade_id'] = $address['brigade_id']; $useraddress['village_code'] = $address['village_code']; $useraddress['auth_range'] = $address['auth_range']; $admin = Db::name('admin_group_access')->where('uid', $address['admin_id'])->find(); if ($admin) { $useraddress['admin_group'] = $admin['group_id']; } } //权限组信息 $groupwhere[] = ['id', 'in', 2, 4]; if ($this->adminInfo['position_id'] != 1) { //不是超级管理员 // $www['admin_id'] = $this->adminInfo['id']; // $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); // if ($user_address) { if ($this->adminInfo['group_access'] == 2) { $auth_range = [['name' => '村级', 'value' => '1']]; $groupwhere[] = ['id', 'in', 2]; } if ($this->adminInfo['group_access'] == 4) { $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2']]; } // if ($user_address['auth_range'] == 3) { // $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3']]; // } // if ($user_address['auth_range'] == 4) { // $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3'], ['name' => '市级', 'value' => '4']]; // } // } } else { $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3'], ['name' => '市级', 'value' => '4']]; } $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500']) ->field('area_id id,area_code code,area_name name') ->select(); $brigade = Db::table('fa_geo_brigade') ->limit(30) ->select(); //后端权限 $groupdata = Db::name('admin_group') ->where($groupwhere) ->limit(30) ->select(); $groupdata[] = ['id' => 0, 'title' => '无后台权限']; //前端权限 $user_group = Db::table('fa_user_group') ->limit(30) ->select(); View::assign('id', $params['id']); View::assign('user_group', $user_group); View::assign('groupdata', $groupdata); View::assign('street', $street); View::assign('brigade', $brigade); View::assign('auth_range', $auth_range); View::assign('user', $user); View::assign('address', $useraddress); View::assign('url', $this->url); View::assign('editor', get_system_config('other', 'editor')); return view(); } public function tongji() { $post = get_params(); $where = []; //权限组信息 $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->adminInfo['user_id'])->find(); if ($find) { if ($find['auth_range'] == 1) { $where['village_id'] = $find['village_id']; } elseif ($find['auth_range'] == 2) { $where['street_id'] = $find['street_id']; } elseif ($find['auth_range'] == 3) { $where['area_id'] = $find['area_id']; } } if ($post['village_id'] != '') { $where['village_id'] = $post['village_id']; } if ($post['brigade_id'] != '') { $where['brigade_id'] = $post['brigade_id']; } if ($post['street_id'] != '') { $where['street_id'] = $post['street_id']; } $where['area_id'] = $post['area_id']; // 大于60岁人数 $old_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>=', 60)->count(); // 儿童人数 $children_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 15)->count(); // 未婚男 $unmarried_man_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 1], ['marital_status', '=', 169]])->count(); // 未婚女 $unmarried_woman_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 2], ['marital_status', '=', 169]])->count(); $land_area_num = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.land_area'); $sum_218 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=218')->sum('p.land_area'); $sum_217 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=217')->sum('p.land_area'); $sum_216 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=216')->sum('p.land_area'); $sum_215 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=215')->sum('p.land_area'); $sum_214 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=214')->sum('p.land_area'); $sum_70 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=70')->sum('p.land_area'); $sum_69 = Db::table('fa_szxc_information_useraddress') ->alias('u') ->where($where) ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=69')->sum('p.land_area'); $result = [ 'old_num' => $old_num, 'children_num' => $children_num, 'unmarried_man_num' => $unmarried_man_num, 'unmarried_woman_num' => $unmarried_woman_num, 'land_area_num' => $land_area_num, 'sum_218' => $sum_218, 'sum_217' => $sum_217, 'sum_216' => $sum_216, 'sum_215' => $sum_215, 'sum_214' => $sum_214, 'sum_70' => $sum_70, 'sum_69' => $sum_69, ]; $result = ['total' => 0, 'data' => $result]; return table_assign(0, '', $result); } /** * 修改 */ public function del() { $params = get_params(); (new Article())->del($params); } }