public function postUserFromWechat() { $mobile = Input::get('mobile'); $pass = Input::get('pass'); $school_id = Input::get('school'); $vCode = Input::get('vcode'); DB::beginTransaction(); try { $user = new User(); $user->u_school_id = $school_id; $user->u_mobile = $mobile; $user->u_password = $pass; // verify vcode via phone $phone = new Phone($mobile); $phone->authVCode($vCode); $data = $user->register(); // add user wallet $wallet = new UsersWalletBalances(); $wallet->u_id = $user->u_id; $wallet->w_balance = 0.0; $wallet->w_freez = 0.0; $wallet->save(); $re = ['data' => $data, 'result' => 2000, 'info' => '注册成功']; DB::commit(); } catch (Exception $e) { $re = ['data' => [], 'info' => $e->getMessage(), 'result' => 2001]; DB::rollback(); } return Response::json($re); }
public function resetPassForWechat() { $mobile = Input::get('mobile'); $vcode = Input::get('vcode'); $newPass = Input::get('pass'); try { $user = User::where('u_mobile', '=', $mobile)->first(); // chcek if mobile exsits if (!isset($user->u_id)) { throw new Exception("没有查找到与该手机号码绑定的用户", 2001); } $phone = new Phone($mobile); if ($phone->authVCode($vcode)) { $user->u_password = $newPass; $user->updateUser(); } $re = Tools::reTrue('重置密码成功'); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '重置密码失败:' . $e->getMessage()); } return Response::json($re); }