コード例 #1
0
 public function buy($type = 'online')
 {
     // 验证是否签约
     $user = get_user() or $this->error('请先登录!', '/login');
     $contract = M('loan_user_contract')->find($user['uid']);
     if (!$contract || $contract['status'] == 2) {
         $this->error('您还未签约或签约不通过', '/user/contract');
         return;
     }
     if (IS_POST) {
         $user = get_user() or $this->error('请先登录!');
         $userModel = new \Common\Model\UserModel();
         $userModel->verifyCode(I('mobile'), I('verify_code')) or $this->error($userModel->getError());
         $money = I('money', 0, 'floatval');
         $first_money = I('first_money', 0, 'floatval');
         $month = I('month', 0, 'intval');
         $other = $type == 'online' ? ['url' => I('url')] : ['seller_name' => I('seller_name'), 'seller_telephone' => I('seller_telephone')];
         $orderModel = D('Loan/order');
         $order_id = $orderModel->addOther($user['uid'], $type, I('title'), $money, $first_money, $month, I('remark'), $other);
         $order_id or $this->error($orderModel->getError());
         if (IS_AJAX) {
             $this->ajaxReturn(array('status' => 1, 'order_id' => $order_id));
         } else {
             $this->assign('order_id', $order_id);
             $this->success('下单成功,请等待工作人员审核。', '/user/order', 3);
         }
         return;
     }
 }
コード例 #2
0
 /**
  * @title 重置密码(用于找回密码时)
  *
  * @param int $mobile 手机号
  * @param string $verifyCode 验证码
  * @param string $password 新密码
  * @method post
  */
 public function forgetPassword()
 {
     $mobile = I('post.mobile');
     $password = I('post.password');
     $userModel = new \Common\Model\UserModel();
     $verifyCode = I('post.verifyCode') or ajax_error('请输入手机验证码!');
     $userModel->verifyCode($mobile, $verifyCode) or ajax_error($userModel->getError());
     $this->_updatePassword($mobile, $password);
 }
コード例 #3
0
 public function verify_old_mobile()
 {
     session('verify_old', false);
     $userModel = new \Common\Model\UserModel();
     if ($userModel->verifyCode($this->user['mobile'], I('post.verify_old')) === true) {
         session('verify_old', true);
         $this->ajaxReturn(array('ok' => 1));
     } else {
         $this->ajaxReturn(array('ok' => 0, 'message' => $userModel->getError()));
     }
 }
コード例 #4
0
 public function order()
 {
     if (I('post.month', 0, 'intval') > 0) {
         $userModel = new \Common\Model\UserModel();
         $userModel->verifyCode(I('post.mobile'), I('post.verify_code')) or $this->error($userModel->getError());
     }
     $goods = $this->_goods();
     $this->assign('goods', $goods);
     $first_money = I('first_money', 0, 'floatval');
     $month = I('month', 0, 'intval');
     $quantity = I('quantity', 1, 'intval');
     $remark = I('remark');
     $payee_account_type = I('payee_account_type', 0, 'intval');
     $payee_account = I('account');
     $orderModel = new \Loan\Model\OrderModel();
     $order_id = $orderModel->addGoods($this->_user['uid'], $goods['id'], $quantity, $first_money, $month, $goods['property_remark'], $remark, $payee_account_type, $payee_account);
     $order_id or $this->error($orderModel->getError());
     if (IS_AJAX) {
         $this->ajaxReturn(array('status' => 1, 'order_id' => $order_id));
     } else {
         if ($month) {
             $this->assign('order_id', $order_id);
             $this->success('下单成功,请等待工作人员审核。', '/user/order', 3);
         } else {
             $this->redirect('/pay/alipay/' . $order_id);
         }
     }
 }
コード例 #5
0
 /**
  * @title 设置交易密码
  *
  * @param string $password 新密码
  * @param string $verifyCode 手机验证码
  *       
  * @method GET
  */
 public function setTradePassword()
 {
     $password = I('post.password') or ajax_error('请输入交易密码!');
     $verifyCode = I('post.verifyCode') or ajax_error('请输入手机验证码!');
     // 验证手机号
     $userModel = new \Common\Model\UserModel();
     $userModel->verifyCode($this->_user['mobile'], $verifyCode) or ajax_error($userModel->getError());
     $user = $userModel->field('salt')->where(['uid' => $this->_user['uid']])->find() or ajax_error('ACCOUNT_NOT_FOUND', '此账号不存在!');
     // 更新密码
     M('snack_building_master')->where(['uid' => $this->_user['uid']])->setField('trade_password', $userModel->password($password, $user['salt']));
     ajax_success();
 }
コード例 #6
0
 public function verify()
 {
     if (I('post.month', 0, 'intval') > 0) {
         $userModel = new \Common\Model\UserModel();
         $verify_code = I('post.verify_code') or $this->error('请输入手机验证码');
         $userModel->verifyCode(I('post.mobile'), $verify_code) or $this->error($userModel->getError());
     }
 }