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; } }
/** * @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); }
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())); } }
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); } } }
public function changeMobile() { $uid = I('uid', 0, 'intval'); $user = M('user')->find($uid) or $this->error('找不到此用户信息!'); if (IS_POST) { $model = new \Common\Model\UserModel(); $model->changeMobile($user['mobile'], I('mobile'), 3) or $this->error($model->getError()); $this->success('手机号已成功更换为:' . I('mobile')); exit; } $this->assign('info', $user); $this->meta_title = '更换手机号'; $this->display(); }
/** * @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(); }
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()); } }
public function check_success($id) { $company = $this->find($id); if (!$company) { $this->error = '此商铺信息不存在!'; return false; } if ($company['status'] == 1) { $this->error = '禁止操作:此商铺信息已审核通过,请刷新后重试'; return false; } // 判断信息是否完善 if (!$company['name']) { $this->error = '请先输入商铺名!'; return false; } // 需更新的数据 $data = ['status' => 1]; // 关联账号 if ($company['uid'] == 0) { // 未关联,则读取手机号 $mobile = $company['telephone']; if (!preg_match('/^1\\d{10}$/', $mobile)) { $this->error = '自动关联商家账号时,无法读取正确的手机号!'; return false; } $uname = $realname = trim($company['contact']); if (!$uname) { $this->error = '自动关联商家账号时,无法读取商家用户名!'; return false; } $uid = M('user')->where(['mobile' => $mobile])->getField('uid'); if (!$uid) { // 自动创建用户 $userModel = new \Common\Model\UserModel(); $uid = $userModel->addUser($mobile, $uname, $realname, uniqid()); if (!$uname) { $this->error = $userModel->getError(); return false; } } $data['uid'] = $uid; } $this->where(['id' => $id])->save($data); return true; }