Member.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  1. <?php
  2. /**
  3. * 用户 控制器
  4. * Created by PhpStorm.
  5. * User: Administrator
  6. * Date: 2019/9/29
  7. * Time: 14:11
  8. */
  9. namespace app\mobile\controller;
  10. use app\api\controller\Api;
  11. use think\Config;
  12. use app\common\library\FileUpload;
  13. class Member extends Mobile
  14. {
  15. private $_passwordSalt = ''; // 密码加密的盐
  16. private $_encryptMethod = ''; // 密码加密方法
  17. private $_passwordEncrypt = null; // 加密密码
  18. private $_password = null; // 密码明文
  19. private $_username = null; // 用户名
  20. private $_mobile = ''; // 手机号
  21. private $_nameLengthMin = 6; // 用户名最小长度
  22. private $_nameLengthMax = 11; // 用户名最大长度
  23. private $_pswdLengthMin = 6; // 密码最小长度
  24. private $_pswdLengthMax = 15; // 密码最大长度
  25. private $_registerMsgCode = 'SMS_192577923'; //'【麻花网络游戏】您正在进行注册,验证码:[%s],有效期10分钟,请勿向任何人提供您收到的验证码。'; // 手机号注册短信验证码格式
  26. private $_findPwdMsgCode = 'SMS_192542814'; //'【麻花网络游戏】您正在找回密码,验证码:[%s],有效期10分钟。请勿向任何人提供您收到的验证码。'; // 忘记密码-手机验证身份
  27. private $_bindEmailVLMobile = 'SMS_192572807'; //'【麻花网络游戏】您正在换绑邮箱,验证码:[%s],有效期10分钟。请勿向任何人提供您收到的验证码。'; // 绑定邮箱-手机验证身份
  28. private $_bindEmail = 'SMS_192577915'; //'【麻花网络游戏】您正在绑定邮箱,验证码:[%s],有效期10分钟。请勿向任何人提供您收到的验证码。'; // 绑定邮箱
  29. private $_bindMobile = 'SMS_192532751'; //'【麻花网络游戏】您正在绑定手机,验证码:[%s],有效期10分钟。请勿向任何人提供您收到的验证码。'; // 绑定手机
  30. private $_bindMobileVLMobile = 'SMS_192532752'; //'【麻花网络游戏】您正在换绑手机,验证码:[%s],有效期10分钟。请勿向任何人提供您收到的验证码。'; // 绑定手机-手机验证身份
  31. /**
  32. * 初始化操作
  33. */
  34. protected function _initialize()
  35. {
  36. parent::_initialize();
  37. }
  38. /**
  39. * 登录
  40. */
  41. public function login() {
  42. if ($this->request->isAjax()){
  43. $username = $this->request->param('username' , '' );
  44. $password = $this->request->param('password' , '' );
  45. $Ticket = $this->request->param('ticket' , '' );
  46. $Randstr = $this->request->param('randstr' , '' );
  47. $username = strtolower($username);
  48. if ( empty($username)) $this->jsonResult([],-1,'请输入用户名');
  49. if ( empty($password) ) $this->jsonResult([],-2,'请输入密码');
  50. $slider = $this->sliderVelidate($Ticket,$Randstr);
  51. if (!$slider['code']) $this->jsonResult([],0,$slider['msg']);
  52. $this->_username = $username;
  53. $this->_password = $password;
  54. $member = model('Members')->field(["id","username","password","email","fromflag","reg_time",'flag','nickname','avatar'])->where(["username"=>$this->_username])->find();
  55. if ( empty($member) ) $this->jsonResult([],-2,'用户名或密码错误');
  56. if ( !empty($member['flag']) ) $this->jsonResult([],-1,'该用户已被冻结,请联系客服');
  57. if ( $member['password'] != $this->getPassword() ) $this->jsonResult([],-2,'用户名或密码错误');
  58. unset($member['password']);
  59. session('front_userid',$member['id']);
  60. session('front_account',$member['username']);
  61. $userinfo = array('front_userid'=>$member['id'], 'front_account'=>$username);
  62. $userinfo = json_encode($userinfo);
  63. setcookie('t', auth_code($userinfo, 'ENCODE'), time()+86400, '/', SECOND_DOMAIN);
  64. if (empty($member['nickname'])) {
  65. $newNickname = model('Members')->creatNickname($member['id']);
  66. /*$member['nickname'] = $newNickname;*/
  67. }
  68. /*session('front_info',$member);*/
  69. $preUrl = $this->getPrePageUrl();
  70. $this->success('登录成功!',$preUrl);
  71. }
  72. if (session('front_userid')){
  73. $this->redirect($this->defaultPage);
  74. exit;
  75. }
  76. $this->setPreUrl();
  77. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  78. $this->assign('appid',$appid);
  79. return $this->fetch();
  80. }
  81. /**
  82. * 退出登录
  83. */
  84. public function logout(){
  85. setcookie('t', '', time()-1, '/', SECOND_DOMAIN);
  86. session(null);
  87. session_destroy();
  88. $this->jsonResult($this->defaultPage,1,'退出登录成功!');
  89. }
  90. // 获取加密密码
  91. public function getPassword() {
  92. $password = (string)$this->_passwordEncrypt;
  93. if ( empty($password) ) {
  94. switch ( strtoupper($this->_encryptMethod) ) {
  95. case 'MD5':
  96. $password = $this->_md5Code($this->_password, $this->_passwordSalt);
  97. break;
  98. default:
  99. $password = $this->_authCode($this->_password, $this->_passwordSalt);
  100. break;
  101. }
  102. $this->_passwordEncrypt = $password;
  103. }
  104. return $password;
  105. }
  106. private function _md5Code($password,$salt='') {
  107. return md5($password . $salt);
  108. }
  109. private function _authCode($password,$salt='') {
  110. return auth_code($password, 'ENCODE', $salt);
  111. }
  112. public function userReg(){
  113. if (session('front_userid')){
  114. $this->redirect($this->defaultPage);exit;
  115. }
  116. $this->setPreUrl();
  117. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  118. $this->assign('appid',$appid);
  119. return $this->fetch('user_reg');
  120. }
  121. /**
  122. * 注册
  123. */
  124. public function register(){
  125. if ($this->request->isPost()){
  126. $type = $this->request->param('type', '');
  127. $username = $this->request->param('username','');
  128. $password = $this->request->param('password','');
  129. $password_1 = $this->request->param('passwordone','');
  130. $sms_code = $this->request->param('smsCode','');
  131. if ( empty($username)) {
  132. $this->jsonResult([],-1,($type == 'phone') ? '请输入正确的手机号' : '请输入正确的用户名,'.$this->_nameLengthMin.'-'.$this->_nameLengthMax.'位字母或数字');
  133. }
  134. if ( empty($password_1) ) {
  135. $this->jsonResult([],-2,'请输入正确的密码,'.$this->_pswdLengthMin.'-'.$this->_pswdLengthMax.'位字符');
  136. }
  137. if ( empty($password) ) {
  138. $this->jsonResult([],-3,'请再次输入密码');
  139. }
  140. if ($password_1 != $password){
  141. $this->jsonResult([],-3,'两次输入的密码不一致');
  142. }
  143. if ( ! $this->checkPassword($password,false) ) {
  144. $this->jsonResult([],-2,"请输入正确的密码,{$this->_pswdLengthMin} - {$this->_pswdLengthMax}位字符");
  145. }
  146. $this->_username = $username;
  147. if($type == 'phone') {
  148. $result = (new \app\common\library\Sms)->checkCode($username,$sms_code);
  149. if(!$result['status']) {
  150. $this->error($result['msg']);
  151. }
  152. $this->_mobile = $username;
  153. } elseif($type == 'username') {
  154. $resUser = $this->checkUsername($username,false);
  155. if (!$resUser['code']) $this->jsonResult([],-1,$resUser['msg']);
  156. } else {
  157. $this->error('非法请求!');
  158. }
  159. if ( $this->isExistUser($this->_username) ) {
  160. $this->jsonResult([],-1,($type == 'phone') ? '该手机号已经被注册' : '该用户名已经被注册' );
  161. }
  162. if($type == 'username') {
  163. $Ticket = $this->request->param('ticket' , '' );
  164. $Randstr = $this->request->param('randstr' , '' );
  165. $resUser = $this->sliderVelidate($Ticket,$Randstr);
  166. if (!$resUser['code']) $this->jsonResult([],0,$resUser['msg'] );
  167. }
  168. $ip = GetIP(0);
  169. $device = getDevice();
  170. $agent = 'default';
  171. /*! empty($passwordSalt) && $this->setPasswordSalt($passwordSalt);
  172. ! empty($encryptMethod) && $this->setEncryptMethod($encryptMethod);*/
  173. $this->_passwordEncrypt = $this->getPassword();
  174. $last_user_id = model('Members')->insertGetId(["username"=>$this->_username,"password"=>$this->_passwordEncrypt,"mobile"=>$this->_mobile,"agent"=>$agent, "device"=>$device,"ip"=>$ip,"reg_time"=>$_SERVER['REQUEST_TIME'], 'channel_id'=>MEMBER_DEFAULT_CHANNEL_ID]);
  175. if ( $last_user_id <= '0' ) {
  176. $this->error('注册失败');
  177. return false;
  178. }
  179. $this->insertChangeLog($last_user_id, $password,null,$this->_mobile);
  180. session('front_userid',$last_user_id);
  181. session('front_account',$this->_username);
  182. // 加密用户信息,用于跨二级域名登录
  183. $userinfo = array('front_account'=>$username,'front_userid'=>$last_user_id);
  184. $userinfo = json_encode($userinfo);
  185. setcookie('t', auth_code($userinfo, 'ENCODE'), time()+86400, '/', SECOND_DOMAIN);
  186. $newNickname = model('Members')->creatNickname($last_user_id);
  187. /*$member = [
  188. 'id' => $last_user_id ,
  189. "username" => $this->_username ,
  190. 'nickname' => $newNickname ,
  191. "avatar" => '' ,
  192. "reg_time" => $_SERVER['REQUEST_TIME']
  193. ];
  194. session('front_info',$member);*/
  195. $this->success('注册成功!',$this->getPrePageUrl());
  196. }
  197. $this->error('非法请求!');
  198. }
  199. /**
  200. * 发送手机验证码
  201. */
  202. public function sendCode($isExistUser = false) {
  203. $phone = $this->request->param('phone', '');
  204. if (!$this->checkMobile($phone)) {
  205. $this->error('请输入正确的手机号');
  206. }
  207. if ($isExistUser){
  208. $res = $this->isExistUser($phone);
  209. if ($res) $this->jsonResult([],-1,'该手机号已被注册');
  210. }
  211. $Ticket = $this->request->param('ticket' , '' );
  212. $Randstr = $this->request->param('randstr' , '' );
  213. $slider = $this->sliderVelidate($Ticket,$Randstr);
  214. if (!$slider['code']) $this->jsonResult([],0,$slider['msg']);
  215. $result = (new \app\common\library\Sms)->sendCode($phone,$this->_registerMsgCode);
  216. if ($result['status']) $this->success('验证码发送成功');
  217. $this->error($result['msg']);
  218. }
  219. // 校验用户名是否符合规则
  220. public function checkUsername($username,$isExit = true) {
  221. if($this->checkMobile($username)) {
  222. if ($isExit) $this->error('手机号请选择手机号注册方式');
  223. return ['code'=>0,'msg'=>'手机号请选择手机号注册方式'];
  224. } elseif ( strlen($username) < $this->_nameLengthMin || strlen($username) > $this->_nameLengthMax || preg_match('/[^0-9A-Za-z_]/', $username)) {
  225. if ($isExit) $this->error("请输入正确的用户名,{$this->_nameLengthMin} - {$this->_nameLengthMax}位字母或数字");
  226. return ['code'=>0,'msg'=>"请输入正确的用户名,{$this->_nameLengthMin} - {$this->_nameLengthMax}位字母或数字"];
  227. }else {
  228. $this->_username = $username;
  229. return ['code'=>1,'msg'=>''];
  230. }
  231. }
  232. /**
  233. * 检查是否为手机号
  234. */
  235. public function checkMobile($phone){
  236. $preg = '/^1[0123456789]{1}\d{9}$/';
  237. if (0 == preg_match($preg, $phone)) {
  238. return false;
  239. }
  240. return true;
  241. }
  242. /**
  243. * 判断用户是否存在
  244. * @param string $username 用户名
  245. * @return boolean
  246. */
  247. public function isExistUser($username) {
  248. $username = filterAndTrimInput($username);
  249. $result = model('Members')->field('id')->where(["username"=>$username])->find();
  250. if ( isset($result['id']) && $result['id'] > 0 ) {
  251. return true;
  252. }
  253. return false;
  254. }
  255. public function insertChangeLog($userid,$password=null,$email=null,$mobile=null) {
  256. $record = ['userid' => $userid, 'ip' => GetIP(1), 'create_time' => NOW_TIMESTAMP];
  257. !empty($password) && $record['password'] = auth_code($password, 'ENCODE');
  258. !empty($email) && $record['email'] = $email;
  259. !empty($mobile) && $record['mobile'] = $mobile;
  260. return model('MemberHistory')->insertGetId($record);
  261. }
  262. /**
  263. * 校验密码是否符合规则
  264. * @param $password
  265. * @return bool
  266. */
  267. public function checkPassword($password,$isReturn = true) {
  268. if ( strlen($password) > $this->_pswdLengthMax || strlen($password) < $this->_pswdLengthMin ) {
  269. if ($isReturn) $this->error("请输入正确的密码,{$this->_pswdLengthMin} - {$this->_pswdLengthMax}位字符");
  270. return false;
  271. } else {
  272. $this->_password = strval($password);
  273. return true;
  274. }
  275. }
  276. /**
  277. * 忘记密码-- 确认账号
  278. */
  279. public function contactAccount(){
  280. if ($this->request->isAjax()){
  281. $username = input('post.username' , '' );
  282. if (empty($username)) $this->error('用户名不能为空');
  283. $Ticket = $this->request->param('ticket' , '' );
  284. $Randstr = $this->request->param('randstr' , '' );
  285. $slider = $this->sliderVelidate($Ticket,$Randstr);
  286. if (!$slider['code']) $this->jsonResult([],0,$slider['msg']);
  287. $info = model('Members')->field('id,email,mobile,username,flag')->where(["username" => $username])->find();
  288. if (empty($info)) $this->error('用户名不存在');
  289. if ( !empty($info['flag']) ) $this->error('该用户已被冻结,请联系客服');
  290. if ( !empty($info['email'])) $info['email'] = mailObfuscation($info['email']);
  291. if ( !empty($info['mobile'])) $info['mobile'] = stringObfuscation($info['mobile'] , 3);
  292. session('check_uid',$info);
  293. $this->success('',getMobileForgetPwdUrl(2));
  294. }
  295. if (session('front_userid')){
  296. $this->redirect($this->defaultPage);exit;
  297. }
  298. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  299. $this->assign('appid',$appid);
  300. return $this->fetch('contact_account');
  301. }
  302. /**
  303. * 忘记密码--提供验证方式
  304. */
  305. public function contactWay() {
  306. $info = session('check_uid');
  307. if (session('front_userid')){
  308. $this->redirect($this->defaultPage);exit;
  309. }
  310. if (!$info) $this->error('非法请求');
  311. $this->assign('info',$info);
  312. return $this->fetch('contact_way');
  313. }
  314. /**
  315. * 忘记密码--提供验证方式--邮箱或者手机号验证
  316. */
  317. public function contact() {
  318. if (session('front_userid')){
  319. $this->redirect($this->defaultPage);exit;
  320. }
  321. $typeArr = ['phone' , 'email'];
  322. $type = $this->request->param('type' , '' );
  323. $info = session('check_uid');
  324. if (!$info || !in_array($type,$typeArr)) $this->redirect(getMobileForgetPwdUrl(2));
  325. $this->assign('info',$info);
  326. $this->assign('type',$type);
  327. return $this->fetch();
  328. }
  329. /**
  330. * 忘记密码--发送验证码
  331. */
  332. public function resetPwdSendCode(){
  333. $type = input('post.type' , '' );
  334. $id = session('check_uid')['id'];
  335. $typeArr = ['phone' , 'email'];
  336. if (!in_array($type,$typeArr) || empty($id)) $this->error('非法请求');
  337. $info = model('Members')->field('id,username,email,mobile')->where(["id" => $id , 'flag' => 0])->find();
  338. if ($type == $typeArr[0]){
  339. $result = (new \app\common\library\Sms)->sendCode($info['mobile'],$this->_findPwdMsgCode);
  340. }else{
  341. $result = (new \app\common\library\Mail)->sendCodeMailByType($info['username'], $info['email']);
  342. }
  343. if(isset($result) && $result['status']){
  344. $this->jsonResult([],1,'发送成功');
  345. }else{
  346. $this->jsonResult([],0,$result['msg']);
  347. }
  348. }
  349. /**
  350. * 忘记密码--验证验证码
  351. */
  352. public function resetPwdCheckCode() {
  353. $id = session('check_uid')['id'];
  354. $code = input('post.code' , 0 , 'intval');
  355. $type = input('post.type' , '' );
  356. $typeArr = ['phone' , 'email'];
  357. if ( !in_array($type , $typeArr) || empty($id)) $this->jsonResult([],0,'非法请求');
  358. if (empty($code)) $this->jsonResult([],0,'请输入验证码');
  359. $info = model('Members')->field('id,username,email,mobile')->where(["id" => $id , 'flag' => 0])->find();
  360. if ($type == $typeArr[0]) {
  361. $result = (new \app\common\library\Sms)->checkCode($info['mobile'] , $code);
  362. } else {
  363. $result = (new \app\common\library\Mail)->checkCode($info['username'] , $info['email'] , $code);
  364. }
  365. if (isset($result) && $result['status']) {
  366. session('hasCheck',true);
  367. $this->success('验证成功',getMobileForgetPwdUrl(3));
  368. }
  369. $errMsg = $result['msg'];
  370. $this->jsonResult([],0,$errMsg);
  371. }
  372. /**
  373. * 忘记密码--重置密码
  374. */
  375. public function forgetPwdToReset(){
  376. if (session('front_userid')){
  377. $this->redirect($this->defaultPage);exit;
  378. }
  379. if ($this->request->isAjax()){
  380. $id = session('check_uid')['id'];
  381. $password1 = input('post.password1' , '' );
  382. $password2 = input('post.password2' , '' );
  383. if (empty($id)) $this->jsonResult([],0,'非法请求');
  384. if (empty($password1)) $this->jsonResult([],-1,'请输入新密码,'.$this->_pswdLengthMin.'-'.$this->_pswdLengthMax.'位字符');
  385. if (empty($password2)) $this->jsonResult([],-2,'请再次输入密码');
  386. //if (!session('hasCheck')) $this->error('请先通过身份验证');
  387. if ($password1 != $password2) $this->jsonResult([],-2,'两次输入的密码不一致');
  388. $res = $this->resetPassword($id,$password1);
  389. if ($res == 3) $this->jsonResult([],-1,'请输入正确的密码,'.$this->_pswdLengthMin.'-'.$this->_pswdLengthMax.'位字符');
  390. if ($res == 1 || $res == 2) {
  391. session('hasCheck',null);
  392. session('check_uid',null);
  393. $this->success('重置成功',getMobileEncodeUrl('login'));
  394. }
  395. if ($res == 0) $this->jsonResult([],-2,'新密码不能与旧密码相同');
  396. }
  397. return $this->fetch('forget_pwd_to_reset');
  398. }
  399. /**
  400. * 重置密码
  401. *$flag: 账号是否解冻 1解冻 0不解冻
  402. * return:0新密码不能与旧密码相同,1密码重置成功,2密码重置失败,3密码格式不正确
  403. */
  404. public function resetPassword($id,$password1,$flag = 0){
  405. $res1 = $this->checkPassword($password1,false);
  406. if (!$res1) return 3;
  407. $info = model('Members')->field('id,username,email,mobile,password')->where(["id" => $id])->find();
  408. $this->_passwordEncrypt = $this->getPassword();
  409. if ($this->_passwordEncrypt == $info['password']) return 0;
  410. $data = ['password' => $this->_passwordEncrypt];
  411. if ($flag == 1) $data['flag'] = 0;
  412. $res = model('Members')->save($data,['id' => $id]);
  413. if ($res){
  414. session(null);
  415. session_destroy();
  416. setcookie('t', '', time()-1, '/', SECOND_DOMAIN);
  417. $record = [
  418. 'userid' => $id ,
  419. 'ip' => GetIP(1) ,
  420. 'password' => $this->_passwordEncrypt ,
  421. 'create_time' => NOW_TIMESTAMP,
  422. ];
  423. model('MemberHistory')->insertGetId($record);
  424. return 1;
  425. }
  426. return 2;
  427. }
  428. /**
  429. * 个人中心
  430. */
  431. public function personalCenter(){
  432. $this->_isLogin();
  433. $userName = model('Members')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->field('nickname,avatar')->where(['id'=>session('front_userid')])->find();
  434. $this->assign('user_name',$userName);
  435. return $this->fetch('personal_center');
  436. }
  437. /**
  438. * 滑块验证
  439. * @param $Ticket
  440. * @param $Randstr
  441. * @return array
  442. */
  443. public function sliderVelidate($Ticket,$Randstr){
  444. // todo 开发环境跳过滑块验证
  445. if (APP_STATUS == 'dev') return ['code'=>1,'msg'=>''];
  446. if ( empty($Ticket) || empty($Randstr) ) return ['code'=>0,'msg'=>'非法请求'];
  447. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  448. $AppSecretKey = Config::get('SLIDER_VERIFICATION.AppSecretKey');
  449. $url = Config::get('SLIDER_VERIFICATION.VERIFYURL');
  450. $UserIP = GetIP(1);
  451. $params = array(
  452. "aid" => "$appid" ,
  453. "AppSecretKey" => $AppSecretKey ,
  454. "Ticket" => $Ticket ,
  455. "Randstr" => $Randstr ,
  456. "UserIP" => $UserIP
  457. );
  458. $paramstring = http_build_query($params);
  459. $content = txcurl($url,$paramstring);
  460. $result = json_decode($content,true);
  461. if($result){
  462. if($result['response'] == 1){
  463. return ['code'=>1,'msg'=>''];
  464. }else{
  465. return ['code'=>0,'msg'=>'系统繁忙,请稍后再试!'];
  466. }
  467. }else{
  468. return ['code'=>0,'msg'=>'系统繁忙,请稍后再试!'];
  469. }
  470. }
  471. /**
  472. * 个人中心--个人资料
  473. */
  474. public function personalInfo(){
  475. $this->_isLogin();
  476. $defaultBrith = '0000-00-00';
  477. $info = $this->getUserInfo();
  478. if ($info['birthday'] == $defaultBrith) $info['birthday'] = null;
  479. $this->assign('info',$info);
  480. return $this->fetch('personal_info');
  481. }
  482. /**
  483. * 个人中心--个人资料--编辑
  484. */
  485. public function editInfo(){
  486. if (!session('?front_userid')){
  487. $this->error('请先登录!');
  488. }
  489. $files = $data = ['sex' , 'qq' , 'address' , 'zipcode' , 'birthday' ];
  490. $type = input('post.name' , '' );
  491. $value = input('post.value' , '' );
  492. if (empty($type) || !in_array($type,$files)) $this->error('参数错误!');
  493. if($type == $files[1] && !empty($value) && 0 == preg_match('/^\d*$/', $value)) {
  494. $this->jsonResult('',0,'请输入正确的QQ号');
  495. }
  496. if($type == $files[3] && !empty($value) && 0 == preg_match('/^(\d{6})?$/', $value)) {
  497. $this->jsonResult('',0,'请输入正确的邮政编码');
  498. }
  499. if($type == $files[2] && !empty($value) && iconv_strlen($value,"UTF-8") >40) {
  500. $this->jsonResult('',0,'联系地址不能超过40个字');
  501. }
  502. $data = [$type=>$value];
  503. model('MembersTwo')->updateInfo($data, session('front_userid'));
  504. $this->success('保存成功',getMobileUserCenterUrl(1));
  505. }
  506. /**
  507. * 获取用户资料
  508. */
  509. public function getUserInfo(){
  510. $id = session('front_userid');
  511. $info = model('Members')->alias('m')
  512. ->join('cy_memberstwo t','m.id=t.userid','left')
  513. ->field('m.id,m.username,t.sex,t.qq,t.birthday,t.zipcode,t.address,t.id as memberstwo_id,m.nickname,m.avatar')
  514. ->where(["m.id" => $id , 'm.flag' => 0])
  515. ->find();
  516. return $info;
  517. }
  518. /**
  519. * 个人中心--个人资料--QQ
  520. */
  521. public function editqq(){
  522. $info = $this->getUserInfo();
  523. $this->assign('qq',$info['qq']);
  524. return $this->fetch('personal_qq');
  525. }
  526. /**
  527. * 个人中心--个人资料--联系地址
  528. */
  529. public function editaddress(){
  530. $info = $this->getUserInfo();
  531. $this->assign('address',$info['address']);
  532. return $this->fetch('personal_addr');
  533. }
  534. /**
  535. * 个人中心--个人资料--邮政编码
  536. */
  537. public function editzipcode(){
  538. $info = $this->getUserInfo();
  539. $this->assign('zipcode',$info['zipcode']);
  540. return $this->fetch('personal_zipcode');
  541. }
  542. /**
  543. * 前置方法(参数获取)
  544. */
  545. protected function _beforeGetParams()
  546. {
  547. $start = $this->request->param('start' , '');
  548. $end = $this->request->param('end' , '');
  549. $orderid = $this->request->param('orderid' , '' , 'trim');
  550. $gamename = $this->request->param('gamename' , '' , 'trim');
  551. $status = $this->request->param('status' , '');
  552. $condition = [];
  553. if ( !in_array($status , ['' , 0 , 1 , 2])) $status = '';
  554. $condition = ['p.userid' => session('front_userid')];
  555. if ($status != '') {
  556. $condition['p.status'] = $status;
  557. }
  558. if (!empty($orderid)) {
  559. $condition['p.orderid'] = $orderid;
  560. }
  561. if (!empty($gamename)) {
  562. $condition['g.nickname'] = ['LIKE', '%' . $gamename . '%'];
  563. }
  564. //开始时间和结束时间不为空时
  565. if ($start != '' && $end != '') {
  566. $condition['p.create_time'] = [
  567. ['>=', strtotime($start)],
  568. ['<=', strtotime($end . ' 23:59:59')],
  569. ];
  570. } //开始时间不为空时
  571. elseif ($start != '') {
  572. $condition['p.create_time'] = ['>=', strtotime($start)];
  573. } //结束时间不为空时
  574. elseif ($end != '') {
  575. $condition['p.create_time'] = ['<=', strtotime($end . ' 23:59:59')];
  576. } else {
  577. }
  578. return ['where'=>$condition,'start'=>$start,'end'=>$end,'status'=>$status];
  579. }
  580. /**
  581. * 个人中心--充值记录
  582. */
  583. public function personalPay(){
  584. $this->_isLogin();
  585. $GetParams = $this->_beforeGetParams();
  586. $condition = $GetParams['where'];
  587. $PayModel = model('Common/Pay');
  588. $list = $PayModel->alias('p')->field('p.id,p.orderid,p.amount,p.create_time,g.nickname,p.status,p.productname,info.mobileicon')
  589. ->join('cy_game g','p.gameid=g.id','left')
  590. ->join('cy_gameinfo info', 'g.id = info.game_id')
  591. ->where($condition)
  592. ->order('p.create_time desc')
  593. ->paginate(10, false, ['query' => input('get.')])
  594. ->each(function ($item,$index){
  595. $item['amount'] = intval($item['amount']);
  596. $item['icon'] = getGameIcon($item['mobileicon']);
  597. $item['pay_status'] = '';
  598. switch ($item['status']){
  599. case 0: $item['pay_status'] = '未支付';
  600. break;
  601. case 1: $item['pay_status'] = '支付成功';
  602. break;
  603. case 2: $item['pay_status'] = '支付失败';
  604. break;
  605. }
  606. return $item;
  607. });
  608. if ($this->request->isAjax()) $this->jsonResult($list,1);
  609. $this->assign('status',$GetParams['status']);
  610. $this->assign('start',$GetParams['start']);
  611. $this->assign('end',$GetParams['end']);
  612. $this->assign('list',$list);
  613. $this->assign('page', $list->render());
  614. return $this->fetch();
  615. }
  616. /**
  617. * 个人中心--存号箱 页面(未过期)
  618. */
  619. public function giftbox(){
  620. $keyword = input('keyword');
  621. $list = $this->memberGift('now',$keyword);
  622. if ($this->request->isAjax()) $this->jsonResult($list,1,'now');
  623. $this->assign('type','now');
  624. $this->assign('list',$list);
  625. $this->assign('keyword',$keyword);
  626. $this->assign('page', $list->render());
  627. return $this->fetch('member_gift');
  628. }
  629. /**
  630. * 个人中心--存号箱 页面(过期)
  631. */
  632. public function giftboxgp(){
  633. $keyword = input('keyword');
  634. $list = $this->memberGift('overtime',$keyword);
  635. if ($this->request->isAjax()) $this->jsonResult($list,1,'overtime');
  636. $this->assign('type','overtime');
  637. $this->assign('list',$list);
  638. $this->assign('page', $list->render());
  639. $this->assign('keyword',$keyword);
  640. return $this->fetch('member_gift');
  641. }
  642. /**
  643. * 个人中心--存号箱(数据)
  644. */
  645. public function memberGift($dateType = '',$keyword=''){
  646. $this->_isLogin();
  647. $condition = ['a.username'=>session('front_account')];
  648. if ($dateType == 'overtime'){
  649. $condition['l.endtime'] = ['elt',NOW_TIMESTAMP];
  650. }elseif ($dateType == 'now'){
  651. $condition['l.endtime'] = ['gt',NOW_TIMESTAMP];
  652. }
  653. if (!empty($keyword)){
  654. $condition['l.title'] = ['like','%'.$keyword.'%'];
  655. }
  656. $list = model('Libaolog')->alias('a')
  657. ->join('cy_libaoinfo l','l.id=a.libaoid')
  658. ->join('cy_game g','g.id=l.gameid','left')
  659. ->join('cy_gameinfo info', 'g.id=info.game_id', 'left')
  660. ->field('a.id,l.title,a.username,a.create_time,g.name,a.code,l.content,l.starttime,l.endtime,info.mobileicon')
  661. ->where($condition)
  662. ->order('a.create_time desc')
  663. ->paginate(10, false, ['query' => input('get.')])
  664. ->each(function ($item,$index){
  665. $item['endtime'] = date('Y-m-d H:i:s',$item['endtime']);
  666. $item['mobileicon'] = getGameIcon($item['mobileicon']);
  667. return $item;
  668. });
  669. return $list;
  670. }
  671. /**
  672. * 个人中心--账号安全
  673. */
  674. public function personalAccount() {
  675. $this->_isLogin();
  676. $id = session('front_userid');
  677. $info = model('Members')->alias('m')
  678. ->join('cy_memberstwo t' , 'm.id=t.userid' , 'left')
  679. ->field('m.id,m.email,m.mobile,t.idcard,t.realname')
  680. ->where(["m.id" => $id , 'm.flag' => 0])
  681. ->find();
  682. $info['isVerified'] = 1;
  683. if (empty($info['realname']) || empty($info['idcard']) || ((- 1 == $info['realname']) && (- 1 == $info['idcard']))) {
  684. $info['isVerified'] = 0;
  685. }
  686. if ( !empty($info['email'])) $info['email'] = mailObfuscation($info['email']);
  687. if ( !empty($info['mobile'])) $info['mobile'] = mobileObfuscation($info['mobile']);
  688. $this->assign('info',$info);
  689. return $this->fetch();
  690. }
  691. /**
  692. * 个人中心--修改密码
  693. */
  694. public function personalChangePwd(){
  695. $this->_isLogin();
  696. if($this->request->isPost() ){
  697. $oldPwd = input('post.oldPwd' , '' );
  698. $password1 = input('post.password1' , '' );
  699. $password2 = input('post.password2' , '' );
  700. if (empty($oldPwd)) $this->jsonResult([],0,'请输入旧密码');
  701. if (empty($password1)) $this->jsonResult([],-1,'请输入密码,6-15位字符');
  702. if (empty($password2)) $this->jsonResult([],-2,'请再次输入密码');
  703. if ($oldPwd == $password1) $this->jsonResult([],-1,'新密码不能与旧密码相同');
  704. if ($password1 != $password2) $this->jsonResult([],-2,'两次输入的密码不一致');
  705. $this->checkPassword($password1);
  706. $id = session('front_userid');
  707. $info = model('Members')->field('id,username,email,mobile,password')->where(["id" => $id, 'flag' => 0])->find();
  708. $this->_password = $oldPwd;
  709. $this->_passwordEncrypt = $this->getPassword();
  710. if ($this->_passwordEncrypt != $info['password']) $this->jsonResult([],0,'旧密码输入错误');
  711. $this->_password = $password1;$this->_passwordEncrypt = '';
  712. $this->_passwordEncrypt = $this->getPassword();
  713. $res = model('Members')->save(['password' => $this->_passwordEncrypt],['id' => $id]);
  714. model('MemberHistory')->insertGetId(['password' => $this->_passwordEncrypt,'userid'=> $id,'ip' => GetIP(1) ,'create_time' => NOW_TIMESTAMP]);
  715. if ($res) $this->success('修改成功',getMobileUserCenterUrl('4'));
  716. $this->jsonResult([],0,'修改失败');
  717. }
  718. return $this->fetch();
  719. }
  720. /**
  721. * 个人中心--实名认证--页面
  722. */
  723. public function personalIdentityPage(){
  724. $this->_isLogin();
  725. $id = session('front_userid');
  726. $info = model('Members')->alias('m')
  727. ->join('cy_memberstwo t' , 'm.id=t.userid' , 'left')
  728. ->field('m.id,m.email,m.mobile,t.idcard,t.realname')
  729. ->where(["m.id" => $id , 'm.flag' => 0])
  730. ->find();
  731. if (empty($info['realname']) || empty($info['idcard']) || ((- 1 == $info['realname']) && (- 1 == $info['idcard']))) {
  732. // 未实名认证
  733. return $this->fetch('identity');
  734. }
  735. if ( !empty($info['realname'])) $info['realname'] = usernameObfuscation($info['realname']);
  736. if ( !empty($info['idcard'])) $info['idcard'] = idcardObfuscation($info['idcard']);
  737. $this->assign('info',$info);
  738. return $this->fetch('identity_info');
  739. }
  740. /**
  741. * 个人中心--实名认证
  742. */
  743. public function personalIdentity(){
  744. $this->_isLogin();
  745. $data = [
  746. 'realname' => input('post.realname', ''),
  747. 'idcard' => input('post.idcard', ''),
  748. ];
  749. $result = $this->validate($data, [
  750. ['realname', 'require|length:2,10|chs', '请输入姓名|姓名只能是2-10位的汉字|姓名只能是2-10位的汉字'],
  751. ['idcard', 'require|identityNumber', '请输入身份证号码|身份证号码格式不正确'],
  752. ]);
  753. if (true !== $result) $this->jsonResult($result,0,$result);
  754. // 通过身份证验证年龄
  755. if (!isMeetAgeByIDCard($data['idcard'],9,120)) $this->jsonResult([], 0, '您未满足年龄要求(9-120岁),无法通过认证');
  756. $res = model('MembersTwo')->updateInfo($data, session('front_userid'));
  757. if ($res) $this->success('实名认证成功',getMobileUserCenterUrl('4'));
  758. $this->jsonResult('', 0, '认证失败');
  759. }
  760. /**
  761. * 个人中心--绑定手机或邮箱--1
  762. */
  763. public function toBindOne(){
  764. $this->_isLogin();
  765. $type = input('type', '');
  766. if (!in_array($type,['mobile','email'])) {
  767. $this->error('请求错误');
  768. }
  769. $id = session('front_userid');
  770. $info = model('Members')->alias('m')
  771. ->field('m.id,m.email,m.mobile')
  772. ->where(["m.id" => $id , 'm.flag' => 0])
  773. ->find();
  774. // 请求绑定手机,就判断是否绑定邮箱;请求绑定邮箱,就判断是否绑定手机
  775. $runable = 'no'; // 是否去先验证另外一个联系方式
  776. if ($type == 'mobile' && (!empty($info['email']) || !empty($info['mobile'])) ) {
  777. $runable = 'email';
  778. }
  779. if ($type == 'email' && (!empty($info['email']) || !empty($info['mobile']))) {
  780. $runable = 'mobile';
  781. }
  782. if ($runable == 'no'){
  783. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  784. $this->assign('appid',$appid);
  785. $this->assign('type',$type);
  786. return $this->fetch('bind_page');
  787. }
  788. session('velidate_info',['type'=>$type,'info_data'=>$info,'velidate_type'=>'']);
  789. $this->assign('type',$type);
  790. $this->assign('info',$info);
  791. return $this->fetch('bind_other');
  792. }
  793. /**
  794. * 个人中心--绑定手机或邮箱--2 验证其他方式的页面
  795. */
  796. public function toVelidatePage(){
  797. $velidate_info = session('velidate_info');
  798. if (empty($velidate_info)) $this->redirect(getUserCenterUrl(1));
  799. $type = input('type', '');
  800. if (!in_array($type,['mobile','email'])) {
  801. $this->redirect(getUserCenterUrl(1,url('member/personalInfo')));
  802. }
  803. $velidate_info['velidate_type'] = $type;
  804. session('velidate_info',$velidate_info);
  805. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  806. $this->assign('appid',$appid);
  807. $this->assign('info',$velidate_info);
  808. return $this->fetch('velidate_page');
  809. }
  810. /**
  811. * 个人中心--绑定手机或邮箱--3 发送验证码
  812. */
  813. public function toVelidateSendCode(){
  814. $velidate_info = session('velidate_info');
  815. if (empty($velidate_info)) $this->error('系统繁忙!');
  816. /*$Ticket = $this->request->param('ticket' , '' );
  817. $Randstr = $this->request->param('randstr' , '' );
  818. $slider = $this->sliderVelidate($Ticket,$Randstr);
  819. if (!$slider['code']) $this->jsonResult([],0,$slider['msg']);*/
  820. $temple = ''; // 短信或邮件模板
  821. if ($velidate_info['velidate_type'] == 'mobile'){
  822. if ($velidate_info['type'] == 'mobile'){
  823. $temple = $this->_bindMobileVLMobile;
  824. }else{
  825. if (empty($velidate_info['info_data']['email'])){
  826. $temple = $this->_bindEmail;
  827. }else{
  828. $temple = $this->_bindEmailVLMobile;
  829. }
  830. }
  831. $result = (new \app\common\library\Sms)->sendCode($velidate_info['info_data']['mobile'],$temple);
  832. }else{
  833. if ($velidate_info['type'] == 'email'){
  834. $temple = 'bindEmailVLEmail';
  835. }else{
  836. if (empty($velidate_info['info_data']['mobile'])){
  837. $temple = 'bindMobil';
  838. }else{
  839. $temple = 'bindMobilVLEmail';
  840. }
  841. }
  842. $result = (new \app\common\library\Mail)->sendCodeMailByType(session('front_account'), $velidate_info['info_data']['email'],$temple);
  843. }
  844. if(isset($result) && $result['status']){
  845. $this->jsonResult([],1,'发送成功');
  846. }else{
  847. $this->jsonResult([],0,$result['msg']);
  848. }
  849. }
  850. /**
  851. * 个人中心--绑定手机或邮箱--4 验证 手机或邮箱验证码
  852. */
  853. public function velidateCode(){
  854. $velidate_info = session('velidate_info');
  855. if (empty($velidate_info)) $this->redirect(getUserCenterUrl(1));
  856. $code = input('post.code' , 0 , 'intval');
  857. if (empty($code)) $this->jsonResult([],0,'请输入验证码');
  858. if ($velidate_info['velidate_type'] == 'mobile') {
  859. $result = (new \app\common\library\Sms)->checkCode($velidate_info['info_data']['mobile'] , $code);
  860. } else {
  861. $result = (new \app\common\library\Mail)->checkCode(session('front_account') , $velidate_info['info_data']['email'] , $code);
  862. }
  863. if (isset($result) && $result['status']) {
  864. $this->success('验证成功',getMobileAccountUrl(2.2) );
  865. }
  866. $this->jsonResult([],0,$result['msg']);
  867. }
  868. /**
  869. * 个人中心--绑定手机或邮箱--5 直接绑定的页面
  870. */
  871. public function bindPage(){
  872. $velidate_info = session('velidate_info');
  873. if (empty($velidate_info)) $this->redirect(getMobileUserCenterUrl(1));
  874. $this->assign('type',$velidate_info['type']);
  875. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  876. $this->assign('appid',$appid);
  877. return $this->fetch();
  878. }
  879. /**
  880. * 个人中心--绑定手机或邮箱--6 发送验证码
  881. */
  882. public function bindSendCode(){
  883. $velidate_info = session('velidate_info');
  884. if (empty($velidate_info)) $this->error('系统繁忙');
  885. $this->directBindSendCode($velidate_info['type']);
  886. }
  887. /**
  888. * 个人中心--绑定手机或邮箱--直接绑定页面--6 发送验证码
  889. */
  890. public function directBindSendCode($type=''){
  891. $contact = $this->request->param('contact');
  892. if (empty($type)) $this->error('系统繁忙');
  893. if (empty($contact)) {
  894. if ($type == 'mobile') $this->error('请输入正确的手机号');
  895. $this->error('请输入正确的邮箱');
  896. }
  897. $Ticket = $this->request->param('ticket' , '' );
  898. $Randstr = $this->request->param('randstr' , '' );
  899. $slider = $this->sliderVelidate($Ticket,$Randstr);
  900. if (!$slider['code']) $this->jsonResult([],0,$slider['msg']);
  901. $velidate_info = session('velidate_info');
  902. if ($type == 'mobile' && $contact == $velidate_info['info_data']['mobile']){
  903. $this->error('新旧手机号不能相同');
  904. }
  905. if ($type == 'email' && $contact == $velidate_info['info_data']['email']){
  906. $this->error('新旧邮箱不能相同');
  907. }
  908. if ($type == 'mobile'){
  909. $result = (new \app\common\library\Sms)->sendCode($contact,$this->_bindMobile);
  910. }else{
  911. $result = (new \app\common\library\Mail)->sendCodeMailByType(session('front_account'), $contact,'bindEmail');
  912. }
  913. if(isset($result) && $result['status']){
  914. $this->jsonResult([],1,'发送成功');
  915. }
  916. $this->jsonResult([],0,$result['msg']);
  917. }
  918. /**
  919. * 个人中心--绑定手机或邮箱--7 进行绑定操作(直接进行绑定)
  920. */
  921. public function directBindContact($type = ''){
  922. $contact = $this->request->param('contact');
  923. $code = $this->request->param('code' , 0 , 'intval');
  924. if (!in_array($type,['mobile','email'])) $this->error('系统繁忙');
  925. if (empty($contact)) {
  926. if ($type == 'mobile') $this->error('请输入正确的手机号');
  927. $this->error('请输入正确的邮箱');
  928. }
  929. if (empty($code)) $this->jsonResult([],0,'请输入验证码');
  930. if ($type == 'mobile') {
  931. $result = (new \app\common\library\Sms)->checkCode($contact , $code);
  932. } else {
  933. $result = (new \app\common\library\Mail)->checkCode(session('front_account') , $contact , $code);
  934. }
  935. if (isset($result) && $result['status']) {
  936. $userid = session('front_userid');
  937. $res = model('Members')->save([$type => $contact],['id' => $userid]);
  938. model('MemberHistory')->insertGetId([$type => $contact,'userid'=> $userid,'ip' => GetIP(1),'create_time' => NOW_TIMESTAMP]);
  939. session('velidate_info',null);
  940. $this->success('绑定成功',getMobileUserCenterUrl(4));
  941. }
  942. $this->jsonResult([],0,$result['msg'] );
  943. }
  944. /**
  945. * 编辑昵称
  946. */
  947. public function editnickname(){
  948. if ($this->request->isPost()){
  949. $data['nickname'] = input('post.nickname');
  950. if (empty($data)) $this->error('请输入昵称');
  951. $res = validataNickname($data['nickname']);
  952. if (!$res['code']) $this->error($res['msg']);
  953. model('members')->save($data,['id'=>session('front_userid')]);
  954. /*$this->_updateUserInfo($data);*/
  955. $this->success('保存成功',getMobileUserCenterUrl(1));
  956. }
  957. $info = $this->getUserInfo();
  958. $this->assign('nickname',$info['nickname']);
  959. return $this->fetch('personal_nickname');
  960. }
  961. /**
  962. * 用户头像上传
  963. * 由于用户头像经过裁剪,前端传过来的是base64位的数据流,故要先保存在服务器,然后调接口上传到华为云,最后删除服务器上的图片。
  964. * @return bool
  965. */
  966. public function uploadUserImg(){
  967. (new \app\home\controller\Member)->uploadUserImg();
  968. }
  969. /**
  970. * 我要反馈
  971. */
  972. public function feedback(){
  973. if ($this->request->isPost()){
  974. (new \app\home\controller\Member)->ajaxFeedback('mobile');
  975. }
  976. $kefu = model('Kefu')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->field('qq')->find();
  977. $this->assign('kefu',$kefu['qq']);
  978. return $this->fetch();
  979. }
  980. /**
  981. * 我的游戏
  982. */
  983. public function mygame(){
  984. $obj = (new \app\home\controller\Member)->mygame(1);
  985. $this->assign('list' , $obj['list']);
  986. $this->assign('page' , $obj['page']);
  987. $this->assign('guesList' , $obj['guesList']);
  988. return $this->fetch();
  989. }
  990. /**
  991. * 我的游戏分页
  992. */
  993. public function ajaxMyGame(){
  994. (new \app\home\controller\Member)->ajaxMyGame();
  995. }
  996. /**
  997. * 个人中心--充值记录
  998. */
  999. public function personalPayDetail(){
  1000. $this->_isLogin();
  1001. $id = input('id',0,'intval');
  1002. $condition = ['p.userid' => session('front_userid'),'p.id'=>$id];
  1003. $PayModel = model('Common/Pay');
  1004. $list = $PayModel->alias('p')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->field('p.id,p.orderid,p.amount,p.create_time,g.nickname,p.status,p.productname,info.mobileicon,p.paytype,p.real_ptb,p.real_amount,p.pay_time')
  1005. ->join('cy_game g','p.gameid=g.id','left')
  1006. ->join('cy_gameinfo info', 'g.id = info.game_id')
  1007. ->where($condition)
  1008. ->find();
  1009. $list['pay_status'] = '';
  1010. switch ($list['status']){
  1011. case 0: $list['pay_status'] = '未支付';
  1012. break;
  1013. case 1: $list['pay_status'] = '支付成功';
  1014. break;
  1015. case 2: $list['pay_status'] = '支付失败';
  1016. break;
  1017. }
  1018. $list['amount'] = intval($list['amount']);
  1019. $list['icon'] = getGameIcon($list['mobileicon']);
  1020. // 统一显示为“微信支付”。
  1021. $wxzfArr = ['wxpay','swiftwxpay','wxpay-h5','ipaywxpay','ios-wxpay'];
  1022. // 统一显示为“微信混合支付”。
  1023. $wxhhzfArr = ['mix-swiftwxpay','mix-ipaywxpay','mix-wxpay-h5'];
  1024. // 统一显示为“支付宝支付”。
  1025. $zfbzfArr = ['zfb','ios-zfb'];
  1026. // 平台币支付显示规则
  1027. $lbArr = array_merge(['ptb','mix-zfb'],$wxhhzfArr);
  1028. // 第三方支付显示规则
  1029. $thirdArr = array_merge(['mix-zfb'],$wxhhzfArr,$wxzfArr,$zfbzfArr);
  1030. $list['lb_show'] = 0;
  1031. $list['third_show'] = 0;
  1032. if (in_array($list['paytype'],$lbArr)) $list['lb_show'] = 1;
  1033. if (in_array($list['paytype'],$thirdArr)) $list['third_show'] = 1;
  1034. if (in_array($list['paytype'],$wxzfArr)){
  1035. $list['paytype'] = '微信支付';
  1036. }elseif (in_array($list['paytype'],$wxhhzfArr)){
  1037. $list['paytype'] = '微信混合支付';
  1038. }elseif (in_array($list['paytype'],$zfbzfArr)){
  1039. $list['paytype'] = '支付宝';
  1040. }else{
  1041. $list['paytype'] = config('paytype.'.$list['paytype']);
  1042. }
  1043. $this->assign('info',$list);
  1044. return $this->fetch('personal_pay_detail');
  1045. }
  1046. }