123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- <?php
- namespace app\api\controller;
- use app\common\library\Sms;
- use app\api\controller\Common;
- use think\Db;
- use think\Exception;
- use think\Validate;
- use app\common\model\UserAlipay;
- class Withdraw extends Common
- {
- protected $layout = 'default';
- protected $noNeedLogin = ['getUserInfoByMobile','bindBank','mobilelogin'];
- protected $noNeedRight = ['*'];
-
- public function getUserInfoByMobile() {
- $mobile = $this->request->request('mobile');
- if(!$mobile) $this->error("请输入手机号!");
- $field = "u_id,avatar,money,nickname,mobile";
- $userInfo = \app\common\model\User::getByMobile($mobile,$field);
- $this->success("获取成功!",$userInfo);
- }
-
- public function validateCard() {
- $idcard = $this->request->request('idcard');
- if(!$idcard) $this->error("参数缺失!");
-
- $idcardInfo = \app\common\model\UserAuth::where(["user_id"=>$this->auth->id])->value("idcard");
- if($idcardInfo === $idcard) {
- $this->success("验证成功!");
- } else {
- $this->error("验证失败!");
- }
- }
-
- public function bindBank() {
- $realname = $this->request->request('realname');
- $bank_no = $this->request->request('bank_no');
-
- $open_bank = $this->request->request('open_bank');
-
- $userId = $this->auth->id;
-
- if(!$realname || !$bank_no || !$open_bank ) {
- $this->error("请将信息填写完整");
- }
-
-
-
-
- $bankInfo = \app\common\model\UserBank::where(["user_id"=>$userId])->find();
- $data = [];
- $data["realname"] = $realname;
- $data["bank_no"] = $bank_no;
- $data["open_bank"] = $open_bank;
-
- if($bankInfo) {
- $data["updatetime"] = time();
- $res = \app\common\model\UserBank::update($data,["user_id"=>$userId]);
- } else {
- $data["user_id"] = $userId;
- $data["createtime"] = time();
- $res = \app\common\model\UserBank::insert($data);
- }
- if($res) {
-
- $this->success("银行卡绑定成功!");
- } else {
- $this->error("网络异常,请稍后重试!");
- }
- }
-
- public function getBankInfo() {
-
- $bankInfo = \app\common\model\UserBank::where(["user_id"=>$this->auth->id])->find();
- if(!$bankInfo) $this->error("银行卡信息获取失败!");
- $this->success("获取成功!",$bankInfo);
- }
-
- public function bindAlipay() {
- $realname = $this->request->request('realname');
- $payNo = $this->request->request('pay_no');
- $cardNo = $this->request->request('card_no');
-
-
- $userId = $this->auth->id;
- if(!$realname || !$payNo || !$cardNo) {
- $this->error("请将信息填写完整");
- }
-
-
-
- $userAlipayModel = new UserAlipay();
-
- $bankInfo = $userAlipayModel->where(["user_id"=>$userId])->find();
- $data = [];
- $data["realname"] = $realname;
- $data["pay_no"] = $payNo;
- $data["card_no"] = $cardNo;
- if($bankInfo) {
- $data["updatetime"] = time();
- $res = $userAlipayModel->update($data,["user_id"=>$userId]);
- } else {
- $data["user_id"] = $userId;
- $data["createtime"] = time();
- $res = $userAlipayModel->insert($data);
- }
- if($res) {
-
- $this->success("支付宝绑定成功!");
- } else {
- $this->error("网络异常,请稍后重试!");
- }
- }
-
- public function getAlipayInfo() {
-
- $alipayInfo = UserAlipay::where(["user_id"=>$this->auth->id])->find();
- if(!$alipayInfo) $this->error("支付宝信息获取失败!");
- $this->success("获取成功!",$alipayInfo);
- }
-
- public function getUserAccountInfo() {
-
- $res = \app\common\model\User::field("id,u_id,avatar,mobile,nickname,money as use_money,frozen")->where(["id"=>$this->auth->id])->find();
- $res["all_money"] = bcadd($res["use_money"],$res["frozen"],2);
- unset($res["frozen"]);
-
- $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 mobilelogin()
- {
- $mobile = $this->request->request('mobile');
- $captcha = $this->request->request('captcha');
- if (!$mobile || !$captcha) {
- $this->error(__('Invalid parameters'));
- }
- if (!Validate::regex($mobile, "^1\d{10}$")) {
- $this->error(__('Mobile is incorrect'));
- }
- if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
- $this->error(__('Captcha is incorrect'));
- }
- $user = \app\common\model\User::getByMobile($mobile,"u_id,is_auth");
- if ($user) {
- Sms::flush($mobile, 'mobilelogin');
- $this->success("获取成功!",$user);
- } else {
- $this->error("没有查询到用户信息!请前往app注册!");
- }
- }
- }
|