// +---------------------------------------------------------------------- namespace app\user\controller; use function AlibabaCloud\Client\value; use app\user\validate\UserProfileValidate; use app\admin\validate\UserValidate; use cmf\controller\AdminBaseController; use think\Db; use think\db\Query; use PHPExcel; use app\admin\model\AccountLogModel; use app\admin\model\UserModel; use app\weixin\service\Member; use app\weixin\model\Wechat; use app\weixin\model\Member as MemberModel; /** * Class AdminIndexController * @package app\user\controller * * @adminMenuRoot( * 'name' =>'用户管理', * 'action' =>'default', * 'parent' =>'', * 'display'=> true, * 'order' => 10, * 'icon' =>'group', * 'remark' =>'用户管理' * ) * * @adminMenuRoot( * 'name' =>'用户组', * 'action' =>'default1', * 'parent' =>'user/AdminIndex/default', * 'display'=> true, * 'order' => 10000, * 'icon' =>'', * 'remark' =>'用户组' * ) */ class AdminIndexController extends AdminBaseController { /** * 后台本站用户列表 * @adminMenu( * 'name' => '本站用户', * 'parent' => 'default1', * 'display'=> true, * 'hasView'=> true, * 'order' => 10000, * 'icon' => '', * 'remark' => '本站用户', * 'param' => '' * ) */ public function index() { // $content = hook_one('user_admin_index_view'); // if (!empty($content)) { // return $content; // } $data = $this->request->param(); session('search',[ 'uid' => isset($data['uid'])? intval($data['uid']) : 0, 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '', ]); // 添加返回历史修改 by wesmiler 2020-02-16 $history = isset($data['history'])? intval($data['history']) : 0; if($history){ $data = session('user_search'); }else{ session('user_search', $data); } // 修改 end //var_dump($data);die; $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,last_login_time,up.idcard, up.idcard_check,up.position_check,up.education_check') ->alias('u') ->join('user_profile up','u.id=up.userid','left') ->where(function (Query $query) use($data){ $query->where('u.user_type', 2); $query->where('u.openid', 'not in',''); //代表是否付费定制 ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0); //代表是否冻结 if($this->request->action()!='userlogout' && $this->request->param('u')!=5){ ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1); }else{ //代表是否筛选 ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0); } //代表是否注销 if($this->request->action()!='userban' && $this->request->param('u')!=3){ ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1); } //$data = $this->request->param(); if (!empty($data['uid'])) { $query->where('u.id', intval($data['uid'])); } if (!empty($data['keyword'])) { $keyword = $data['keyword']; $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%"); } //年龄区间查询 if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){ $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and'); $query->whereNotNull('u.birthday'); } // //只有第一个年龄的情况下 if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){ $birthday = $data['age1']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null "); } // //只有第二个年龄的情况下 if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){ $birthday = $data['age2']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null "); } //身高区间查询 if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',['>',input('height')],['<',input('heightt')],'and'); } //身高第一个查找 if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){ $query->where('up.height',input('height')); } //身高第二个查找 if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',input('heightt')); } //学历 if((!empty(input('education')) && input('education')!='none') ){ $query->where('up.education',input('education')); } //职位 if((!empty(input('occupation')) && input('occupation')!='none') ){ $query->where('up.occupation',input('occupation')); } //收入 if((!empty(input('salary')) && input('salary')!='none') ){ $query->where('up.salary',input('salary')); } //资产 if((!empty(input('property')) && input('property')!='none') ){ $query->where('up.property',input('property')); } //家乡 if((!empty(input('home_city')) && input('home_city')!='none') ){ $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or'); } //居住地(市) if((!empty(input('city')) && input('city')!='none') ){ $query->where('up.city','like','%'.input('city').'%'); } //婚姻状况 if((!empty(input('married')) && input('married')!='none') ){ $query->where('up.married',input('married')); } //性别 if((!empty(input('sex')) && input('sex')!='none') ){ $query->where('u.sex',input('sex')); } }) //待审核 ->order("u.create_time DESC") ->paginate(10,false,['query'=>request()->param()]); // echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); // 渲染模板输出 return $this->fetch(); } /** * 编辑 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function edit(){ // // $id = $this->request->param('id', 0, 'intval'); // $user = DB::name('user')->where("id", $id)->find(); $data = $this->request->param(); // session('search',[ // 'uid' => isset($data['uid'])? intval($data['uid']) : 0, // 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '', // ]); //var_dump($data);die; $user = Db::name('user')->field('u.id,u.avatar,u.weixin_num,u.sex,u.balance,u.birthday,u.score,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.agent_type,u.parent_id, up.idcard_check,up.wechat_code,up.salary,up.position_check,up.education_check,up.height,up.weight,up.education,up.occupation,up.married,up.province,up.city,up.district,up.home_province,up.home_city,up.home_district') ->alias('u') ->join('user_profile up','u.id=up.userid','left') ->where('u.id', input('id')) ->where(function (Query $query) { $query->where('u.user_type', 2); ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0); }) ->find(); // var_dump($user);die; $this->assign($user); return $this->fetch(); } /** * 编辑处理 * @throws \think\Exception * @throws \think\exception\PDOException */ public function editPost(){ // $page=$this->request->param; // echo $page['page'];die(); if ($this->request->isPost()) { if (empty($_POST['user_pass'])) { unset($_POST['user_pass']); } else { $_POST['user_pass'] = cmf_password($_POST['user_pass']); } $validate = new UserValidate(); $result = $validate->scene('info')->check($this->request->param()); if ($result !== true) { // 验证失败 输出错误信息 $this->error($validate->getError()); } else { // $_POST['birthday']=strtotime($_POST['birthday']); //分开保存。用户的 $user['mobile']=$_POST['mobile']; $user['user_nickname']=$_POST['user_nickname']; $user['real_name']=$_POST['real_name']; if($_POST['sex']=='男'){ $user['sex'] =1; }else{ $user['sex'] =2; } $user['redheart']=$_POST['redheart']; // $user['birthday']=strtotime($_POST['birthday']); $user['user_status']=$_POST['user_status']; //通过用户来查询是否存在父级了 // $parent_id=Db::name('user')->field('parent_id')->find($_POST['id']); // if($parent_id){ // $this->error('已存在该上级!'); // } //通过输入的parent_id判断是否存在这个人。 $parentId = isset($_POST['parent_id'])? $_POST['parent_id'] : 0; if($parentId){ $parent_result=Db::name('user')->find($parentId); if(!$parent_result){ $this->error('不存在该上级用户!'); } $user['parent_id']=$parentId; } //用户详情的 $userinfo['wechat_code']=$_POST['weixin_num']; $userinfo['height'] = $_POST['height']; $userinfo['weight'] = $_POST['weight']; $userinfo['salary'] = $_POST['salary']; $userinfo['education'] = $_POST['education']; $userinfo['occupation'] = $_POST['position1']; $userinfo['province'] = $_POST['province']; $userinfo['city'] = $_POST['city']; $userinfo['district'] = $_POST['district']; $userinfo['home_province'] = $_POST['home_province']; $userinfo['home_city'] = $_POST['home_city']; $userinfo['home_district'] = $_POST['home_district']; $userinfo['married'] = $_POST['married']; Db::startTrans(); $result = DB::name('user')->where('id',$_POST['id'])->update($user); if ($result !== false) { if(Db::name('user_profile')->where('userid',$_POST['id'])->value('id')){ $userpro_result=Db::name('user_profile')->where('userid',$_POST['id'])->update($userinfo); }else{ $userinfo['userid'] = $_POST['id']; $userpro_result=Db::name('user_profile')->insertGetId($userinfo); } if($userpro_result !== false){ Db::commit(); $this->success("保存成功!",'/user/admin_index/index'); }else{ Db::rollback(); $this->error("保存失败!"); } } else { Db::rollback(); $this->error("保存失败!"); } } } } /** * 本站用户拉黑 * @adminMenu( * 'name' => '本站用户拉黑', * 'parent' => 'index', * 'display'=> false, * 'hasView'=> false, * 'order' => 10000, * 'icon' => '', * 'remark' => '本站用户拉黑', * 'param' => '' * ) */ public function ban() { $doban=input('doban'); if(isset($doban)){ $id = input('param.id', 0, 'intval'); //判断冻结原因不能为空 if ($id) { $result = Db::name("user")->where(["id" => $id, "user_type" => 2])->setField(array('user_status'=>0,'freezing'=>input('freezing'),'freezing_choose'=>input('freezing_choose'))); if ($result) { //发送给客户具体冻结的原因。 // $this->success("会员冻结成功!", "adminIndex/index"); echo 1;die; } else { //$this->error('会员冻结失败,会员不存在,或者是管理员!'); echo 0;die; } } else { // $this->error('数据传入失败!'); echo 0;die; } }else{ $this->assign('id',input('id')); return $this->fetch('ban'); } } /** * 本站用户拉黑 * @adminMenu( * 'name' => '本站用户拉黑', * 'parent' => 'index', * 'display'=> false, * 'hasView'=> false, * 'order' => 10000, * 'icon' => '', * 'remark' => '本站用户拉黑', * 'param' => '' * ) */ public function bant() { $doban=input('dobant'); if(isset($doban)){ $param = $this->request->param(); if (isset($param['id'])) { //通过id来获取举报页面 // Db::startTrans(); $result=Db::name('complain')->where('id',$param['id'])->find(); // var_dump($result);die; if($result){ $result['freezing_choose']=$param['freezing_choose']; //进行奖励 $siteInfo = cmf_get_site_info(); if ($result) { Db::startTrans(); //冻结被举报人 $userresult2=Db::name('user')->where('id',$result['c_uid'])->update(['user_status'=>0,'freezing'=>$result['remark']]); if($userresult2){ //奖励举报人爱心,并且发送模板消息 $result3=Db::name('user')->where('id',$result['uid'])->setInc('redheart',$siteInfo['complain_award_redheart']); if($result3){ //举报人的openid $memberInfo = MemberModel::getInfo(['id'=>$result['uid']],''); //被举报人的openid wechat_code $memberInfoc = MemberModel::getInfo(['id'=>$result['c_uid']],''); $wechat_result=Db::name('user_profile')->field('wechat_code')->where('userid',$result['c_uid'])->find(); // 推送审核信息 $result['remark'] $openid = isset($memberInfo['openid'])? $memberInfo['openid'] : ''; if ($openid) { $realname = isset($memberInfo['real_name']) ? $memberInfo['real_name'] : ''; $checkTime = date('Y.m.d H:i'); // $remark = "审核成功!您的举报的用户{$memberInfoc['user_nickname']}已经通过审核!\n\n审核时间:\t{$checkTime}"; $remark = "脱单需主动,交友需真诚!\n你举报的用户已被冻结,奖励你爱心{$siteInfo['complain_award_redheart']}个"; $title ="尊敬的南宁单身青年用户,您举报的用户经平台核实已审核通过,请谨慎与该用户联系\n被举报用户:\t{$memberInfoc['user_nickname']} (昵称)\n对方的微信号: \t{$wechat_result['wechat_code']}\n申请时间:\t{$checkTime}"; $params = [ 'title' => $title, 'remark' => $remark, 'type' => 'auth', 'keywords' => [ 'keyword1' => [ 'value' => "举报用户", 'color' => '#173177', ], 'keyword2' => [ 'value' =>$result3==true? '已审核' : '审核失败', 'color' => '#173177', ] ] // 'url' => $status==2? url('/weixin/match/index', '', '', true) : url('/weixin/auth/' . $scene, '', '', true), ]; Wechat::sendTplMsg($openid, $params); } //如同是已经冻结了就不需要发模板信息给被举报人了 // if ($memberInfoc['user_status']!=0) { //推送被举报人信息 $openidc = isset($memberInfoc['openid'])? $memberInfoc['openid'] : ''; if ($openidc) { // $realname = isset($memberInfo['real_name']) ? $memberInfo['real_name'] : ''; $checkTime = date('Y.m.d H:i'); $remark = "脱单需主动,交友需真诚!"; $params = [ 'title' =>"尊敬的{$memberInfoc['user_nickname']}用户,由于您的账号被多人举报经平台审核,已经将你的账号冻结,若有疑问请联系平台客服\n\n举报原因:\t{$result['remark']}", 'remark' => $remark, 'type' => 'auth', 'keywords' => [ 'keyword1' => [ 'value' => "举报反馈", 'color' => '#173177', ], 'keyword2' => [ 'value' =>$result3==true? '已审核' : '审核失败', 'color' => '#173177', ] ] // 'url' => $status==2? url('/weixin/match/index', '', '', true) : url('/weixin/auth/' . $scene, '', '', true), ]; Wechat::sendTplMsg($openidc, $params); } // } }else{ Db::rollback(); echo 0;die; } Db::commit(); echo 1;die; }else{ Db::rollback(); echo 0;die; } //发送给客户具体冻结的原因。 // $this->success("会员冻结成功!", "adminIndex/index"); // echo 1;die; } else { //$this->error('会员冻结失败,会员不存在,或者是管理员!'); echo 0;die; } } else { // $this->error('数据传入失败!'); echo 0;die; } } }else{ $this->assign('id',input('id')); $this->assign('uid',input('uid')); $this->assign('c_uid',input('cuid')); return $this->fetch('bant'); } } /** * 本站用户启用 * @adminMenu( * 'name' => '本站用户启用', * 'parent' => 'index', * 'display'=> false, * 'hasView'=> false, * 'order' => 10000, * 'icon' => '', * 'remark' => '本站用户启用', * 'param' => '' * ) */ public function cancelBan() { // $openid=Db::name('user')->field('openid')->where('id',$id)->find();echo $openid;die(); $id = input('param.id', 0, 'intval'); if ($id) { Db::startTrans(); $result=Db::name("user")->where(["id" => $id, "user_type" => 2])->setField('user_status', 1); if($result){ // $complain=Db::name('complain')->field('status')->where('c_uid',$id)->find(); // if($complain['status']!=3){ Db::name("complain")->where(['c_uid'=>$id])->update(['status'=>3]); // if($result2){ $open_result=Db::name('user')->field('openid')->where('id',$id)->find(); // 推送审核信息 $result['remark'] $openid = $open_result['openid']; if ($openid) { $checkTime = date('Y.m.d H:i'); // $remark = "审核成功!您的举报的用户{$memberInfoc['user_nickname']}已经通过审核!\n\n审核时间:\t{$checkTime}"; $remark = "脱单需主动,交友需真诚!"; $title ="恭喜!! 尊敬的南宁单身青年用户,您的账号已经被启用。\n申请时间:\t{$checkTime}"; $params = [ 'title' => $title, 'remark' => $remark, 'type' => 'auth', 'keywords' => [ 'keyword1' => [ 'value' => "重新启用", 'color' => '#173177', ], 'keyword2' => [ 'value' =>'启用成功', 'color' => '#20c108', ] ] // 'url' => $status==2? url('/weixin/match/index', '', '', true) : url('/weixin/auth/' . $scene, '', '', true), ]; Wechat::sendTplMsg($openid, $params); } else{ Db::rollback(); $this->error('会员启用失败!!'); } Db::commit(); // }else{ // Db::rollback(); // $this->error('会员启用失败0!'); // } // } // Db::commit(); }else{ Db::rollback(); $this->error('数据传入失败1!'); } $this->success("会员启用成功0!", ''); } else { $this->error('会员启用失败2!'); } } /** * 批量删除 */ public function del() { $params = input(); $id = isset($params['id']) ? $params['id'] : 0; if (empty($id)) { $this->error('请先选择操作项!'); } $id = is_array($id) ? implode(',', $id) : $id; if (Db::name('user')->where(['id' => ['in', $id]])->update(['is_del'=>1])) { $this->success("批量删除成功!", ''); } else { $this->error('批量删除失败!'); } } /* * 过滤昵称的特效字符 */ public function filterEmoji($str) { $str = preg_replace_callback( '/./u', function (array $match) { return strlen($match[0]) >= 4 ? '' : $match[0]; }, $str); return $str; } /* * PHPExcel导出用户列表 */ public function export() { if(session('ADMIN_ID')!=1){ $this->error('你不是管理员不能具备导出功能!'); } $PHPExcel = new \PHPExcel(); $PHPSheet = $PHPExcel->getActiveSheet(); //获得当前活动sheet的操作对象 $PHPSheet->setTitle('会员列表'); /* 给当前sheet表设置名称及表头 */ $PHPSheet->setCellValue('A1', '账号'); $PHPSheet->setCellValue('B1', '昵称'); $PHPSheet->setCellValue('C1', '年份'); $PHPSheet->setCellValue('D1', '身高'); $PHPSheet->setCellValue('E1', '学历'); $PHPSheet->setCellValue('F1', '职位'); $PHPSheet->setCellValue('G1', '手机号'); $PHPSheet->setCellValue('H1', '微信号'); $where = array('user_type' => 2); // $params = session('search'); var_dump($params);die(); // $uid = isset($params['uid']) ? $params['uid'] : 0; // $keyword = isset($params['keyword']) ? $params['keyword'] : '';$keyword="eerterter"; // if ($uid) { // $where['uid'] = $uid; // } $uid=input('uid'); $keyword=input('keyword'); $field = 'u.id,u.user_login,u.user_nickname,u.birthday,u.real_name,u.mobile,up.height,up.education,u.weixin_num,up.occupation,up.wechat_code'; $dataList = Db::name('user') ->alias('u') ->join('user_profile up','up.userid=u.id','left') ->where($where) ->where(function ($query) use ($keyword,$uid) { $query->where('u.openid', 'not in',''); if(input('u')==2){ $query->where('u.is_vip',1); }else if(input('u')==3){ $query->where('u.user_status',0); }else if(input('u')==4){ $query->where('u.is_screen',1); }else if(input('u')==5){ $query->where('u.user_status',-1); }else{ $query->where('u.is_vip',0); } if($uid){ $query->where('u.id',$uid); } if ($keyword) { $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%"); } }) ->field($field) ->order("u.create_time DESC") ->select(); //echo Db::name('user')->getLastSql();die; foreach ($dataList as $key => $item) { $key += 2; $PHPSheet->setCellValue('A' . $key, $item['user_login']); $PHPSheet->setCellValue('B' . $key, $this->filterEmoji($item['user_nickname'])); $PHPSheet->setCellValue('C' . $key, date('Y-m-d ', $item['birthday'])); $PHPSheet->setCellValue('D' . $key, $item['height']); $PHPSheet->setCellValue('E' . $key, $item['education']); $PHPSheet->setCellValue('F' . $key, $item['occupation']); $PHPSheet->setCellValue('G' . $key, $item['mobile']); $PHPSheet->setCellValue('H' . $key, $item['wechat_code']); // switch ($item['user_status']) { // case 0: // $status = '冻结'; // break; // case 1: // $status = '开启'; // break; // default: // $status = '无效'; // break; // } // $PHPSheet->setCellValue('I' . $key, $status); } $filename = "用户列表" . date('YmdHis') . ".xls"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header("Content-Type:application/force-download"); header("Content-Type:application/vnd.ms-execl"); header("Content-Type:application/octet-stream"); header("Content-Type:application/download");; header('Content-Disposition:attachment;filename=' . $filename . ''); header("Content-Transfer-Encoding:binary"); $PHPWriter = \PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5'); $PHPWriter->save('php://output'); } /* * 爱心充值显示 */ public function accountadd() { $params = input(); $id = isset($params['id']) ? $params['id'] : 0; if (empty($id)) { $this->error('请先选择操作项!'); } //通过id来查询用户姓名 $user = DB::name('user')->where("id", $id)->find(); $this->assign($user); return $this->fetch(); } /* * 爱心充值添加 * */ public function accountAddpost() { if ($this->request->isPost()) { $data = $this->request->param(); $accountlogModel = new AccountLogModel(); $result = $this->validate($data, 'AccountLog'); if ($result !== true) { $this->error($result); } $data['user_id'] = $data['user_id']; //用户id $data['remark'] = $data['remark']; //备注 $data['type'] = 5; //表示后台充值 $data['status'] = 2; //已完成 $accountlogModel->allowField(true)->save($data); //变更用户表的redheart $user=Db::name('user') ->where('id',$data['user_id']) ->find(); $data['redheart'] = $user['redheart'] + $data['money']; Db::name('user')->where('id', $data['user_id']) // ->strict(false) ->field('redheart') ->update($data); // file_put_contents('abc.txt', Db::name('user')->getLastSql()); $this->success("充值成功!", '/admin/love/index'); } } /* * 会员相亲详细 * */ public function profile(){ $user_profile = Db::name('user_profile') ->where('userid',input('id')) ->find() // ->each(function($item,$key){ // $item['photolists']=$item['photolist']; // }) ; // var_dump($user_profile); if(!empty($user_profile)){ $user_profile['photolists']=explode(',', $user_profile['photolist']); } //var_dump($user_profile);die; $this->assign('id',input('id')); $this->assign('profile',$user_profile); return $this->fetch('editprofile'); } /** * 会员匹配信息 * */ public function profilepost(){ if ($this->request->isPost()) { $data=$this->request->param(); $profilevalidate = new UserProfileValidate(); $result = $profilevalidate->scene('info')->check($this->request->param()); if ($result !== true) { // 验证失败 输出错误信息 $this->error($profilevalidate->getError()); } else { //var_dump($_POST);die; $result2 = DB::name('user_profile')->update($_POST); //echo Db::name('user_profile')->getLastSql();die(); if ($result2 !== false) { $this->success("保存成功!",'/user/admin_index/index'); } else { $this->error("保存失败!"); } } } } /** * 会员身份证验证 * */ public function idpost(){ if ($this->request->isPost()) { $data=$this->request->param(); //$this->request->param() 和$_POST[] 一样的 // var_dump($this->request->post('passbtn', TRUE));die; if($this->request->post('passbtn',true)=='pass'){ //审核通过操作 if(!empty($_POST['idcard_fail'])){ $this->error('失败原因不要填写!'); } $result=Member::checkAuth($data['id'],2,'idcard','身份证等信息符合'); if(is_array($result)){ //顺便更新一下注册时间 2020 10-22 DB::name('user')->where('id',input('id'))->update([ "create_time"=>time() ]); $this->success('审核成功!'); } else{ $this->error(lang($result)); } } else if($this->request->post('passbtn',true)=='nopass'){ if($_POST['idcard_fail']=='' || $_POST['idcard_fail']==null){ $this->error('身份证认证失败原因不能为空!'); } //审核不通过操作 $result=Member::checkAuth($data['id'],3,'idcard',$_POST['idcard_fail']); if(is_array($result)){ $this->success('审核不通过成功!'); } else{ $this->error(lang($result)); } }else{ //保持操作 $profilevalidate = new UserProfileValidate(); $result = $profilevalidate->scene('info')->check($this->request->param()); if ($result !== true) { // 验证失败 输出错误信息 $this->error($profilevalidate->getError()); } else { //var_dump($_POST);die; //先修改用户表 $result1=DB::name('user')->where('id',input('id'))->update([ "real_name"=>input('real_name') ]); if ($result1!==false) { $result2 = DB::name('user_profile')->where('userid',$data['id']) ->update([ "idcard"=>input('idcard'), 'idcard_type'=>input('idcard_type') ]); // echo Db::name('user_profile')->getLastSql();die(); if ($result2 !== false) { $this->success("保存成功!",'/user/admin_index/index'); } else { $this->error("保存失败!"); } }else{ $this->error("保存失败!"); } } } }else{ $id = $this->request->param('id', 0, 'intval'); //读取用户表和用户资料表的信息出来 $join = [ ['user_profile up', 'u.id = up.userid'] ]; $userresult=Db::name('user')->field('u.real_name,up.idcard,up.idcard_check,up.idcard_online_check,up.idcard_fail,up.front_idcard,up.back_idcard,up.idcard_type') ->alias('u')->join($join) ->where('u.id',$id) ->find(); $this->assign('id',$id); $this->assign('userresult',$userresult); return $this->fetch('editID'); } } public function docomplain(){ $data = $this->request->param(); session('search',[ 'uid' => isset($data['uid'])? intval($data['uid']) : 0, 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '', ]); // 添加返回历史修改 by wesmiler 2020-02-16 $history = isset($data['history'])? intval($data['history']) : 0; if($history){ $data = session('user_search'); }else{ session('user_search', $data); } // 修改 end //var_dump($data);die; $list = Db::name('complain')->field('u.id as ids,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,u.last_login_time,c.id,c.type,c.c_uid, c.remark,c.image,c.created_time,c.status') ->alias('c') ->join('user u','u.id=c.uid','left') ->where(function (Query $query) use($data){ $query->where('u.user_type', 2); $query->where('u.openid', 'not in',''); $query->where('c.status', 2); // //代表是否付费定制 // ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0); // //代表是否冻结 // if($this->request->action()!='userlogout' && $this->request->param('u')!=5){ // ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1); // } // //代表是否筛选 // ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0); // //代表是否注销 // if($this->request->action()!='userban' && $this->request->param('u')!=3){ // ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1); // } // $this->screenpublic(); }) //待审核 ->order("u.create_time DESC") ->paginate(10,false,['query'=>request()->param()]) ->each(function($item,$key){ //查询出报名人数,通过活动id $item['user_nicknamet']=Db::name('user') ->where(['id'=> $item['c_uid']]) ->field('user_nickname,user_status') ->find(); ; return $item; }) ; // var_dump($list);die; //echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); return $this->fetch('complain'); } /** * 职位认证 * */ public function companypost(){ if ($this->request->isPost()) { $data=$this->request->param(); if($this->request->post('passbtn',true)=='pass'){ //审核通过 if(!empty($_POST['position_fail'])){ $this->error('失败原因不要填写!'); } $result=Member::checkAuth($data['id'],2,'position','职位认证等信息符合'); if(is_array($result)){ $this->success('审核成功!'); } else{ $this->error(lang($result)); } }else if($this->request->post('passbtn',true)=='nopass'){ //审核不通过 if($_POST['position_fail']=='' || $_POST['position_fail']==null){ $this->error('职位认证失败原因不能为空!'); } $result=Member::checkAuth($data['id'],3,'position',$_POST['position_fail']); if(is_array($result)){ $this->success('审核不通过成功!'); } else{ // / $this->error($result); $this->error(lang($result)); } }else{ $profilevalidate = new UserProfileValidate(); $result = $profilevalidate->scene('info')->check($this->request->param()); if ($result !== true) { // 验证失败 输出错误信息 $this->error($profilevalidate->getError()); } else { //var_dump($_POST);die; $result2 = DB::name('user_profile')->where('userid',$data['id'])->update([ "company"=>input("company"), "occupation"=>input("occupation"), "position_type"=>input("position_type") ]); // echo Db::name('user_profile')->getLastSql();die(); if ($result2 !== false) { $this->success("保存成功!",'/user/admin_index/index'); } else { $this->error("保存失败!"); } } } }else{ $id = $this->request->param('id', 0, 'intval'); //读取用户表和用户资料表的信息出来 $companyresult=Db::name('user_profile')->field('company,occupation,position_img,position_fail,position_type,position_check') ->where('userid',$id) ->find(); $this->assign('id',$id); $this->assign('userresult',$companyresult); return $this->fetch('editcompany'); } } /** * 学历认证 * */ public function schoolpost(){ if ($this->request->isPost()) { $data=$this->request->param(); if($this->request->post('passbtn',true)=='pass'){ //审核通过 if(!empty($_POST['education_fail'])){ $this->error('失败原因不要填写!'); } $result=Member::checkAuth($data['id'],2,'education','学历认证等信息符合'); if(is_array($result)){ $this->success('审核成功!'); } else{ $this->error(lang($result)); } }else if($this->request->post('passbtn',true)=='nopass'){ //审核不通过 if($_POST['education_fail']=='' || $_POST['education_fail']==null){ $this->error('学历认证失败原因不能为空!'); } $result=Member::checkAuth($data['id'],3,'education',$_POST['education_fail']); if(is_array($result)){ $this->success('审核不通过成功!'); } else{ $this->error(lang($result)); } }else{ $profilevalidate = new UserProfileValidate(); $result = $profilevalidate->scene('info')->check($this->request->param()); if ($result !== true) { // 验证失败 输出错误信息 $this->error($profilevalidate->getError()); } else { //var_dump($_POST);die; $result2 = DB::name('user_profile')->where('userid',$data['id'])->update([ "graduate"=>input("graduate"), "education"=>input("education"), "education_type"=>input("education_type"), ]); // echo Db::name('user_profile')->getLastSql();die(); if ($result2 !== false) { $this->success("保存成功!",'/user/admin_index/index'); } else { $this->error("保存失败!"); } } } }else{ $id = $this->request->param('id', 0, 'intval'); //读取用户表和用户资料表的信息出来 $schoolresult=Db::name('user_profile')->field('graduate,education,education_fail,education_type,education_code,education_img,education_check') ->where('userid',$id) ->find(); $this->assign('id',$id); $this->assign('userresult',$schoolresult); return $this->fetch('editschool'); } } //条件筛选 // public function screen(){ // return $this->fetch(); // } // //成为VIP付费定制 public function tovip(){ $param = $this->request->param(); if (isset($param['ids']) && isset($param["yes"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['is_vip' => 1]); $this->success("成为付费会员成功!", '/user/admin_index/custom'); } if (isset($_POST['ids']) && isset($param["no"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['is_vip' => 0]); $this->success("取消付费会员成功!", ''); } } //成为单身推荐和取消单身推荐 public function totuijian(){ $param = $this->request->param(); if (isset($param['ids']) && isset($param["yes"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['is_tuijian' => 1]); $this->success("成为单身推荐成功!"); } if (isset($_POST['ids']) && isset($param["no"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['is_tuijian' => 0]); $this->success("取消单身推荐成功!", '/user/Recommend/index'); } } //注销用户 public function tozhuxiao(){ $param = $this->request->param(); if (isset($param['ids']) && isset($param["yes"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['user_status' => -1]); $this->success("注销成功!"); } if (isset($_POST['ids']) && isset($param["no"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['user_status' => 1]); $this->success("取消注销成功!", '/user/Recommend/index'); } } //成为筛选用户和取消筛选用户 public function toscreen(){ $param = $this->request->param(); if (isset($param['ids']) && isset($param["yes"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['is_screen' => 1]); $this->success("成为筛选用户成功!"); } if (isset($_POST['ids']) && isset($param["no"])) { $ids = $this->request->param('ids/a'); Db::name('user')->where('id', 'in', $ids)->update(['is_screen' => 0]); $this->success("取消筛选用户成功!", url('/user/Admin_index/screen',['u'=>4])); } } //付费定制显示 public function custom(){ $data = $this->request->param(); $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile, up.idcard_check,up.position_check,up.education_check,last_login_time') ->alias('u') ->join('user_profile up','u.id=up.userid','left') ->where(function (Query $query) { $query->where('u.user_type', 2); $query->where('u.is_vip', 1); $data = $this->request->param(); if (!empty($data['uid'])) { $query->where('u.id', intval($data['uid'])); } if (!empty($data['keyword'])) { $keyword = $data['keyword']; $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%"); } //年龄区间查询 if(!empty($data['age1']) && !empty($data['age2'])){ $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and'); $query->whereNotNull('u.birthday'); } // //只有第一个年龄的情况下 if(!empty($data['age1']) && empty($data['age2'])){ $birthday = $data['age1']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null "); } // //只有第二个年龄的情况下 if(empty($data['age1']) && !empty($data['age2'])){ $birthday = $data['age2']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null "); } //身高区间查询 if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',['>',input('height')],['<',input('heightt')],'and'); } //身高第一个查找 if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){ $query->where('up.height',input('height')); } //身高第二个查找 if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',input('heightt')); } //学历 if((!empty(input('education')) && input('education')!='none') ){ $query->where('up.education',input('education')); } //职位 if((!empty(input('occupation')) && input('occupation')!='none') ){ $query->where('up.occupation',input('occupation')); } //收入 if((!empty(input('salary')) && input('salary')!='none') ){ $query->where('up.salary',input('salary')); } //资产 if((!empty(input('property')) && input('property')!='none') ){ $query->where('up.property',input('property')); } //籍贯 if((!empty(input('home_city')) && input('home_city')!='none') ){ $query->where('up.home_city','like','%'.input('home_city').'%'); } //居住地 if((!empty(input('district')) && input('district')!='none') ){ $query->where('up.district','like','%'.input('district').'%'); } //婚姻状况 if((!empty(input('married')) && input('married')!='none') ){ $query->where('up.married',input('married')); } }) //待审核 ->order("u.create_time DESC") ->paginate(10,false,['query'=>request()->param()]); //echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); // 渲染模板输出 return $this->fetch('index'); } //冻结用户显示 public function userban(){ $data = $this->request->param(); $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at, up.idcard_check,up.position_check,up.education_check,last_login_time') ->alias('u') ->join('user_profile up','u.id=up.userid','left') ->where(function (Query $query) { $query->where('u.user_type', 2); $query->where('u.user_status', 0); $data = $this->request->param(); if (!empty($data['uid'])) { $query->where('u.id', intval($data['uid'])); } if (!empty($data['keyword'])) { $keyword = $data['keyword']; $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%"); } //年龄区间查询 if(!empty($data['age1']) && !empty($data['age2'])){ $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and'); $query->whereNotNull('u.birthday'); } // //只有第一个年龄的情况下 if(!empty($data['age1']) && empty($data['age2'])){ $birthday = $data['age1']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } // //只有第二个年龄的情况下 if(empty($data['age1']) && !empty($data['age2'])){ $birthday = $data['age2']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } //身高区间查询 if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',['>',input('height')],['<',input('heightt')],'and'); } //身高第一个查找 if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){ $query->where('up.height',input('height')); } //身高第二个查找 if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',input('heightt')); } //学历 if((!empty(input('education')) && input('education')!='none') ){ $query->where('up.education',input('education')); } //职位 if((!empty(input('occupation')) && input('occupation')!='none') ){ $query->where('up.occupation',input('occupation')); } //收入 if((!empty(input('salary')) && input('salary')!='none') ){ $query->where('up.salary',input('salary')); } //资产 if((!empty(input('property')) && input('property')!='none') ){ $query->where('up.property',input('property')); } //籍贯 if((!empty(input('home_city')) && input('home_city')!='none') ){ $query->where('up.home_city','like','%'.input('home_city').'%'); } //居住地 if((!empty(input('district')) && input('district')!='none') ){ $query->where('up.district','like','%'.input('district').'%'); } //婚姻状况 if((!empty(input('married')) && input('married')!='none') ){ $query->where('up.married',input('married')); } }) //待审核 ->order("u.updated_at DESC") ->paginate(10,false,['query'=>request()->param()]); //echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); // 渲染模板输出 return $this->fetch('index'); } /** *筛选用户 * */ public function screen(){ $data = $this->request->param(); $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile, up.idcard_check,up.position_check,up.education_check,last_login_time') ->alias('u') ->join('user_profile up','u.id=up.userid','left') ->where(function (Query $query) { $query->where('u.user_type', 2); $query->where('u.is_screen', 1); //是否是筛选 $data = $this->request->param(); if (!empty($data['uid'])) { $query->where('u.id', intval($data['uid'])); } if (!empty($data['keyword'])) { $keyword = $data['keyword']; $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%"); } //年龄区间查询 if(!empty($data['age1']) && !empty($data['age2'])){ $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and'); $query->whereNotNull('u.birthday'); } // //只有第一个年龄的情况下 if(!empty($data['age1']) && empty($data['age2'])){ $birthday = $data['age1']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } // //只有第二个年龄的情况下 if(empty($data['age1']) && !empty($data['age2'])){ $birthday = $data['age2']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } //身高区间查询 if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',['>',input('height')],['<',input('heightt')],'and'); } //身高第一个查找 if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){ $query->where('up.height',input('height')); } //身高第二个查找 if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',input('heightt')); } //学历 if((!empty(input('education')) && input('education')!='none') ){ $query->where('up.education',input('education')); } //职位 if((!empty(input('occupation')) && input('occupation')!='none') ){ $query->where('up.occupation',input('occupation')); } //收入 if((!empty(input('salary')) && input('salary')!='none') ){ $query->where('up.salary',input('salary')); } //资产 if((!empty(input('property')) && input('property')!='none') ){ $query->where('up.property',input('property')); } //籍贯 if((!empty(input('home_city')) && input('home_city')!='none') ){ $query->where('up.home_city','like','%'.input('home_city').'%'); } //居住地 if((!empty(input('district')) && input('district')!='none') ){ $query->where('up.district','like','%'.input('district').'%'); } //婚姻状况 if((!empty(input('married')) && input('married')!='none') ){ $query->where('up.married',input('married')); } }) //待审核 ->order("u.create_time DESC") ->paginate(10,false,['query'=>request()->param()]); //echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); // 渲染模板输出 return $this->fetch('index'); } //显示备注信息 public function showbeizhu(){ $dobeizhu=input('dobeizhu'); if(isset($dobeizhu)){ $id = input('param.id', 0, 'intval'); //判断备注原因不能为空 if ($id) { $result = Db::name("user")->where(["id" => $id, "user_type" => 2])->setField(array('remark'=>input('remark'))); if ($result) { echo 1;die; } else { echo 0;die; } } else { echo 0;die; } }else{ //通过用户id来进行显示备注 $result=Db::name('user')->field('remark')->where('id',input('id'))->find(); $this->assign('remark',$result['remark']); $this->assign('id',input('id')); return $this->fetch('beizhu'); } } //显示注销用户 public function userlogout(){ $data = $this->request->param(); $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,up.idcard, up.idcard_check,up.position_check,up.education_check,last_login_time') ->alias('u') ->join('user_profile up','u.id=up.userid','left') ->where(function (Query $query) { $query->where('u.user_type', 2); $query->where('u.user_status', -1); $data = $this->request->param(); if (!empty($data['uid'])) { $query->where('u.id', intval($data['uid'])); } if (!empty($data['keyword'])) { $keyword = $data['keyword']; $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%"); } //年龄区间查询 if(!empty($data['age1']) && !empty($data['age2'])){ $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and'); $query->whereNotNull('u.birthday'); } // //只有第一个年龄的情况下 if(!empty($data['age1']) && empty($data['age2'])){ $birthday = $data['age1']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } // //只有第二个年龄的情况下 if(empty($data['age1']) && !empty($data['age2'])){ $birthday = $data['age2']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } //身高区间查询 if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',['>',input('height')],['<',input('heightt')],'and'); } //身高第一个查找 if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){ $query->where('up.height',input('height')); } //身高第二个查找 if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',input('heightt')); } //学历 if((!empty(input('education')) && input('education')!='none') ){ $query->where('up.education',input('education')); } //职位 if((!empty(input('occupation')) && input('occupation')!='none') ){ $query->where('up.occupation',input('occupation')); } //收入 if((!empty(input('salary')) && input('salary')!='none') ){ $query->where('up.salary',input('salary')); } //资产 if((!empty(input('property')) && input('property')!='none') ){ $query->where('up.property',input('property')); } //籍贯 if((!empty(input('home_city')) && input('home_city')!='none') ){ $query->where('up.home_city','like','%'.input('home_city').'%'); } //居住地 if((!empty(input('district')) && input('district')!='none') ){ $query->where('up.district','like','%'.input('district').'%'); } //婚姻状况 if((!empty(input('married')) && input('married')!='none') ){ $query->where('up.married',input('married')); } }) //待审核 ->order("u.updated_at DESC") ->paginate(10,false,['query'=>request()->param()]); //echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); // 渲染模板输出 return $this->fetch('index'); } //清除身份证提交 public function touserlogout(){ $param = $this->request->param(); if (isset($param['ids']) && isset($param["yes"])) { $ids = $this->request->param('ids/a'); Db::name('user_profile')->where('userid', 'in', $ids)->update(['idcard' => '','idcard_check'=>0]); // echo Db::name('user_profile')->getLastSql();die(); $this->success("清理身份信息成功!"); } } //vip充值用户显示 public function viprechange(){ $data = $this->request->param(); session('search',[ 'uid' => isset($data['uid'])? intval($data['uid']) : 0, 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '', ]); // 添加返回历史修改 by wesmiler 2020-02-16 $history = isset($data['history'])? intval($data['history']) : 0; if($history){ $data = session('user_search'); }else{ session('user_search', $data); } // 修改 end $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,u.last_login_time,u.vip_auth,u.vip_expire,up.idcard, up.idcard_check,up.position_check,rl.money,rl.pay_money,up.education_check') ->alias('u') ->join('user_profile up','u.id=up.userid','left') ->join('user_recharge_log rl','rl.user_id=u.id','left') ->where(function (Query $query) use($data){ $query->where('u.user_type', 2); $query->where('u.openid', 'not in',''); $query->where('rl.type', 4); $query->where('rl.status', 2); $query->where('u.vip_auth', 1); $this->screenpublic(); }) //待审核 ->order("rl.created_at DESC") ->paginate(10,false,['query'=>request()->param()]); // echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); // 渲染模板输出 return $this->fetch('index'); } //人工牵线 public function pullwire(){ $this->fetch(); } //下架处理 public function unshelf(){ $data=$this->request->param(); $com_result=Db::name('complain')->field('c_uid')->where('id',$data['ids'])->find(); if($data){ Db::startTrans(); $result1=Db::name('complain')->where("c_uid",$com_result['c_uid'])->update(['status'=>1]); if($result1){ $result2=Db::name('user')->where('id',$data['c_uid'])->update(['user_status'=>1]); if($result2){ Db::commit(); $this->success("下架成功!", url('/user/Admin_index/complain')); }else{ Db::rollback(); $this->error("下架失败!"); } }else{ Db::rollback(); $this->error("下架失败!!"); } } } //进行显示反馈显示用户。 public function feedback(){ $list=Db::name('advices') ->alias('ad') // ->where('status',1) ->order("ad.created_time DESC") ->paginate(10,false,['query'=>request()->param()]) ->each(function($item,$key){ //查询出被举报名人昵称和状态。 $item['user_nicknamet']=Db::name('user') ->where(['id'=> $item['uid']]) ->field('user_nickname,user_status') ->find(); ; return $item; }) ; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); return $this->fetch('feedback'); } //处理审核 public function feedbackedit(){ $result=Db::name('advices')->where("id",input('id'))->update(['status'=>2]); if($result){ $this->success("审核处理成功!"); }else{ $this->error("审核处理失败!"); } } //投诉举报页面 public function complain(){ $data = $this->request->param(); session('search',[ 'uid' => isset($data['uid'])? intval($data['uid']) : 0, 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '', ]); // 添加返回历史修改 by wesmiler 2020-02-16 $history = isset($data['history'])? intval($data['history']) : 0; if($history){ $data = session('user_search'); }else{ session('user_search', $data); } // 修改 end //var_dump($data);die; $list = Db::name('complain')->field('u.id as ids,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,u.last_login_time,c.id,c.type,c.c_uid, c.remark,c.image,c.created_time,c.status') ->alias('c') ->join('user u','u.id=c.uid','left') ->where(function (Query $query) use($data){ $query->where('u.user_type', 2); $query->where('u.openid', 'not in',''); // $query->where('c.status', 1); //代表是否付费定制 ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0); //代表是否冻结 if($this->request->action()!='userlogout' && $this->request->param('u')!=5){ ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1); } //代表是否筛选 ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0); //代表是否注销 if($this->request->action()!='userban' && $this->request->param('u')!=3){ ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1); } $this->screenpublic(); }) //待审核 ->order("c.created_time DESC") ->paginate(10,false,['query'=>request()->param()]) ->each(function($item,$key){ //查询出被举报名人昵称和状态。 $item['user_nicknamet']=Db::name('user') ->where(['id'=> $item['c_uid']]) ->field('user_nickname,user_status') ->find(); ; return $item; }) ; // var_dump($data);die; //echo Db::name('user')->getLastSql();die; // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); return $this->fetch('complain'); } public function screenpublic(){ $data = $this->request->param(); if (!empty($data['uid'])) { $query->where('u.id', intval($data['uid'])); } if (!empty($data['keyword'])) { $keyword = $data['keyword']; $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%"); } //年龄区间查询 if(!empty($data['age1']) && !empty($data['age2'])){ $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and'); $query->whereNotNull('u.birthday'); } // //只有第一个年龄的情况下 if(!empty($data['age1']) && empty($data['age2'])){ $birthday = $data['age1']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } // //只有第二个年龄的情况下 if(empty($data['age1']) && !empty($data['age2'])){ $birthday = $data['age2']; $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null "); } //身高区间查询 if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',['>',input('height')],['<',input('heightt')],'and'); } //身高第一个查找 if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){ $query->where('up.height',input('height')); } //身高第二个查找 if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){ $query->where('up.height',input('heightt')); } //学历 if((!empty(input('education')) && input('education')!='none') ){ $query->where('up.education',input('education')); } //职位 if((!empty(input('occupation')) && input('occupation')!='none') ){ $query->where('up.occupation',input('occupation')); } //收入 if((!empty(input('salary')) && input('salary')!='none') ){ $query->where('up.salary',input('salary')); } //资产 if((!empty(input('property')) && input('property')!='none') ){ $query->where('up.property',input('property')); } //籍贯 if((!empty(input('home_city')) && input('home_city')!='none') ){ $query->where('up.home_city','like','%'.input('home_city').'%'); } //居住地 if((!empty(input('district')) && input('district')!='none') ){ $query->where('up.district','like','%'.input('district').'%'); } //婚姻状况 if((!empty(input('married')) && input('married')!='none') ){ $query->where('up.married',input('married')); } } //处理举报用户 public function tohandle(){ $param = $this->request->param(); $siteInfo = cmf_get_site_info(); $id = $param['ids']; if (isset($param['ids'])) { //通过id来获取举报页面 $result=Db::name('complain')->where('id',$param['ids'])->find(); Db::startTrans(); if($result){ //冻结被举报人, //进行奖励 $userresult2=Db::name('user')->where('id',$result['c_uid'])->update(['user_status'=>0,'freezing'=>$result['remark']]); if($userresult2){ $comsel_result=Db::name('complain')->field('uid')->where('c_uid',$result['c_uid'])->select(); foreach ($comsel_result as $key => $value) { $aryuser=$value['uid']; } //奖励举报人爱心,并且发送模板消息,循环多人发送 $result3=Db::name('user')->where('id','in',$aryuser)->setInc('redheart',$siteInfo['complain_award_redheart']); if($result3){ //变成已经处理 $com_result= Db::name("complain")->where(['c_uid'=>$result['c_uid']])->update(['status'=>2]); if($com_result){ //被举报人的openid wechat_code $memberInfoc = MemberModel::getInfo(['id'=>$result['c_uid']],''); $wechat_result=Db::name('user_profile')->field('wechat_code')->where('userid',$result['c_uid'])->find(); //举报人的openid //$memberInfo = MemberModel::getInfo(['id'=>$result['uid']],''); $memberInfo = Db::name('user')->field('openid,real_name')->where('id','in',$aryuser)->select(); foreach ($memberInfo as $values) { // 推送审核信息 $result['remark'] $openid = isset($values['openid'])? $values['openid'] : ''; if ($openid) { $realname = isset($values['real_name']) ? $values['real_name'] : ''; $checkTime = date('Y.m.d H:i'); $remark = "脱单需主动,交友需真诚!\n你举报的用户已被处理,奖励你爱心{$siteInfo['complain_award_redheart']}个"; $title ="尊敬的南宁单身青年用户,您举报的用户经平台核实已审核通过,请谨慎与该用户联系\n被举报用户:\t{$memberInfoc['user_nickname']} (昵称)\n对方的微信号: \t{$wechat_result['wechat_code']}\n申请时间:\t{$checkTime}"; $params = [ 'title' => $title, 'remark' => $remark, 'type' => 'auth', 'keywords' => [ 'keyword1' => [ 'value' => "举报用户", 'color' => '#173177', ], 'keyword2' => [ 'value' =>$result3==true? '已审核' : '审核失败', 'color' => '#173177', ] ] ]; Wechat::sendTplMsg($openid, $params); } } //推送被举报人信息 $openidc = isset($memberInfoc['openid'])? $memberInfoc['openid'] : ''; if ($openidc) { $checkTime = date('Y.m.d H:i'); $remark = "脱单需主动,交友需真诚!"; $params = [ 'title' =>"尊敬的{$memberInfoc['user_nickname']}用户,由于您的账号被多人举报经平台审核,已经将你的账号冻结,若有疑问请联系平台客服\n\n举报原因:\t{$result['remark']}", 'remark' => $remark, 'type' => 'auth', 'keywords' => [ 'keyword1' => [ 'value' => "举报反馈", 'color' => '#173177', ], 'keyword2' => [ 'value' =>$result3==true? '已审核' : '审核失败', 'color' => '#173177', ] ] ]; Wechat::sendTplMsg($openidc, $params); } } }else{ Db::rollback(); $this->error('处理失败!'); } }else{ Db::rollback(); $this->error('处理失败!'); } Db::commit(); $this->success("处理成功!",'/user/admin_index/complain'); } else { Db::rollback(); $this->error('处理失败!'); } }else{ $this->error('处理失败!'); } } }