UserController.class.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <?php
  2. namespace Home\Controller;
  3. class UserController extends HomeController
  4. {
  5. protected function _initialize()
  6. {
  7. parent::_initialize();
  8. $allow_action=array("index","addresslist","deladdress","upplusaddress","authrz","recharge_img","upauthrz","respwd","sub_respwd","tgcode","notice","readnoticeone","delonenotice","allread","allnoticedel","online","getlineinfo","uptxt","mybill","getbilllist");
  9. if(!in_array(ACTION_NAME,$allow_action)){
  10. $this->error(L("非法操作!"));
  11. }
  12. }
  13. //获取我的账号
  14. public function getbilllist(){
  15. //$uid = userid();
  16. // $list = M("bill")->where(array('uid'=>$uid))->order("id desc")->limit(50)->select();
  17. }
  18. //我的账单
  19. public function mybill(){
  20. $uid = userid();
  21. if($uid <= 0){
  22. $this->redirect('Login/index');
  23. }
  24. $uid = userid();
  25. $fields = "id,username,rzstatus,logintime,loginip,invit";
  26. $uinfo = M("user")->where(array('id'=>$uid))->field($fields)->find();
  27. $uarr = explode("@",$uinfo['username']);
  28. $uinfo['name'] = substr($uarr[0],0,4)."***@".$uarr[1];
  29. $uinfo['uid'] = '7012'.$uinfo['id'];
  30. $uheader = substr($uinfo['username'],0,2);
  31. $this->assign('uheader',$uheader);
  32. $this->assign('uinfo',$uinfo);
  33. $list = M("bill")->where(array('uid'=>$uid))->order("id desc")->limit(50)->select();
  34. $this->assign('list',$list);
  35. $this->display();
  36. }
  37. //提交聊天内容
  38. public function uptxt($txt = null){
  39. if (checkstr($txt) ) {
  40. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  41. }
  42. $uid = userid();
  43. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username")->find();
  44. if($uid <= 0){
  45. $this->ajaxReturn(['code'=>0,'info'=>L('请先登陆')]);
  46. }
  47. if($txt == ''){
  48. $this->ajaxReturn(['code'=>0,'info'=>L('请输入信息内容')]);
  49. }
  50. $data['uid'] = $uid;
  51. $data['username'] = $uinfo['username'];
  52. $data['type'] = 2;
  53. $data['content'] = $txt;
  54. $data['addtime'] = date("Y-m-d H:i:s",time());
  55. $result = M("online")->add($data);
  56. if($result){
  57. $this->ajaxReturn(['code'=>1]);
  58. }else{
  59. $this->ajaxReturn(['code'=>0,'info'=>L('信息发送失败')]);
  60. }
  61. }
  62. //获取聊天记录
  63. public function getlineinfo(){
  64. $uid = userid();
  65. $list = M("online")->where(array('uid'=>$uid))->order('id asc')->field("type,content")->limit(20)->select();
  66. $this->ajaxReturn(['code'=>1,'data'=>$list]);exit();
  67. }
  68. //在线客服
  69. public function online(){
  70. $uid = userid();
  71. if($uid <= 0){
  72. $this->redirect('Login/index');
  73. }
  74. $this->display();
  75. }
  76. //我的通知全部删除
  77. public function allnoticedel(){
  78. if($_POST){
  79. $st = trim($_POST['st']);
  80. if($st != 1){
  81. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  82. }
  83. $uid = userid();
  84. if($uid <= 0){
  85. redirect('/Login/index.html');
  86. }
  87. $list = M("notice")->where(array('uid'=>$uid))->select();
  88. if(!empty($list)){
  89. foreach($list as $key => $vo){
  90. $id = $vo['id'];
  91. M("notice")->where(array('id'=>$id))->delete();
  92. }
  93. $this->ajaxReturn(['code'=>1,'info'=>L('删除成功')]);
  94. }else{
  95. $this->ajaxReturn(['code'=>1,'info'=>L('操作成功')]);
  96. }
  97. }else{
  98. $this->ajaxReturn(['code'=>0,'info'=>L('非法操作')]);
  99. }
  100. }
  101. //我的通知全部标为已读
  102. public function allread(){
  103. if($_POST){
  104. $st = trim($_POST['st']);
  105. if($st != 1){
  106. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  107. }
  108. $uid = userid();
  109. if($uid <= 0){
  110. redirect('/Login/index.html');
  111. }
  112. $list = M("notice")->where(array('uid'=>$uid,'status'=>1))->select();
  113. if(!empty($list)){
  114. foreach($list as $key => $vo){
  115. $id = $vo['id'];
  116. M("notice")->where(array('id'=>$id))->save(['status'=>2]);
  117. }
  118. $this->ajaxReturn(['code'=>1,'info'=>L('标记成功')]);
  119. }else{
  120. $this->ajaxReturn(['code'=>1,'info'=>L('操作成功')]);
  121. }
  122. }else{
  123. $this->ajaxReturn(['code'=>0,'info'=>L('非法操作')]);
  124. }
  125. }
  126. //删除单条记录
  127. public function delonenotice($id = null){
  128. if($_POST){
  129. if(checkstr($id)){
  130. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  131. }
  132. if($id <= 0){
  133. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  134. }
  135. $info = M("notice")->where(array('id'=>$id))->find();
  136. if(empty($info)){
  137. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  138. }
  139. $result = M("notice")->where(array('id'=>$id))->delete();
  140. if($result){
  141. $this->ajaxReturn(['code'=>1,'info'=>L('删除成功')]);
  142. }else{
  143. $this->ajaxReturn(['code'=>0,'info'=>L('删除失败')]);
  144. }
  145. }else{
  146. $this->ajaxReturn(['code'=>0,'info'=>L('非法操作')]);
  147. }
  148. }
  149. //标记单条通知已读状态
  150. public function readnoticeone($id = null){
  151. if($_POST){
  152. if(checkstr($id)){
  153. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  154. }
  155. if($id <= 0){
  156. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  157. }
  158. $info = M("notice")->where(array('id'=>$id))->find();
  159. if(empty($info)){
  160. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  161. }
  162. $result = M("notice")->where(array('id'=>$id))->save(['status'=>2]);
  163. if($result){
  164. $this->ajaxReturn(['code'=>1,'info'=>L('操作成功')]);
  165. }else{
  166. $this->ajaxReturn(['code'=>0,'info'=>L('操作失败')]);
  167. }
  168. }else{
  169. $this->ajaxReturn(['code'=>0,'info'=>L('非法操作')]);
  170. }
  171. }
  172. //我的通知
  173. public function notice(){
  174. if (!userid()) {
  175. redirect('/Login/index.html');
  176. }
  177. $uid = userid();
  178. $fields = "id,username,rzstatus,logintime,loginip,invit";
  179. $uinfo = M("user")->where(array('id'=>$uid))->field($fields)->find();
  180. $uarr = explode("@",$uinfo['username']);
  181. $uinfo['name'] = substr($uarr[0],0,4)."***@".$uarr[1];
  182. $uinfo['uid'] = '7012'.$uinfo['id'];
  183. $uheader = substr($uinfo['username'],0,2);
  184. $this->assign('uheader',$uheader);
  185. $this->assign('uinfo',$uinfo);
  186. $list = M("notice")->where(array('uid'=>$uid))->order("id desc")->limit(50)->select();
  187. $this->assign("list",$list);
  188. $this->display();
  189. }
  190. //分享推荐页面
  191. public function tgcode(){
  192. if (!userid()) {
  193. redirect('/Login/index.html');
  194. }
  195. $uid = userid();
  196. $fields = "id,username,rzstatus,logintime,loginip,invit";
  197. $uinfo = M("user")->where(array('id'=>$uid))->field($fields)->find();
  198. $uarr = explode("@",$uinfo['username']);
  199. $uinfo['name'] = substr($uarr[0],0,4)."***@".$uarr[1];
  200. $uinfo['uid'] = '7012'.$uinfo['id'];
  201. $uheader = substr($uinfo['username'],0,2);
  202. $this->assign('uheader',$uheader);
  203. $this->assign('uinfo',$uinfo);
  204. //三代会员统计
  205. $count1_rz = M("user")->where("invit_1 = {$uid} and rzstatus = 2")->count();
  206. if($count1_rz <= 0){
  207. $count1_rz = 0;
  208. }
  209. $count1_nrz = M("user")->where("invit_1 = {$uid} and rzstatus != 2")->count();
  210. if($count1_nrz <= 0){
  211. $count1_nrz = 0;
  212. }
  213. $count2_rz = M("user")->where("invit_2 = {$uid} and rzstatus = 2")->count();
  214. if($count2_rz <= 0){
  215. $count2_rz = 0;
  216. }
  217. $count2_nrz = M("user")->where("invit_2 = {$uid} and rzstatus != 2")->count();
  218. if($count2_nrz <= 0){
  219. $count2_nrz = 0;
  220. }
  221. $count3_rz = M("user")->where("invit_3 = {$uid} and rzstatus = 2")->count();
  222. if($count3_rz <= 0){
  223. $count3_rz = 0;
  224. }
  225. $count3_nrz = M("user")->where("invit_3 = {$uid} and rzstatus != 2")->count();
  226. if($count3_nrz <= 0){
  227. $count3_nrz = 0;
  228. }
  229. $allcount_rz = $count1_rz + $count2_rz + $count3_rz;
  230. if($allcount_rz <= 0){
  231. $allcount_rz = 0;
  232. }
  233. $allcount_nrz = $count1_nrz + $count2_nrz + $count3_nrz;
  234. if($allcount_nrz <= 0){
  235. $allcount_nrz = 0;
  236. }
  237. $carr['one'] = $count1_rz;
  238. $carr['two'] = $count2_rz;
  239. $carr['three'] = $count3_rz;
  240. $carr['onen'] = $count1_nrz;
  241. $carr['twon'] = $count2_nrz;
  242. $carr['threen'] = $count3_nrz;
  243. $carr['allrz'] = $allcount_rz;
  244. $carr['allnrz'] = $allcount_nrz;
  245. $this->assign('carr',$carr);
  246. $invit = $uinfo['invit'];
  247. $url = 'https://' . $_SERVER['HTTP_HOST'] . u('/Login/register', array('qr'=>$invit));
  248. $drpath = './Public/Static/qrcode/';
  249. $imgma = $invit . '.png';
  250. $urel = './Public/Static/qrcode/' . $imgma;
  251. Vendor('phpqrcode.phpqrcode');
  252. $object = new \QRcode();
  253. $size = 3;
  254. $errorLevel = 16;
  255. $object->png($url, $drpath . '/' . $imgma, $errorLevel, $size);
  256. $object->scerweima1($url,$urel,$url);
  257. $this->assign('invit',$invit);
  258. $this->assign('url',$url);
  259. //登陆日志
  260. $loglist = M("user_log")->where(array('userid'=>$uid))->order("id desc")->limit(20)->select();
  261. $this->assign('loglist',$loglist);
  262. $this->display();
  263. }
  264. //修改密码页面
  265. public function respwd(){
  266. if (!userid()) {
  267. redirect('/Login/index.html');
  268. }
  269. $this->display();
  270. }
  271. //修改密码处理
  272. public function sub_respwd($oldpwd,$newpwd){
  273. if($_POST){
  274. if(checkstr($oldpwd) || checkstr($newpwd)){
  275. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  276. }
  277. $uid = userid();
  278. if($uid == ''){
  279. $this->ajaxReturn(['code'=>0,'info'=>L('请先登陆')]);
  280. }
  281. $info = M("user")->where(array('id'=>$uid))->field("id,username,password")->find();
  282. if(md5($oldpwd) != $info['password']){
  283. $this->ajaxReturn(['code'=>0,'info'=>L('旧密码不正确')]);
  284. }
  285. $result = M("user")->where(array('id'=>$uid))->save(array('password'=>md5($newpwd),'stoptime'=>time()));
  286. if($result){
  287. $this->ajaxReturn(['code'=>1,'info'=>L('密码修改成功')]);
  288. }else{
  289. $this->ajaxReturn(['code'=>0,'info'=>L('密码修改失败')]);
  290. }
  291. }else{
  292. $this->ajaxReturn(['code'=>0,'info'=>L('非法操作')]);
  293. }
  294. }
  295. //账户总览
  296. public function index()
  297. {
  298. if (!userid()) {
  299. redirect('/Login/index.html');
  300. }
  301. $uid = userid();
  302. $fields = "id,username,rzstatus,logintime,loginip";
  303. $uinfo = M("user")->where(array('id'=>$uid))->field($fields)->find();
  304. $uarr = explode("@",$uinfo['username']);
  305. $uinfo['name'] = substr($uarr[0],0,4)."***@".$uarr[1];
  306. $uinfo['uid'] = '7012'.$uinfo['id'];
  307. $uheader = substr($uinfo['username'],0,2);
  308. $this->assign('uheader',$uheader);
  309. $this->assign('uinfo',$uinfo);
  310. //USDT余额查询
  311. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  312. $balance = $minfo['usdt'] + $minfo['usdtd'];
  313. $this->assign('balance',$balance);
  314. //公告查询
  315. $notice = M("content")->where(array('status'=>1))->order("id desc")->limit(2)->field("id,title,addtime")->select();
  316. $this->assign('notice',$notice);
  317. //未成效币币委托
  318. $where['ordertype'] = 1;
  319. $where['status'] = 1;
  320. $where['uid'] = $uid;
  321. $bblist = M("bborder")->where($where)->order("id desc")->select();
  322. $this->assign('bblist',$bblist);
  323. //未成交快速合约
  324. $hylist = M("hyorder")->where(array('uid'=>$uid,'status'=>1))->order("id desc")->limit(20)->select();
  325. $this->assign("hylist",$hylist);
  326. $this->display();
  327. }
  328. //实名认证处理
  329. public function upauthrz($phone,$cardzm,$cardfm){
  330. if (checkstr($phone) || checkstr($cardzm) || checkstr($cardfm)) {
  331. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  332. }
  333. $uid = userid();
  334. $userinfo = M("user")->where(array('id'=>$uid))->find();
  335. if($uid <= 0){
  336. $this->ajaxReturn(['code'=>0,'info'=>L('请先登陆')]);
  337. }
  338. $uinfo = M("user")->where(array('phone'=>$phone))->find();
  339. if(!empty($uinfo)){
  340. $this->ajaxReturn(['code'=>0,'info'=>L('手机号已绑定')]);
  341. }
  342. if($uinfo['rzstatus'] == 1){
  343. $this->ajaxReturn(['code'=>0,'info'=>L('不能重复认证')]);
  344. }
  345. if($cardzm == ""){
  346. $this->ajaxReturn(['code'=>0,'info'=>L('请上传上传身份证正面')]);
  347. }
  348. if($cardfm == ""){
  349. $this->ajaxReturn(['code'=>0,'info'=>L('请上传上传身份证背面')]);
  350. }
  351. $data['phone'] = $phone;
  352. $data['cardzm'] = $cardzm;
  353. $data['cardfm'] = $cardfm;
  354. $data['rzstatus'] = 1;
  355. $data['rztime'] = time();
  356. $re = M("user")->where(array('id'=>$uid))->save($data);
  357. if($re){
  358. $notice['uid'] = $uid;
  359. $notice['account'] = $userinfo['username'];
  360. $notice['title'] = L('认证资料提交成功,耐心等待管理员审核');
  361. $notice['content'] = L('实名资料提成功,耐心等待管理员审核');
  362. $notice['addtime'] = date("Y-m-d H:i:s",time());
  363. $notice['status'] = 1;
  364. M("notice")->add($notice);
  365. $this->ajaxReturn(['code'=>1,'info'=>L('认证资料提交成功,耐心等待管理员审核')]);
  366. }else{
  367. $this->ajaxReturn(['code'=>0,'info'=>L('认证资料提交失败')]);
  368. }
  369. }
  370. //实名认证页面
  371. public function authrz(){
  372. $uid = userid();
  373. if($uid <= 0){
  374. redirect('/Login/index.html');
  375. }
  376. $userinfo = M("user")->where(array('id'=>$uid))->find();
  377. $this->assign("info",$userinfo);
  378. $this->display();
  379. }
  380. //提币地址管理
  381. public function addresslist()
  382. {
  383. if (!userid()) {
  384. redirect('/Login/index.html');
  385. }
  386. //获取币种
  387. $filds = "id,name,czline,title";
  388. $coinlist = M("coin")->where(array('txstatus'=>1))->field($filds)->select();
  389. $this->assign("coinlist",$coinlist);
  390. //获取用户地址列表
  391. $uid = userid();
  392. $qblist = M("user_qianbao")->where(array('userid'=>$uid))->select();
  393. $this->assign("qblist",$qblist);
  394. $this->display();
  395. }
  396. //删除提币地址
  397. public function deladdress($aid){
  398. $uid = userid();
  399. if($uid <= 0){
  400. redirect('/Login/index.html');
  401. }
  402. $ainfo = M("user_qianbao")->where(array('id'=>$aid))->find();
  403. if(empty($ainfo)){
  404. $this->ajaxReturn(['code'=>0,'info'=> L('提币地址不存在')]);
  405. }
  406. $delre = M("user_qianbao")->where(array('id'=>$aid))->delete();
  407. if($delre){
  408. $this->ajaxReturn(['code'=>1,'info'=> L('删除成功')]);
  409. }else{
  410. $this->ajaxReturn(['code'=>0,'info'=> L('删除失败')]);
  411. }
  412. $this->display();
  413. }
  414. //添加地址处理
  415. public function upplusaddress(){
  416. if($_POST){
  417. $uid = userid();
  418. if($uid <= 0){
  419. $this->ajaxReturn(['code'=>0,'msg'=> L('请先登陆')]);
  420. }
  421. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username")->find();
  422. $address = trim(I('post.address'));
  423. $remark = trim(I('post.remark'));
  424. $oid = trim(I('post.oid'));
  425. if($oid <= 0){
  426. $this->ajaxReturn(['code'=>0,'msg'=> L('缺少重要参数')]);
  427. }
  428. if($address == ''){
  429. $this->ajaxReturn(['code'=>0,'msg'=> L('请输入提币地址')]);
  430. }
  431. if($remark == ''){
  432. $this->ajaxReturn(['code'=>0,'msg'=> L('请输入备注')]);
  433. }
  434. $cinfo = M("coin")->where(array('id'=>$oid))->find();
  435. $data['userid'] = $uid;
  436. $data['coinname'] = $uinfo['username'];
  437. $data['czline'] = trim(I('post.czline'));
  438. $data['name'] = $cinfo['name'];
  439. $data['remark'] = $remark;
  440. $data['addr'] = $address;
  441. $data['sort'] = 1;
  442. $data['addtime'] = date("Y-m-d H:i:s",time());
  443. $data['status'] = 1;
  444. $result = M('user_qianbao')->add($data);
  445. if($result){
  446. $this->ajaxReturn(['code'=>1,'msg'=> L('添加成功')]);
  447. }else{
  448. $this->ajaxReturn(['code'=>0,'msg'=> L('添加失败')]);
  449. }
  450. }else{
  451. }
  452. }
  453. //上传图片
  454. public function recharge_img(){
  455. $upload = new \Think\Upload();
  456. $upload->maxSize = 3145728;
  457. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
  458. $upload->rootPath = './Public/Static/payimgs/';
  459. $upload->autoSub = false;
  460. $info = $upload->upload();
  461. $host = $_SERVER['HTTP_HOST'];
  462. foreach ($info as $k => $v) {
  463. $path = $v['savepath'] . $v['savename'];
  464. $response = array(
  465. 'code' => 0,
  466. 'msg' => L('上传成功'),
  467. 'data' => array(
  468. 'src' => 'http://'.$host.'/Public/Static/payimgs/'.$path,
  469. 'img' => $path
  470. )
  471. );
  472. echo json_encode($response);
  473. exit();
  474. }
  475. }
  476. }
  477. ?>