AdminIndexController.php 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: Powerless < wzxaini9@gmail.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\user\controller;
  12. use function AlibabaCloud\Client\value;
  13. use app\user\validate\UserProfileValidate;
  14. use app\admin\validate\UserValidate;
  15. use cmf\controller\AdminBaseController;
  16. use think\Db;
  17. use think\db\Query;
  18. use PHPExcel;
  19. use app\admin\model\AccountLogModel;
  20. use app\admin\model\UserModel;
  21. use app\weixin\service\Member;
  22. use app\weixin\model\Wechat;
  23. use app\weixin\model\Member as MemberModel;
  24. /**
  25. * Class AdminIndexController
  26. * @package app\user\controller
  27. *
  28. * @adminMenuRoot(
  29. * 'name' =>'用户管理',
  30. * 'action' =>'default',
  31. * 'parent' =>'',
  32. * 'display'=> true,
  33. * 'order' => 10,
  34. * 'icon' =>'group',
  35. * 'remark' =>'用户管理'
  36. * )
  37. *
  38. * @adminMenuRoot(
  39. * 'name' =>'用户组',
  40. * 'action' =>'default1',
  41. * 'parent' =>'user/AdminIndex/default',
  42. * 'display'=> true,
  43. * 'order' => 10000,
  44. * 'icon' =>'',
  45. * 'remark' =>'用户组'
  46. * )
  47. */
  48. class AdminIndexController extends AdminBaseController
  49. {
  50. /**
  51. * 后台本站用户列表
  52. * @adminMenu(
  53. * 'name' => '本站用户',
  54. * 'parent' => 'default1',
  55. * 'display'=> true,
  56. * 'hasView'=> true,
  57. * 'order' => 10000,
  58. * 'icon' => '',
  59. * 'remark' => '本站用户',
  60. * 'param' => ''
  61. * )
  62. */
  63. public function index()
  64. {
  65. // $content = hook_one('user_admin_index_view');
  66. // if (!empty($content)) {
  67. // return $content;
  68. // }
  69. $data = $this->request->param();
  70. session('search',[
  71. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  72. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  73. ]);
  74. // 添加返回历史修改 by wesmiler 2020-02-16
  75. $history = isset($data['history'])? intval($data['history']) : 0;
  76. if($history){
  77. $data = session('user_search');
  78. }else{
  79. session('user_search', $data);
  80. }
  81. // 修改 end
  82. //var_dump($data);die;
  83. $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,
  84. up.idcard_check,up.position_check,up.education_check')
  85. ->alias('u')
  86. ->join('user_profile up','u.id=up.userid','left')
  87. ->where(function (Query $query) use($data){
  88. $query->where('u.user_type', 2);
  89. $query->where('u.openid', 'not in','');
  90. //代表是否付费定制
  91. ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  92. //代表是否冻结
  93. if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
  94. ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
  95. }else{
  96. //代表是否筛选
  97. ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
  98. }
  99. //代表是否注销
  100. if($this->request->action()!='userban' && $this->request->param('u')!=3){
  101. ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
  102. }
  103. //$data = $this->request->param();
  104. if (!empty($data['uid'])) {
  105. $query->where('u.id', intval($data['uid']));
  106. }
  107. if (!empty($data['keyword'])) {
  108. $keyword = $data['keyword'];
  109. $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  110. }
  111. //年龄区间查询
  112. if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
  113. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  114. $query->whereNotNull('u.birthday');
  115. }
  116. // //只有第一个年龄的情况下
  117. if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
  118. $birthday = $data['age1'];
  119. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  120. }
  121. // //只有第二个年龄的情况下
  122. if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
  123. $birthday = $data['age2'];
  124. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  125. }
  126. //身高区间查询
  127. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  128. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  129. }
  130. //身高第一个查找
  131. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  132. $query->where('up.height',input('height'));
  133. }
  134. //身高第二个查找
  135. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  136. $query->where('up.height',input('heightt'));
  137. }
  138. //学历
  139. if((!empty(input('education')) && input('education')!='none') ){
  140. $query->where('up.education',input('education'));
  141. }
  142. //职位
  143. if((!empty(input('occupation')) && input('occupation')!='none') ){
  144. $query->where('up.occupation',input('occupation'));
  145. }
  146. //收入
  147. if((!empty(input('salary')) && input('salary')!='none') ){
  148. $query->where('up.salary',input('salary'));
  149. }
  150. //资产
  151. if((!empty(input('property')) && input('property')!='none') ){
  152. $query->where('up.property',input('property'));
  153. }
  154. //家乡
  155. if((!empty(input('home_city')) && input('home_city')!='none') ){
  156. $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
  157. }
  158. //居住地(市)
  159. if((!empty(input('city')) && input('city')!='none') ){
  160. $query->where('up.city','like','%'.input('city').'%');
  161. }
  162. //婚姻状况
  163. if((!empty(input('married')) && input('married')!='none') ){
  164. $query->where('up.married',input('married'));
  165. }
  166. //性别
  167. if((!empty(input('sex')) && input('sex')!='none') ){
  168. $query->where('u.sex',input('sex'));
  169. }
  170. })
  171. //待审核
  172. ->order("u.create_time DESC")
  173. ->paginate(10,false,['query'=>request()->param()]);
  174. // echo Db::name('user')->getLastSql();die;
  175. // 获取分页显示
  176. $page = $list->render();
  177. $this->assign('list', $list);
  178. $this->assign('page', $page);
  179. // 渲染模板输出
  180. return $this->fetch();
  181. }
  182. /**
  183. * 编辑
  184. * @return mixed
  185. * @throws \think\db\exception\DataNotFoundException
  186. * @throws \think\db\exception\ModelNotFoundException
  187. * @throws \think\exception\DbException
  188. */
  189. public function edit(){
  190. //
  191. // $id = $this->request->param('id', 0, 'intval');
  192. // $user = DB::name('user')->where("id", $id)->find();
  193. $data = $this->request->param();
  194. // session('search',[
  195. // 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  196. // 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  197. // ]);
  198. //var_dump($data);die;
  199. $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,
  200. 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')
  201. ->alias('u')
  202. ->join('user_profile up','u.id=up.userid','left')
  203. ->where('u.id', input('id'))
  204. ->where(function (Query $query) {
  205. $query->where('u.user_type', 2);
  206. ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  207. })
  208. ->find();
  209. // var_dump($user);die;
  210. $this->assign($user);
  211. return $this->fetch();
  212. }
  213. /**
  214. * 编辑处理
  215. * @throws \think\Exception
  216. * @throws \think\exception\PDOException
  217. */
  218. public function editPost(){
  219. // $page=$this->request->param;
  220. // echo $page['page'];die();
  221. if ($this->request->isPost()) {
  222. if (empty($_POST['user_pass'])) {
  223. unset($_POST['user_pass']);
  224. } else {
  225. $_POST['user_pass'] = cmf_password($_POST['user_pass']);
  226. }
  227. $validate = new UserValidate();
  228. $result = $validate->scene('info')->check($this->request->param());
  229. if ($result !== true) {
  230. // 验证失败 输出错误信息
  231. $this->error($validate->getError());
  232. } else {
  233. // $_POST['birthday']=strtotime($_POST['birthday']);
  234. //分开保存。用户的
  235. $user['mobile']=$_POST['mobile'];
  236. $user['user_nickname']=$_POST['user_nickname'];
  237. $user['real_name']=$_POST['real_name'];
  238. if($_POST['sex']=='男'){
  239. $user['sex'] =1;
  240. }else{
  241. $user['sex'] =2;
  242. }
  243. $user['redheart']=$_POST['redheart'];
  244. // $user['birthday']=strtotime($_POST['birthday']);
  245. $user['user_status']=$_POST['user_status'];
  246. //通过用户来查询是否存在父级了
  247. // $parent_id=Db::name('user')->field('parent_id')->find($_POST['id']);
  248. // if($parent_id){
  249. // $this->error('已存在该上级!');
  250. // }
  251. //通过输入的parent_id判断是否存在这个人。
  252. $parentId = isset($_POST['parent_id'])? $_POST['parent_id'] : 0;
  253. if($parentId){
  254. $parent_result=Db::name('user')->find($parentId);
  255. if(!$parent_result){
  256. $this->error('不存在该上级用户!');
  257. }
  258. $user['parent_id']=$parentId;
  259. }
  260. //用户详情的
  261. $userinfo['wechat_code']=$_POST['weixin_num'];
  262. $userinfo['height'] = $_POST['height'];
  263. $userinfo['weight'] = $_POST['weight'];
  264. $userinfo['salary'] = $_POST['salary'];
  265. $userinfo['education'] = $_POST['education'];
  266. $userinfo['occupation'] = $_POST['position1'];
  267. $userinfo['province'] = $_POST['province'];
  268. $userinfo['city'] = $_POST['city'];
  269. $userinfo['district'] = $_POST['district'];
  270. $userinfo['home_province'] = $_POST['home_province'];
  271. $userinfo['home_city'] = $_POST['home_city'];
  272. $userinfo['home_district'] = $_POST['home_district'];
  273. $userinfo['married'] = $_POST['married'];
  274. Db::startTrans();
  275. $result = DB::name('user')->where('id',$_POST['id'])->update($user);
  276. if ($result !== false) {
  277. if(Db::name('user_profile')->where('userid',$_POST['id'])->value('id')){
  278. $userpro_result=Db::name('user_profile')->where('userid',$_POST['id'])->update($userinfo);
  279. }else{
  280. $userinfo['userid'] = $_POST['id'];
  281. $userpro_result=Db::name('user_profile')->insertGetId($userinfo);
  282. }
  283. if($userpro_result !== false){
  284. Db::commit();
  285. $this->success("保存成功!",'/user/admin_index/index');
  286. }else{
  287. Db::rollback();
  288. $this->error("保存失败!");
  289. }
  290. } else {
  291. Db::rollback();
  292. $this->error("保存失败!");
  293. }
  294. }
  295. }
  296. }
  297. /**
  298. * 本站用户拉黑
  299. * @adminMenu(
  300. * 'name' => '本站用户拉黑',
  301. * 'parent' => 'index',
  302. * 'display'=> false,
  303. * 'hasView'=> false,
  304. * 'order' => 10000,
  305. * 'icon' => '',
  306. * 'remark' => '本站用户拉黑',
  307. * 'param' => ''
  308. * )
  309. */
  310. public function ban()
  311. {
  312. $doban=input('doban');
  313. if(isset($doban)){
  314. $id = input('param.id', 0, 'intval');
  315. //判断冻结原因不能为空
  316. if ($id) {
  317. $result = Db::name("user")->where(["id" => $id, "user_type" => 2])->setField(array('user_status'=>0,'freezing'=>input('freezing'),'freezing_choose'=>input('freezing_choose')));
  318. if ($result) {
  319. //发送给客户具体冻结的原因。
  320. // $this->success("会员冻结成功!", "adminIndex/index");
  321. echo 1;die;
  322. } else {
  323. //$this->error('会员冻结失败,会员不存在,或者是管理员!');
  324. echo 0;die;
  325. }
  326. } else {
  327. // $this->error('数据传入失败!');
  328. echo 0;die;
  329. }
  330. }else{
  331. $this->assign('id',input('id'));
  332. return $this->fetch('ban');
  333. }
  334. }
  335. /**
  336. * 本站用户拉黑
  337. * @adminMenu(
  338. * 'name' => '本站用户拉黑',
  339. * 'parent' => 'index',
  340. * 'display'=> false,
  341. * 'hasView'=> false,
  342. * 'order' => 10000,
  343. * 'icon' => '',
  344. * 'remark' => '本站用户拉黑',
  345. * 'param' => ''
  346. * )
  347. */
  348. public function bant()
  349. {
  350. $doban=input('dobant');
  351. if(isset($doban)){
  352. $param = $this->request->param();
  353. if (isset($param['id'])) {
  354. //通过id来获取举报页面
  355. // Db::startTrans();
  356. $result=Db::name('complain')->where('id',$param['id'])->find();
  357. // var_dump($result);die;
  358. if($result){
  359. $result['freezing_choose']=$param['freezing_choose'];
  360. //进行奖励
  361. $siteInfo = cmf_get_site_info();
  362. if ($result) {
  363. Db::startTrans();
  364. //冻结被举报人
  365. $userresult2=Db::name('user')->where('id',$result['c_uid'])->update(['user_status'=>0,'freezing'=>$result['remark']]);
  366. if($userresult2){
  367. //奖励举报人爱心,并且发送模板消息
  368. $result3=Db::name('user')->where('id',$result['uid'])->setInc('redheart',$siteInfo['complain_award_redheart']);
  369. if($result3){
  370. //举报人的openid
  371. $memberInfo = MemberModel::getInfo(['id'=>$result['uid']],'');
  372. //被举报人的openid wechat_code
  373. $memberInfoc = MemberModel::getInfo(['id'=>$result['c_uid']],'');
  374. $wechat_result=Db::name('user_profile')->field('wechat_code')->where('userid',$result['c_uid'])->find();
  375. // 推送审核信息 $result['remark']
  376. $openid = isset($memberInfo['openid'])? $memberInfo['openid'] : '';
  377. if ($openid) {
  378. $realname = isset($memberInfo['real_name']) ? $memberInfo['real_name'] : '';
  379. $checkTime = date('Y.m.d H:i');
  380. // $remark = "审核成功!您的举报的用户{$memberInfoc['user_nickname']}已经通过审核!\n\n审核时间:\t{$checkTime}";
  381. $remark = "脱单需主动,交友需真诚!\n你举报的用户已被冻结,奖励你爱心{$siteInfo['complain_award_redheart']}个";
  382. $title ="尊敬的南宁单身青年用户,您举报的用户经平台核实已审核通过,请谨慎与该用户联系\n被举报用户:\t{$memberInfoc['user_nickname']} (昵称)\n对方的微信号: \t{$wechat_result['wechat_code']}\n申请时间:\t{$checkTime}";
  383. $params = [
  384. 'title' => $title,
  385. 'remark' => $remark,
  386. 'type' => 'auth',
  387. 'keywords' => [
  388. 'keyword1' => [
  389. 'value' => "举报用户",
  390. 'color' => '#173177',
  391. ],
  392. 'keyword2' => [
  393. 'value' =>$result3==true? '已审核' : '审核失败',
  394. 'color' => '#173177',
  395. ]
  396. ]
  397. // 'url' => $status==2? url('/weixin/match/index', '', '', true) : url('/weixin/auth/' . $scene, '', '', true),
  398. ];
  399. Wechat::sendTplMsg($openid, $params);
  400. }
  401. //如同是已经冻结了就不需要发模板信息给被举报人了
  402. // if ($memberInfoc['user_status']!=0) {
  403. //推送被举报人信息
  404. $openidc = isset($memberInfoc['openid'])? $memberInfoc['openid'] : '';
  405. if ($openidc) {
  406. // $realname = isset($memberInfo['real_name']) ? $memberInfo['real_name'] : '';
  407. $checkTime = date('Y.m.d H:i');
  408. $remark = "脱单需主动,交友需真诚!";
  409. $params = [
  410. 'title' =>"尊敬的{$memberInfoc['user_nickname']}用户,由于您的账号被多人举报经平台审核,已经将你的账号冻结,若有疑问请联系平台客服\n\n举报原因:\t{$result['remark']}",
  411. 'remark' => $remark,
  412. 'type' => 'auth',
  413. 'keywords' => [
  414. 'keyword1' => [
  415. 'value' => "举报反馈",
  416. 'color' => '#173177',
  417. ],
  418. 'keyword2' => [
  419. 'value' =>$result3==true? '已审核' : '审核失败',
  420. 'color' => '#173177',
  421. ]
  422. ]
  423. // 'url' => $status==2? url('/weixin/match/index', '', '', true) : url('/weixin/auth/' . $scene, '', '', true),
  424. ];
  425. Wechat::sendTplMsg($openidc, $params);
  426. }
  427. // }
  428. }else{
  429. Db::rollback();
  430. echo 0;die;
  431. }
  432. Db::commit();
  433. echo 1;die;
  434. }else{
  435. Db::rollback();
  436. echo 0;die;
  437. }
  438. //发送给客户具体冻结的原因。
  439. // $this->success("会员冻结成功!", "adminIndex/index");
  440. // echo 1;die;
  441. } else {
  442. //$this->error('会员冻结失败,会员不存在,或者是管理员!');
  443. echo 0;die;
  444. }
  445. } else {
  446. // $this->error('数据传入失败!');
  447. echo 0;die;
  448. }
  449. }
  450. }else{
  451. $this->assign('id',input('id'));
  452. $this->assign('uid',input('uid'));
  453. $this->assign('c_uid',input('cuid'));
  454. return $this->fetch('bant');
  455. }
  456. }
  457. /**
  458. * 本站用户启用
  459. * @adminMenu(
  460. * 'name' => '本站用户启用',
  461. * 'parent' => 'index',
  462. * 'display'=> false,
  463. * 'hasView'=> false,
  464. * 'order' => 10000,
  465. * 'icon' => '',
  466. * 'remark' => '本站用户启用',
  467. * 'param' => ''
  468. * )
  469. */
  470. public function cancelBan()
  471. { // $openid=Db::name('user')->field('openid')->where('id',$id)->find();echo $openid;die();
  472. $id = input('param.id', 0, 'intval');
  473. if ($id) {
  474. Db::startTrans();
  475. $result=Db::name("user")->where(["id" => $id, "user_type" => 2])->setField('user_status', 1);
  476. if($result){
  477. // $complain=Db::name('complain')->field('status')->where('c_uid',$id)->find();
  478. // if($complain['status']!=3){
  479. Db::name("complain")->where(['c_uid'=>$id])->update(['status'=>3]);
  480. // if($result2){
  481. $open_result=Db::name('user')->field('openid')->where('id',$id)->find();
  482. // 推送审核信息 $result['remark']
  483. $openid = $open_result['openid'];
  484. if ($openid) {
  485. $checkTime = date('Y.m.d H:i');
  486. // $remark = "审核成功!您的举报的用户{$memberInfoc['user_nickname']}已经通过审核!\n\n审核时间:\t{$checkTime}";
  487. $remark = "脱单需主动,交友需真诚!";
  488. $title ="恭喜!! 尊敬的南宁单身青年用户,您的账号已经被启用。\n申请时间:\t{$checkTime}";
  489. $params = [
  490. 'title' => $title,
  491. 'remark' => $remark,
  492. 'type' => 'auth',
  493. 'keywords' => [
  494. 'keyword1' => [
  495. 'value' => "重新启用",
  496. 'color' => '#173177',
  497. ],
  498. 'keyword2' => [
  499. 'value' =>'启用成功',
  500. 'color' => '#20c108',
  501. ]
  502. ]
  503. // 'url' => $status==2? url('/weixin/match/index', '', '', true) : url('/weixin/auth/' . $scene, '', '', true),
  504. ];
  505. Wechat::sendTplMsg($openid, $params);
  506. } else{
  507. Db::rollback();
  508. $this->error('会员启用失败!!');
  509. }
  510. Db::commit();
  511. // }else{
  512. // Db::rollback();
  513. // $this->error('会员启用失败0!');
  514. // }
  515. // }
  516. // Db::commit();
  517. }else{
  518. Db::rollback();
  519. $this->error('数据传入失败1!');
  520. }
  521. $this->success("会员启用成功0!", '');
  522. } else {
  523. $this->error('会员启用失败2!');
  524. }
  525. }
  526. /**
  527. * 批量删除
  528. */
  529. public function del()
  530. {
  531. $params = input();
  532. $id = isset($params['id']) ? $params['id'] : 0;
  533. if (empty($id)) {
  534. $this->error('请先选择操作项!');
  535. }
  536. $id = is_array($id) ? implode(',', $id) : $id;
  537. if (Db::name('user')->where(['id' => ['in', $id]])->update(['is_del'=>1])) {
  538. $this->success("批量删除成功!", '');
  539. } else {
  540. $this->error('批量删除失败!');
  541. }
  542. }
  543. /*
  544. * 过滤昵称的特效字符
  545. */
  546. public function filterEmoji($str)
  547. {
  548. $str = preg_replace_callback(
  549. '/./u',
  550. function (array $match) {
  551. return strlen($match[0]) >= 4 ? '' : $match[0];
  552. },
  553. $str);
  554. return $str;
  555. }
  556. /*
  557. * PHPExcel导出用户列表
  558. */
  559. public function export()
  560. {
  561. if(session('ADMIN_ID')!=1){
  562. $this->error('你不是管理员不能具备导出功能!');
  563. }
  564. $PHPExcel = new \PHPExcel();
  565. $PHPSheet = $PHPExcel->getActiveSheet(); //获得当前活动sheet的操作对象
  566. $PHPSheet->setTitle('会员列表'); /* 给当前sheet表设置名称及表头 */
  567. $PHPSheet->setCellValue('A1', '账号');
  568. $PHPSheet->setCellValue('B1', '昵称');
  569. $PHPSheet->setCellValue('C1', '年份');
  570. $PHPSheet->setCellValue('D1', '身高');
  571. $PHPSheet->setCellValue('E1', '学历');
  572. $PHPSheet->setCellValue('F1', '职位');
  573. $PHPSheet->setCellValue('G1', '手机号');
  574. $PHPSheet->setCellValue('H1', '微信号');
  575. $where = array('user_type' => 2);
  576. // $params = session('search'); var_dump($params);die();
  577. // $uid = isset($params['uid']) ? $params['uid'] : 0;
  578. // $keyword = isset($params['keyword']) ? $params['keyword'] : '';$keyword="eerterter";
  579. // if ($uid) {
  580. // $where['uid'] = $uid;
  581. // }
  582. $uid=input('uid');
  583. $keyword=input('keyword');
  584. $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';
  585. $dataList = Db::name('user')
  586. ->alias('u')
  587. ->join('user_profile up','up.userid=u.id','left')
  588. ->where($where)
  589. ->where(function ($query) use ($keyword,$uid) {
  590. $query->where('u.openid', 'not in','');
  591. if(input('u')==2){
  592. $query->where('u.is_vip',1);
  593. }else if(input('u')==3){
  594. $query->where('u.user_status',0);
  595. }else if(input('u')==4){
  596. $query->where('u.is_screen',1);
  597. }else if(input('u')==5){
  598. $query->where('u.user_status',-1);
  599. }else{
  600. $query->where('u.is_vip',0);
  601. }
  602. if($uid){
  603. $query->where('u.id',$uid);
  604. }
  605. if ($keyword) {
  606. $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  607. }
  608. })
  609. ->field($field)
  610. ->order("u.create_time DESC")
  611. ->select();
  612. //echo Db::name('user')->getLastSql();die;
  613. foreach ($dataList as $key => $item) {
  614. $key += 2;
  615. $PHPSheet->setCellValue('A' . $key, $item['user_login']);
  616. $PHPSheet->setCellValue('B' . $key, $this->filterEmoji($item['user_nickname']));
  617. $PHPSheet->setCellValue('C' . $key, date('Y-m-d ', $item['birthday']));
  618. $PHPSheet->setCellValue('D' . $key, $item['height']);
  619. $PHPSheet->setCellValue('E' . $key, $item['education']);
  620. $PHPSheet->setCellValue('F' . $key, $item['occupation']);
  621. $PHPSheet->setCellValue('G' . $key, $item['mobile']);
  622. $PHPSheet->setCellValue('H' . $key, $item['wechat_code']);
  623. // switch ($item['user_status']) {
  624. // case 0:
  625. // $status = '冻结';
  626. // break;
  627. // case 1:
  628. // $status = '开启';
  629. // break;
  630. // default:
  631. // $status = '无效';
  632. // break;
  633. // }
  634. // $PHPSheet->setCellValue('I' . $key, $status);
  635. }
  636. $filename = "用户列表" . date('YmdHis') . ".xls";
  637. header("Pragma: public");
  638. header("Expires: 0");
  639. header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
  640. header("Content-Type:application/force-download");
  641. header("Content-Type:application/vnd.ms-execl");
  642. header("Content-Type:application/octet-stream");
  643. header("Content-Type:application/download");;
  644. header('Content-Disposition:attachment;filename=' . $filename . '');
  645. header("Content-Transfer-Encoding:binary");
  646. $PHPWriter = \PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5');
  647. $PHPWriter->save('php://output');
  648. }
  649. /*
  650. * 爱心充值显示
  651. */
  652. public function accountadd()
  653. {
  654. $params = input();
  655. $id = isset($params['id']) ? $params['id'] : 0;
  656. if (empty($id)) {
  657. $this->error('请先选择操作项!');
  658. }
  659. //通过id来查询用户姓名
  660. $user = DB::name('user')->where("id", $id)->find();
  661. $this->assign($user);
  662. return $this->fetch();
  663. }
  664. /*
  665. * 爱心充值添加
  666. *
  667. */
  668. public function accountAddpost()
  669. {
  670. if ($this->request->isPost()) {
  671. $data = $this->request->param();
  672. $accountlogModel = new AccountLogModel();
  673. $result = $this->validate($data, 'AccountLog');
  674. if ($result !== true) {
  675. $this->error($result);
  676. }
  677. $data['user_id'] = $data['user_id']; //用户id
  678. $data['remark'] = $data['remark']; //备注
  679. $data['type'] = 5; //表示后台充值
  680. $data['status'] = 2; //已完成
  681. $accountlogModel->allowField(true)->save($data);
  682. //变更用户表的redheart
  683. $user=Db::name('user')
  684. ->where('id',$data['user_id'])
  685. ->find();
  686. $data['redheart'] = $user['redheart'] + $data['money'];
  687. Db::name('user')->where('id', $data['user_id'])
  688. // ->strict(false)
  689. ->field('redheart')
  690. ->update($data);
  691. // file_put_contents('abc.txt', Db::name('user')->getLastSql());
  692. $this->success("充值成功!", '/admin/love/index');
  693. }
  694. }
  695. /*
  696. * 会员相亲详细
  697. *
  698. */
  699. public function profile(){
  700. $user_profile = Db::name('user_profile')
  701. ->where('userid',input('id'))
  702. ->find()
  703. // ->each(function($item,$key){
  704. // $item['photolists']=$item['photolist'];
  705. // })
  706. ;
  707. // var_dump($user_profile);
  708. if(!empty($user_profile)){
  709. $user_profile['photolists']=explode(',', $user_profile['photolist']);
  710. }
  711. //var_dump($user_profile);die;
  712. $this->assign('id',input('id'));
  713. $this->assign('profile',$user_profile);
  714. return $this->fetch('editprofile');
  715. }
  716. /**
  717. * 会员匹配信息
  718. *
  719. */
  720. public function profilepost(){
  721. if ($this->request->isPost()) {
  722. $data=$this->request->param();
  723. $profilevalidate = new UserProfileValidate();
  724. $result = $profilevalidate->scene('info')->check($this->request->param());
  725. if ($result !== true) {
  726. // 验证失败 输出错误信息
  727. $this->error($profilevalidate->getError());
  728. } else {
  729. //var_dump($_POST);die;
  730. $result2 = DB::name('user_profile')->update($_POST);
  731. //echo Db::name('user_profile')->getLastSql();die();
  732. if ($result2 !== false) {
  733. $this->success("保存成功!",'/user/admin_index/index');
  734. } else {
  735. $this->error("保存失败!");
  736. }
  737. }
  738. }
  739. }
  740. /**
  741. * 会员身份证验证
  742. *
  743. */
  744. public function idpost(){
  745. if ($this->request->isPost()) {
  746. $data=$this->request->param(); //$this->request->param() 和$_POST[] 一样的
  747. // var_dump($this->request->post('passbtn', TRUE));die;
  748. if($this->request->post('passbtn',true)=='pass'){ //审核通过操作
  749. if(!empty($_POST['idcard_fail'])){
  750. $this->error('失败原因不要填写!');
  751. }
  752. $result=Member::checkAuth($data['id'],2,'idcard','身份证等信息符合');
  753. if(is_array($result)){
  754. //顺便更新一下注册时间 2020 10-22
  755. DB::name('user')->where('id',input('id'))->update([
  756. "create_time"=>time()
  757. ]);
  758. $this->success('审核成功!');
  759. } else{
  760. $this->error(lang($result));
  761. }
  762. }
  763. else if($this->request->post('passbtn',true)=='nopass'){
  764. if($_POST['idcard_fail']=='' || $_POST['idcard_fail']==null){
  765. $this->error('身份证认证失败原因不能为空!');
  766. }
  767. //审核不通过操作
  768. $result=Member::checkAuth($data['id'],3,'idcard',$_POST['idcard_fail']);
  769. if(is_array($result)){
  770. $this->success('审核不通过成功!');
  771. } else{
  772. $this->error(lang($result));
  773. }
  774. }else{ //保持操作
  775. $profilevalidate = new UserProfileValidate();
  776. $result = $profilevalidate->scene('info')->check($this->request->param());
  777. if ($result !== true) {
  778. // 验证失败 输出错误信息
  779. $this->error($profilevalidate->getError());
  780. } else {
  781. //var_dump($_POST);die;
  782. //先修改用户表
  783. $result1=DB::name('user')->where('id',input('id'))->update([
  784. "real_name"=>input('real_name')
  785. ]);
  786. if ($result1!==false) {
  787. $result2 = DB::name('user_profile')->where('userid',$data['id'])
  788. ->update([
  789. "idcard"=>input('idcard'),
  790. 'idcard_type'=>input('idcard_type')
  791. ]);
  792. // echo Db::name('user_profile')->getLastSql();die();
  793. if ($result2 !== false) {
  794. $this->success("保存成功!",'/user/admin_index/index');
  795. } else {
  796. $this->error("保存失败!");
  797. }
  798. }else{
  799. $this->error("保存失败!");
  800. }
  801. }
  802. }
  803. }else{
  804. $id = $this->request->param('id', 0, 'intval');
  805. //读取用户表和用户资料表的信息出来
  806. $join = [
  807. ['user_profile up', 'u.id = up.userid']
  808. ];
  809. $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')
  810. ->alias('u')->join($join)
  811. ->where('u.id',$id)
  812. ->find();
  813. $this->assign('id',$id);
  814. $this->assign('userresult',$userresult);
  815. return $this->fetch('editID');
  816. }
  817. }
  818. public function docomplain(){
  819. $data = $this->request->param();
  820. session('search',[
  821. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  822. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  823. ]);
  824. // 添加返回历史修改 by wesmiler 2020-02-16
  825. $history = isset($data['history'])? intval($data['history']) : 0;
  826. if($history){
  827. $data = session('user_search');
  828. }else{
  829. session('user_search', $data);
  830. }
  831. // 修改 end
  832. //var_dump($data);die;
  833. $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,
  834. c.remark,c.image,c.created_time,c.status')
  835. ->alias('c')
  836. ->join('user u','u.id=c.uid','left')
  837. ->where(function (Query $query) use($data){
  838. $query->where('u.user_type', 2);
  839. $query->where('u.openid', 'not in','');
  840. $query->where('c.status', 2);
  841. // //代表是否付费定制
  842. // ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  843. // //代表是否冻结
  844. // if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
  845. // ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
  846. // }
  847. // //代表是否筛选
  848. // ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
  849. // //代表是否注销
  850. // if($this->request->action()!='userban' && $this->request->param('u')!=3){
  851. // ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
  852. // }
  853. // $this->screenpublic();
  854. })
  855. //待审核
  856. ->order("u.create_time DESC")
  857. ->paginate(10,false,['query'=>request()->param()])
  858. ->each(function($item,$key){
  859. //查询出报名人数,通过活动id
  860. $item['user_nicknamet']=Db::name('user')
  861. ->where(['id'=> $item['c_uid']])
  862. ->field('user_nickname,user_status')
  863. ->find();
  864. ;
  865. return $item;
  866. })
  867. ;
  868. // var_dump($list);die;
  869. //echo Db::name('user')->getLastSql();die;
  870. // 获取分页显示
  871. $page = $list->render();
  872. $this->assign('list', $list);
  873. $this->assign('page', $page);
  874. return $this->fetch('complain');
  875. }
  876. /**
  877. * 职位认证
  878. *
  879. */
  880. public function companypost(){
  881. if ($this->request->isPost()) {
  882. $data=$this->request->param();
  883. if($this->request->post('passbtn',true)=='pass'){ //审核通过
  884. if(!empty($_POST['position_fail'])){
  885. $this->error('失败原因不要填写!');
  886. }
  887. $result=Member::checkAuth($data['id'],2,'position','职位认证等信息符合');
  888. if(is_array($result)){
  889. $this->success('审核成功!');
  890. } else{
  891. $this->error(lang($result));
  892. }
  893. }else if($this->request->post('passbtn',true)=='nopass'){ //审核不通过
  894. if($_POST['position_fail']=='' || $_POST['position_fail']==null){
  895. $this->error('职位认证失败原因不能为空!');
  896. }
  897. $result=Member::checkAuth($data['id'],3,'position',$_POST['position_fail']);
  898. if(is_array($result)){
  899. $this->success('审核不通过成功!');
  900. } else{
  901. // / $this->error($result);
  902. $this->error(lang($result));
  903. }
  904. }else{
  905. $profilevalidate = new UserProfileValidate();
  906. $result = $profilevalidate->scene('info')->check($this->request->param());
  907. if ($result !== true) {
  908. // 验证失败 输出错误信息
  909. $this->error($profilevalidate->getError());
  910. } else {
  911. //var_dump($_POST);die;
  912. $result2 = DB::name('user_profile')->where('userid',$data['id'])->update([
  913. "company"=>input("company"),
  914. "occupation"=>input("occupation"),
  915. "position_type"=>input("position_type")
  916. ]);
  917. // echo Db::name('user_profile')->getLastSql();die();
  918. if ($result2 !== false) {
  919. $this->success("保存成功!",'/user/admin_index/index');
  920. } else {
  921. $this->error("保存失败!");
  922. }
  923. }
  924. }
  925. }else{
  926. $id = $this->request->param('id', 0, 'intval');
  927. //读取用户表和用户资料表的信息出来
  928. $companyresult=Db::name('user_profile')->field('company,occupation,position_img,position_fail,position_type,position_check')
  929. ->where('userid',$id)
  930. ->find();
  931. $this->assign('id',$id);
  932. $this->assign('userresult',$companyresult);
  933. return $this->fetch('editcompany');
  934. }
  935. }
  936. /**
  937. * 学历认证
  938. *
  939. */
  940. public function schoolpost(){
  941. if ($this->request->isPost()) {
  942. $data=$this->request->param();
  943. if($this->request->post('passbtn',true)=='pass'){ //审核通过
  944. if(!empty($_POST['education_fail'])){
  945. $this->error('失败原因不要填写!');
  946. }
  947. $result=Member::checkAuth($data['id'],2,'education','学历认证等信息符合');
  948. if(is_array($result)){
  949. $this->success('审核成功!');
  950. } else{
  951. $this->error(lang($result));
  952. }
  953. }else if($this->request->post('passbtn',true)=='nopass'){ //审核不通过
  954. if($_POST['education_fail']=='' || $_POST['education_fail']==null){
  955. $this->error('学历认证失败原因不能为空!');
  956. }
  957. $result=Member::checkAuth($data['id'],3,'education',$_POST['education_fail']);
  958. if(is_array($result)){
  959. $this->success('审核不通过成功!');
  960. } else{
  961. $this->error(lang($result));
  962. }
  963. }else{
  964. $profilevalidate = new UserProfileValidate();
  965. $result = $profilevalidate->scene('info')->check($this->request->param());
  966. if ($result !== true) {
  967. // 验证失败 输出错误信息
  968. $this->error($profilevalidate->getError());
  969. } else {
  970. //var_dump($_POST);die;
  971. $result2 = DB::name('user_profile')->where('userid',$data['id'])->update([
  972. "graduate"=>input("graduate"),
  973. "education"=>input("education"),
  974. "education_type"=>input("education_type"),
  975. ]);
  976. // echo Db::name('user_profile')->getLastSql();die();
  977. if ($result2 !== false) {
  978. $this->success("保存成功!",'/user/admin_index/index');
  979. } else {
  980. $this->error("保存失败!");
  981. }
  982. }
  983. }
  984. }else{
  985. $id = $this->request->param('id', 0, 'intval');
  986. //读取用户表和用户资料表的信息出来
  987. $schoolresult=Db::name('user_profile')->field('graduate,education,education_fail,education_type,education_code,education_img,education_check')
  988. ->where('userid',$id)
  989. ->find();
  990. $this->assign('id',$id);
  991. $this->assign('userresult',$schoolresult);
  992. return $this->fetch('editschool');
  993. }
  994. }
  995. //条件筛选
  996. // public function screen(){
  997. // return $this->fetch();
  998. // }
  999. //
  1000. //成为VIP付费定制
  1001. public function tovip(){
  1002. $param = $this->request->param();
  1003. if (isset($param['ids']) && isset($param["yes"])) {
  1004. $ids = $this->request->param('ids/a');
  1005. Db::name('user')->where('id', 'in', $ids)->update(['is_vip' => 1]);
  1006. $this->success("成为付费会员成功!", '/user/admin_index/custom');
  1007. }
  1008. if (isset($_POST['ids']) && isset($param["no"])) {
  1009. $ids = $this->request->param('ids/a');
  1010. Db::name('user')->where('id', 'in', $ids)->update(['is_vip' => 0]);
  1011. $this->success("取消付费会员成功!", '');
  1012. }
  1013. }
  1014. //成为单身推荐和取消单身推荐
  1015. public function totuijian(){
  1016. $param = $this->request->param();
  1017. if (isset($param['ids']) && isset($param["yes"])) {
  1018. $ids = $this->request->param('ids/a');
  1019. Db::name('user')->where('id', 'in', $ids)->update(['is_tuijian' => 1]);
  1020. $this->success("成为单身推荐成功!");
  1021. }
  1022. if (isset($_POST['ids']) && isset($param["no"])) {
  1023. $ids = $this->request->param('ids/a');
  1024. Db::name('user')->where('id', 'in', $ids)->update(['is_tuijian' => 0]);
  1025. $this->success("取消单身推荐成功!", '/user/Recommend/index');
  1026. }
  1027. }
  1028. //注销用户
  1029. public function tozhuxiao(){
  1030. $param = $this->request->param();
  1031. if (isset($param['ids']) && isset($param["yes"])) {
  1032. $ids = $this->request->param('ids/a');
  1033. Db::name('user')->where('id', 'in', $ids)->update(['user_status' => -1]);
  1034. $this->success("注销成功!");
  1035. }
  1036. if (isset($_POST['ids']) && isset($param["no"])) {
  1037. $ids = $this->request->param('ids/a');
  1038. Db::name('user')->where('id', 'in', $ids)->update(['user_status' => 1]);
  1039. $this->success("取消注销成功!", '/user/Recommend/index');
  1040. }
  1041. }
  1042. //成为筛选用户和取消筛选用户
  1043. public function toscreen(){
  1044. $param = $this->request->param();
  1045. if (isset($param['ids']) && isset($param["yes"])) {
  1046. $ids = $this->request->param('ids/a');
  1047. Db::name('user')->where('id', 'in', $ids)->update(['is_screen' => 1]);
  1048. $this->success("成为筛选用户成功!");
  1049. }
  1050. if (isset($_POST['ids']) && isset($param["no"])) {
  1051. $ids = $this->request->param('ids/a');
  1052. Db::name('user')->where('id', 'in', $ids)->update(['is_screen' => 0]);
  1053. $this->success("取消筛选用户成功!", url('/user/Admin_index/screen',['u'=>4]));
  1054. }
  1055. }
  1056. //付费定制显示
  1057. public function custom(){
  1058. $data = $this->request->param();
  1059. $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,
  1060. up.idcard_check,up.position_check,up.education_check,last_login_time')
  1061. ->alias('u')
  1062. ->join('user_profile up','u.id=up.userid','left')
  1063. ->where(function (Query $query) {
  1064. $query->where('u.user_type', 2);
  1065. $query->where('u.is_vip', 1);
  1066. $data = $this->request->param();
  1067. if (!empty($data['uid'])) {
  1068. $query->where('u.id', intval($data['uid']));
  1069. }
  1070. if (!empty($data['keyword'])) {
  1071. $keyword = $data['keyword'];
  1072. $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  1073. }
  1074. //年龄区间查询
  1075. if(!empty($data['age1']) && !empty($data['age2'])){
  1076. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  1077. $query->whereNotNull('u.birthday');
  1078. }
  1079. // //只有第一个年龄的情况下
  1080. if(!empty($data['age1']) && empty($data['age2'])){
  1081. $birthday = $data['age1'];
  1082. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  1083. }
  1084. // //只有第二个年龄的情况下
  1085. if(empty($data['age1']) && !empty($data['age2'])){
  1086. $birthday = $data['age2'];
  1087. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  1088. }
  1089. //身高区间查询
  1090. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1091. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  1092. }
  1093. //身高第一个查找
  1094. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  1095. $query->where('up.height',input('height'));
  1096. }
  1097. //身高第二个查找
  1098. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1099. $query->where('up.height',input('heightt'));
  1100. }
  1101. //学历
  1102. if((!empty(input('education')) && input('education')!='none') ){
  1103. $query->where('up.education',input('education'));
  1104. }
  1105. //职位
  1106. if((!empty(input('occupation')) && input('occupation')!='none') ){
  1107. $query->where('up.occupation',input('occupation'));
  1108. }
  1109. //收入
  1110. if((!empty(input('salary')) && input('salary')!='none') ){
  1111. $query->where('up.salary',input('salary'));
  1112. }
  1113. //资产
  1114. if((!empty(input('property')) && input('property')!='none') ){
  1115. $query->where('up.property',input('property'));
  1116. }
  1117. //籍贯
  1118. if((!empty(input('home_city')) && input('home_city')!='none') ){
  1119. $query->where('up.home_city','like','%'.input('home_city').'%');
  1120. }
  1121. //居住地
  1122. if((!empty(input('district')) && input('district')!='none') ){
  1123. $query->where('up.district','like','%'.input('district').'%');
  1124. }
  1125. //婚姻状况
  1126. if((!empty(input('married')) && input('married')!='none') ){
  1127. $query->where('up.married',input('married'));
  1128. }
  1129. })
  1130. //待审核
  1131. ->order("u.create_time DESC")
  1132. ->paginate(10,false,['query'=>request()->param()]);
  1133. //echo Db::name('user')->getLastSql();die;
  1134. // 获取分页显示
  1135. $page = $list->render();
  1136. $this->assign('list', $list);
  1137. $this->assign('page', $page);
  1138. // 渲染模板输出
  1139. return $this->fetch('index');
  1140. }
  1141. //冻结用户显示
  1142. public function userban(){
  1143. $data = $this->request->param();
  1144. $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,
  1145. up.idcard_check,up.position_check,up.education_check,last_login_time')
  1146. ->alias('u')
  1147. ->join('user_profile up','u.id=up.userid','left')
  1148. ->where(function (Query $query) {
  1149. $query->where('u.user_type', 2);
  1150. $query->where('u.user_status', 0);
  1151. $data = $this->request->param();
  1152. if (!empty($data['uid'])) {
  1153. $query->where('u.id', intval($data['uid']));
  1154. }
  1155. if (!empty($data['keyword'])) {
  1156. $keyword = $data['keyword'];
  1157. $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  1158. }
  1159. //年龄区间查询
  1160. if(!empty($data['age1']) && !empty($data['age2'])){
  1161. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  1162. $query->whereNotNull('u.birthday');
  1163. }
  1164. // //只有第一个年龄的情况下
  1165. if(!empty($data['age1']) && empty($data['age2'])){
  1166. $birthday = $data['age1'];
  1167. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1168. }
  1169. // //只有第二个年龄的情况下
  1170. if(empty($data['age1']) && !empty($data['age2'])){
  1171. $birthday = $data['age2'];
  1172. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1173. }
  1174. //身高区间查询
  1175. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1176. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  1177. }
  1178. //身高第一个查找
  1179. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  1180. $query->where('up.height',input('height'));
  1181. }
  1182. //身高第二个查找
  1183. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1184. $query->where('up.height',input('heightt'));
  1185. }
  1186. //学历
  1187. if((!empty(input('education')) && input('education')!='none') ){
  1188. $query->where('up.education',input('education'));
  1189. }
  1190. //职位
  1191. if((!empty(input('occupation')) && input('occupation')!='none') ){
  1192. $query->where('up.occupation',input('occupation'));
  1193. }
  1194. //收入
  1195. if((!empty(input('salary')) && input('salary')!='none') ){
  1196. $query->where('up.salary',input('salary'));
  1197. }
  1198. //资产
  1199. if((!empty(input('property')) && input('property')!='none') ){
  1200. $query->where('up.property',input('property'));
  1201. }
  1202. //籍贯
  1203. if((!empty(input('home_city')) && input('home_city')!='none') ){
  1204. $query->where('up.home_city','like','%'.input('home_city').'%');
  1205. }
  1206. //居住地
  1207. if((!empty(input('district')) && input('district')!='none') ){
  1208. $query->where('up.district','like','%'.input('district').'%');
  1209. }
  1210. //婚姻状况
  1211. if((!empty(input('married')) && input('married')!='none') ){
  1212. $query->where('up.married',input('married'));
  1213. }
  1214. })
  1215. //待审核
  1216. ->order("u.updated_at DESC")
  1217. ->paginate(10,false,['query'=>request()->param()]);
  1218. //echo Db::name('user')->getLastSql();die;
  1219. // 获取分页显示
  1220. $page = $list->render();
  1221. $this->assign('list', $list);
  1222. $this->assign('page', $page);
  1223. // 渲染模板输出
  1224. return $this->fetch('index');
  1225. }
  1226. /**
  1227. *筛选用户
  1228. *
  1229. */
  1230. public function screen(){
  1231. $data = $this->request->param();
  1232. $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,
  1233. up.idcard_check,up.position_check,up.education_check,last_login_time')
  1234. ->alias('u')
  1235. ->join('user_profile up','u.id=up.userid','left')
  1236. ->where(function (Query $query) {
  1237. $query->where('u.user_type', 2);
  1238. $query->where('u.is_screen', 1); //是否是筛选
  1239. $data = $this->request->param();
  1240. if (!empty($data['uid'])) {
  1241. $query->where('u.id', intval($data['uid']));
  1242. }
  1243. if (!empty($data['keyword'])) {
  1244. $keyword = $data['keyword'];
  1245. $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  1246. }
  1247. //年龄区间查询
  1248. if(!empty($data['age1']) && !empty($data['age2'])){
  1249. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  1250. $query->whereNotNull('u.birthday');
  1251. }
  1252. // //只有第一个年龄的情况下
  1253. if(!empty($data['age1']) && empty($data['age2'])){
  1254. $birthday = $data['age1'];
  1255. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1256. }
  1257. // //只有第二个年龄的情况下
  1258. if(empty($data['age1']) && !empty($data['age2'])){
  1259. $birthday = $data['age2'];
  1260. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1261. }
  1262. //身高区间查询
  1263. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1264. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  1265. }
  1266. //身高第一个查找
  1267. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  1268. $query->where('up.height',input('height'));
  1269. }
  1270. //身高第二个查找
  1271. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1272. $query->where('up.height',input('heightt'));
  1273. }
  1274. //学历
  1275. if((!empty(input('education')) && input('education')!='none') ){
  1276. $query->where('up.education',input('education'));
  1277. }
  1278. //职位
  1279. if((!empty(input('occupation')) && input('occupation')!='none') ){
  1280. $query->where('up.occupation',input('occupation'));
  1281. }
  1282. //收入
  1283. if((!empty(input('salary')) && input('salary')!='none') ){
  1284. $query->where('up.salary',input('salary'));
  1285. }
  1286. //资产
  1287. if((!empty(input('property')) && input('property')!='none') ){
  1288. $query->where('up.property',input('property'));
  1289. }
  1290. //籍贯
  1291. if((!empty(input('home_city')) && input('home_city')!='none') ){
  1292. $query->where('up.home_city','like','%'.input('home_city').'%');
  1293. }
  1294. //居住地
  1295. if((!empty(input('district')) && input('district')!='none') ){
  1296. $query->where('up.district','like','%'.input('district').'%');
  1297. }
  1298. //婚姻状况
  1299. if((!empty(input('married')) && input('married')!='none') ){
  1300. $query->where('up.married',input('married'));
  1301. }
  1302. })
  1303. //待审核
  1304. ->order("u.create_time DESC")
  1305. ->paginate(10,false,['query'=>request()->param()]);
  1306. //echo Db::name('user')->getLastSql();die;
  1307. // 获取分页显示
  1308. $page = $list->render();
  1309. $this->assign('list', $list);
  1310. $this->assign('page', $page);
  1311. // 渲染模板输出
  1312. return $this->fetch('index');
  1313. }
  1314. //显示备注信息
  1315. public function showbeizhu(){
  1316. $dobeizhu=input('dobeizhu');
  1317. if(isset($dobeizhu)){
  1318. $id = input('param.id', 0, 'intval');
  1319. //判断备注原因不能为空
  1320. if ($id) {
  1321. $result = Db::name("user")->where(["id" => $id, "user_type" => 2])->setField(array('remark'=>input('remark')));
  1322. if ($result) {
  1323. echo 1;die;
  1324. } else {
  1325. echo 0;die;
  1326. }
  1327. } else {
  1328. echo 0;die;
  1329. }
  1330. }else{
  1331. //通过用户id来进行显示备注
  1332. $result=Db::name('user')->field('remark')->where('id',input('id'))->find();
  1333. $this->assign('remark',$result['remark']);
  1334. $this->assign('id',input('id'));
  1335. return $this->fetch('beizhu');
  1336. }
  1337. }
  1338. //显示注销用户
  1339. public function userlogout(){
  1340. $data = $this->request->param();
  1341. $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,
  1342. up.idcard_check,up.position_check,up.education_check,last_login_time')
  1343. ->alias('u')
  1344. ->join('user_profile up','u.id=up.userid','left')
  1345. ->where(function (Query $query) {
  1346. $query->where('u.user_type', 2);
  1347. $query->where('u.user_status', -1);
  1348. $data = $this->request->param();
  1349. if (!empty($data['uid'])) {
  1350. $query->where('u.id', intval($data['uid']));
  1351. }
  1352. if (!empty($data['keyword'])) {
  1353. $keyword = $data['keyword'];
  1354. $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  1355. }
  1356. //年龄区间查询
  1357. if(!empty($data['age1']) && !empty($data['age2'])){
  1358. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  1359. $query->whereNotNull('u.birthday');
  1360. }
  1361. // //只有第一个年龄的情况下
  1362. if(!empty($data['age1']) && empty($data['age2'])){
  1363. $birthday = $data['age1'];
  1364. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1365. }
  1366. // //只有第二个年龄的情况下
  1367. if(empty($data['age1']) && !empty($data['age2'])){
  1368. $birthday = $data['age2'];
  1369. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1370. }
  1371. //身高区间查询
  1372. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1373. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  1374. }
  1375. //身高第一个查找
  1376. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  1377. $query->where('up.height',input('height'));
  1378. }
  1379. //身高第二个查找
  1380. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1381. $query->where('up.height',input('heightt'));
  1382. }
  1383. //学历
  1384. if((!empty(input('education')) && input('education')!='none') ){
  1385. $query->where('up.education',input('education'));
  1386. }
  1387. //职位
  1388. if((!empty(input('occupation')) && input('occupation')!='none') ){
  1389. $query->where('up.occupation',input('occupation'));
  1390. }
  1391. //收入
  1392. if((!empty(input('salary')) && input('salary')!='none') ){
  1393. $query->where('up.salary',input('salary'));
  1394. }
  1395. //资产
  1396. if((!empty(input('property')) && input('property')!='none') ){
  1397. $query->where('up.property',input('property'));
  1398. }
  1399. //籍贯
  1400. if((!empty(input('home_city')) && input('home_city')!='none') ){
  1401. $query->where('up.home_city','like','%'.input('home_city').'%');
  1402. }
  1403. //居住地
  1404. if((!empty(input('district')) && input('district')!='none') ){
  1405. $query->where('up.district','like','%'.input('district').'%');
  1406. }
  1407. //婚姻状况
  1408. if((!empty(input('married')) && input('married')!='none') ){
  1409. $query->where('up.married',input('married'));
  1410. }
  1411. })
  1412. //待审核
  1413. ->order("u.updated_at DESC")
  1414. ->paginate(10,false,['query'=>request()->param()]);
  1415. //echo Db::name('user')->getLastSql();die;
  1416. // 获取分页显示
  1417. $page = $list->render();
  1418. $this->assign('list', $list);
  1419. $this->assign('page', $page);
  1420. // 渲染模板输出
  1421. return $this->fetch('index');
  1422. }
  1423. //清除身份证提交
  1424. public function touserlogout(){
  1425. $param = $this->request->param();
  1426. if (isset($param['ids']) && isset($param["yes"])) {
  1427. $ids = $this->request->param('ids/a');
  1428. Db::name('user_profile')->where('userid', 'in', $ids)->update(['idcard' => '','idcard_check'=>0]);
  1429. // echo Db::name('user_profile')->getLastSql();die();
  1430. $this->success("清理身份信息成功!");
  1431. }
  1432. }
  1433. //vip充值用户显示
  1434. public function viprechange(){
  1435. $data = $this->request->param();
  1436. session('search',[
  1437. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  1438. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  1439. ]);
  1440. // 添加返回历史修改 by wesmiler 2020-02-16
  1441. $history = isset($data['history'])? intval($data['history']) : 0;
  1442. if($history){
  1443. $data = session('user_search');
  1444. }else{
  1445. session('user_search', $data);
  1446. }
  1447. // 修改 end
  1448. $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,
  1449. up.idcard_check,up.position_check,rl.money,rl.pay_money,up.education_check')
  1450. ->alias('u')
  1451. ->join('user_profile up','u.id=up.userid','left')
  1452. ->join('user_recharge_log rl','rl.user_id=u.id','left')
  1453. ->where(function (Query $query) use($data){
  1454. $query->where('u.user_type', 2);
  1455. $query->where('u.openid', 'not in','');
  1456. $query->where('rl.type', 4);
  1457. $query->where('rl.status', 2);
  1458. $query->where('u.vip_auth', 1);
  1459. $this->screenpublic();
  1460. })
  1461. //待审核
  1462. ->order("rl.created_at DESC")
  1463. ->paginate(10,false,['query'=>request()->param()]);
  1464. // echo Db::name('user')->getLastSql();die;
  1465. // 获取分页显示
  1466. $page = $list->render();
  1467. $this->assign('list', $list);
  1468. $this->assign('page', $page);
  1469. // 渲染模板输出
  1470. return $this->fetch('index');
  1471. }
  1472. //人工牵线
  1473. public function pullwire(){
  1474. $this->fetch();
  1475. }
  1476. //下架处理
  1477. public function unshelf(){
  1478. $data=$this->request->param();
  1479. $com_result=Db::name('complain')->field('c_uid')->where('id',$data['ids'])->find();
  1480. if($data){
  1481. Db::startTrans();
  1482. $result1=Db::name('complain')->where("c_uid",$com_result['c_uid'])->update(['status'=>1]);
  1483. if($result1){
  1484. $result2=Db::name('user')->where('id',$data['c_uid'])->update(['user_status'=>1]);
  1485. if($result2){
  1486. Db::commit();
  1487. $this->success("下架成功!", url('/user/Admin_index/complain'));
  1488. }else{
  1489. Db::rollback();
  1490. $this->error("下架失败!");
  1491. }
  1492. }else{
  1493. Db::rollback();
  1494. $this->error("下架失败!!");
  1495. }
  1496. }
  1497. }
  1498. //进行显示反馈显示用户。
  1499. public function feedback(){
  1500. $list=Db::name('advices')
  1501. ->alias('ad')
  1502. // ->where('status',1)
  1503. ->order("ad.created_time DESC")
  1504. ->paginate(10,false,['query'=>request()->param()])
  1505. ->each(function($item,$key){
  1506. //查询出被举报名人昵称和状态。
  1507. $item['user_nicknamet']=Db::name('user')
  1508. ->where(['id'=> $item['uid']])
  1509. ->field('user_nickname,user_status')
  1510. ->find();
  1511. ;
  1512. return $item;
  1513. })
  1514. ;
  1515. // 获取分页显示
  1516. $page = $list->render();
  1517. $this->assign('list', $list);
  1518. $this->assign('page', $page);
  1519. return $this->fetch('feedback');
  1520. }
  1521. //处理审核
  1522. public function feedbackedit(){
  1523. $result=Db::name('advices')->where("id",input('id'))->update(['status'=>2]);
  1524. if($result){
  1525. $this->success("审核处理成功!");
  1526. }else{
  1527. $this->error("审核处理失败!");
  1528. }
  1529. }
  1530. //投诉举报页面
  1531. public function complain(){
  1532. $data = $this->request->param();
  1533. session('search',[
  1534. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  1535. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  1536. ]);
  1537. // 添加返回历史修改 by wesmiler 2020-02-16
  1538. $history = isset($data['history'])? intval($data['history']) : 0;
  1539. if($history){
  1540. $data = session('user_search');
  1541. }else{
  1542. session('user_search', $data);
  1543. }
  1544. // 修改 end
  1545. //var_dump($data);die;
  1546. $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,
  1547. c.remark,c.image,c.created_time,c.status')
  1548. ->alias('c')
  1549. ->join('user u','u.id=c.uid','left')
  1550. ->where(function (Query $query) use($data){
  1551. $query->where('u.user_type', 2);
  1552. $query->where('u.openid', 'not in','');
  1553. // $query->where('c.status', 1);
  1554. //代表是否付费定制
  1555. ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  1556. //代表是否冻结
  1557. if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
  1558. ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
  1559. }
  1560. //代表是否筛选
  1561. ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
  1562. //代表是否注销
  1563. if($this->request->action()!='userban' && $this->request->param('u')!=3){
  1564. ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
  1565. }
  1566. $this->screenpublic();
  1567. })
  1568. //待审核
  1569. ->order("c.created_time DESC")
  1570. ->paginate(10,false,['query'=>request()->param()])
  1571. ->each(function($item,$key){
  1572. //查询出被举报名人昵称和状态。
  1573. $item['user_nicknamet']=Db::name('user')
  1574. ->where(['id'=> $item['c_uid']])
  1575. ->field('user_nickname,user_status')
  1576. ->find();
  1577. ;
  1578. return $item;
  1579. })
  1580. ;
  1581. // var_dump($data);die;
  1582. //echo Db::name('user')->getLastSql();die;
  1583. // 获取分页显示
  1584. $page = $list->render();
  1585. $this->assign('list', $list);
  1586. $this->assign('page', $page);
  1587. return $this->fetch('complain');
  1588. }
  1589. public function screenpublic(){
  1590. $data = $this->request->param();
  1591. if (!empty($data['uid'])) {
  1592. $query->where('u.id', intval($data['uid']));
  1593. }
  1594. if (!empty($data['keyword'])) {
  1595. $keyword = $data['keyword'];
  1596. $query->where('u.user_login|u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  1597. }
  1598. //年龄区间查询
  1599. if(!empty($data['age1']) && !empty($data['age2'])){
  1600. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  1601. $query->whereNotNull('u.birthday');
  1602. }
  1603. // //只有第一个年龄的情况下
  1604. if(!empty($data['age1']) && empty($data['age2'])){
  1605. $birthday = $data['age1'];
  1606. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1607. }
  1608. // //只有第二个年龄的情况下
  1609. if(empty($data['age1']) && !empty($data['age2'])){
  1610. $birthday = $data['age2'];
  1611. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=YEAR('$birthday') and u.birthday is not null ");
  1612. }
  1613. //身高区间查询
  1614. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1615. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  1616. }
  1617. //身高第一个查找
  1618. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  1619. $query->where('up.height',input('height'));
  1620. }
  1621. //身高第二个查找
  1622. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  1623. $query->where('up.height',input('heightt'));
  1624. }
  1625. //学历
  1626. if((!empty(input('education')) && input('education')!='none') ){
  1627. $query->where('up.education',input('education'));
  1628. }
  1629. //职位
  1630. if((!empty(input('occupation')) && input('occupation')!='none') ){
  1631. $query->where('up.occupation',input('occupation'));
  1632. }
  1633. //收入
  1634. if((!empty(input('salary')) && input('salary')!='none') ){
  1635. $query->where('up.salary',input('salary'));
  1636. }
  1637. //资产
  1638. if((!empty(input('property')) && input('property')!='none') ){
  1639. $query->where('up.property',input('property'));
  1640. }
  1641. //籍贯
  1642. if((!empty(input('home_city')) && input('home_city')!='none') ){
  1643. $query->where('up.home_city','like','%'.input('home_city').'%');
  1644. }
  1645. //居住地
  1646. if((!empty(input('district')) && input('district')!='none') ){
  1647. $query->where('up.district','like','%'.input('district').'%');
  1648. }
  1649. //婚姻状况
  1650. if((!empty(input('married')) && input('married')!='none') ){
  1651. $query->where('up.married',input('married'));
  1652. }
  1653. }
  1654. //处理举报用户
  1655. public function tohandle(){
  1656. $param = $this->request->param();
  1657. $siteInfo = cmf_get_site_info();
  1658. $id = $param['ids'];
  1659. if (isset($param['ids'])) {
  1660. //通过id来获取举报页面
  1661. $result=Db::name('complain')->where('id',$param['ids'])->find();
  1662. Db::startTrans();
  1663. if($result){
  1664. //冻结被举报人, //进行奖励
  1665. $userresult2=Db::name('user')->where('id',$result['c_uid'])->update(['user_status'=>0,'freezing'=>$result['remark']]);
  1666. if($userresult2){
  1667. $comsel_result=Db::name('complain')->field('uid')->where('c_uid',$result['c_uid'])->select();
  1668. foreach ($comsel_result as $key => $value) {
  1669. $aryuser=$value['uid'];
  1670. }
  1671. //奖励举报人爱心,并且发送模板消息,循环多人发送
  1672. $result3=Db::name('user')->where('id','in',$aryuser)->setInc('redheart',$siteInfo['complain_award_redheart']);
  1673. if($result3){
  1674. //变成已经处理
  1675. $com_result= Db::name("complain")->where(['c_uid'=>$result['c_uid']])->update(['status'=>2]);
  1676. if($com_result){
  1677. //被举报人的openid wechat_code
  1678. $memberInfoc = MemberModel::getInfo(['id'=>$result['c_uid']],'');
  1679. $wechat_result=Db::name('user_profile')->field('wechat_code')->where('userid',$result['c_uid'])->find();
  1680. //举报人的openid
  1681. //$memberInfo = MemberModel::getInfo(['id'=>$result['uid']],'');
  1682. $memberInfo = Db::name('user')->field('openid,real_name')->where('id','in',$aryuser)->select();
  1683. foreach ($memberInfo as $values) {
  1684. // 推送审核信息 $result['remark']
  1685. $openid = isset($values['openid'])? $values['openid'] : '';
  1686. if ($openid) {
  1687. $realname = isset($values['real_name']) ? $values['real_name'] : '';
  1688. $checkTime = date('Y.m.d H:i');
  1689. $remark = "脱单需主动,交友需真诚!\n你举报的用户已被处理,奖励你爱心{$siteInfo['complain_award_redheart']}个";
  1690. $title ="尊敬的南宁单身青年用户,您举报的用户经平台核实已审核通过,请谨慎与该用户联系\n被举报用户:\t{$memberInfoc['user_nickname']} (昵称)\n对方的微信号: \t{$wechat_result['wechat_code']}\n申请时间:\t{$checkTime}";
  1691. $params = [
  1692. 'title' => $title,
  1693. 'remark' => $remark,
  1694. 'type' => 'auth',
  1695. 'keywords' => [
  1696. 'keyword1' => [
  1697. 'value' => "举报用户",
  1698. 'color' => '#173177',
  1699. ],
  1700. 'keyword2' => [
  1701. 'value' =>$result3==true? '已审核' : '审核失败',
  1702. 'color' => '#173177',
  1703. ]
  1704. ]
  1705. ];
  1706. Wechat::sendTplMsg($openid, $params);
  1707. }
  1708. }
  1709. //推送被举报人信息
  1710. $openidc = isset($memberInfoc['openid'])? $memberInfoc['openid'] : '';
  1711. if ($openidc) {
  1712. $checkTime = date('Y.m.d H:i');
  1713. $remark = "脱单需主动,交友需真诚!";
  1714. $params = [
  1715. 'title' =>"尊敬的{$memberInfoc['user_nickname']}用户,由于您的账号被多人举报经平台审核,已经将你的账号冻结,若有疑问请联系平台客服\n\n举报原因:\t{$result['remark']}",
  1716. 'remark' => $remark,
  1717. 'type' => 'auth',
  1718. 'keywords' => [
  1719. 'keyword1' => [
  1720. 'value' => "举报反馈",
  1721. 'color' => '#173177',
  1722. ],
  1723. 'keyword2' => [
  1724. 'value' =>$result3==true? '已审核' : '审核失败',
  1725. 'color' => '#173177',
  1726. ]
  1727. ]
  1728. ];
  1729. Wechat::sendTplMsg($openidc, $params);
  1730. }
  1731. }
  1732. }else{
  1733. Db::rollback();
  1734. $this->error('处理失败!');
  1735. }
  1736. }else{
  1737. Db::rollback();
  1738. $this->error('处理失败!');
  1739. }
  1740. Db::commit();
  1741. $this->success("处理成功!",'/user/admin_index/complain');
  1742. } else {
  1743. Db::rollback();
  1744. $this->error('处理失败!');
  1745. }
  1746. }else{
  1747. $this->error('处理失败!');
  1748. }
  1749. }
  1750. }