| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: Powerless < wzxaini9@gmail.com>
- // +----------------------------------------------------------------------
- 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('处理失败!');
-
-
- }
-
-
- }
- }
|