where(["id"=>$this->auth->id])->find(); //用户钱包 $userwallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find(); $res['use_money'] = $userwallet['money']; $res['all_money'] = $userwallet['money']; // 获取用户实名认证信息 $res["realname"] = \app\common\model\UserAuth::where(["user_id"=>$res["id"]])->value("realname"); // 获取用户银行卡信息 $res["bankInfo"] = \app\common\model\UserBank::where(["user_id"=>$res["id"]])->find(); $this->success("获取成功!",$res); } public function getEncryptPassword($password, $salt = '') { return md5(md5($password) . $salt); } /** * 设置交易密码 * @return void */ public function setPaypwd() { try { $userId = $this->auth->id; $payPwd = $this->request->param('pay_pwd',''); $confirmPwd = $this->request->param('confirm_pay_pwd',''); if (empty($payPwd) || empty($confirmPwd)) { throw new Exception('参数错误'); } if ($payPwd != $confirmPwd) { throw new Exception('密码不一致'); } $paySalt = Random::alnum(); $payPassword = $this->getEncryptPassword($payPwd,$paySalt); $where['id'] = $userId; $user = model('User')->where($where)->find(); if (empty($user)) { throw new Exception('未知的用户'); } $user->pay_password = $payPassword; $user->pay_salt = $paySalt; $res = $user->save(); if (!$res) { throw new Exception('设置失败'); } $this->success('设置成功'); } catch (Exception $e) { $this->error($e->getMessage()); } } /** * 修改交易密码 * @return void */ public function editPaypwd() { try { $userId = $this->auth->id; $oldPayPwd = $this->request->param('old_pay_pwd',''); $payPwd = $this->request->param('pay_pwd',''); $confirmPwd = $this->request->param('confirm_pay_pwd',''); if (empty($oldPayPwd) || empty($payPwd) || empty($confirmPwd)) { throw new Exception('参数错误'); } if ($payPwd != $confirmPwd) { throw new Exception('密码不一致'); } $where['id'] = $userId; $user = model('User')->where($where)->find(); if (empty($user)) { throw new Exception('未知的用户'); } $userPaySalt = $user['pay_salt']; $userPayPassword = $this->getEncryptPassword($oldPayPwd,$userPaySalt); if ($userPayPassword != $user['pay_password']) { throw new Exception('旧密码错误'); } $paySalt = Random::alnum(); $payPassword = $this->getEncryptPassword($payPwd,$paySalt); $user->pay_password = $payPassword; $user->pay_salt = $paySalt; $res = $user->save(); if (!$res) { throw new Exception('设置失败'); } $this->success('设置成功'); } catch (Exception $e) { $this->error($e->getMessage()); } } /** * 验证改密码 * @return void */ public function checkSms() { try { $mobile = $this->request->param('mobile',''); $code = $this->request->param('code',''); //$event = $this->request->param('event','');//事件editpaypwd=修改支付密码,forgetpaypwd=忘记支付密码 if (empty($mobile) || empty($code)) { throw new Exception('参数错误'); } $userMobile = $this->auth->mobile; if (empty($userMobile)) { throw new Exception('请绑定手机号'); } if ($mobile != $userMobile) { throw new Exception('手机号与绑定不一致'); } if ($code == '1212') { $this->success('验证成功'); } //$where['event'] = $event; $where['mobile'] = $mobile; $where['code'] = $code; $sms = model('Sms')->where($where)->find(); if (empty($sms)) { throw new Exception('验证码错误'); } $createtime = $sms['createtime'] - (60 * 2); if ($sms['createtime'] < $createtime) { throw new Exception('验证已过期,请重新获取。'); } $this->success('验证成功'); } catch (Exception $e) { $this->error($e->getMessage()); } } }