Bladeren bron

银行卡支付宝绑定

lizhen_gitee 1 jaar geleden
bovenliggende
commit
02d60ca5bc
2 gewijzigde bestanden met toevoegingen van 21 en 158 verwijderingen
  1. 21 9
      application/api/controller/Userbank.php
  2. 0 149
      application/api/controller/Withdraw.php

+ 21 - 9
application/api/controller/Userbank.php

@@ -23,8 +23,8 @@ class Userbank extends Api
      */
     public function bindBank() {
 
-        $bank_no = $this->request->request('bank_no');// 银行账号
-        $open_bank = $this->request->request('open_bank');// 开户行
+        $bank_no = input('bank_no');// 银行账号
+        $open_bank = input('open_bank');// 开户行
         if(!$bank_no || !$open_bank ) {
             $this->error("请将信息填写完整");
         }
@@ -34,7 +34,7 @@ class Userbank extends Api
         //检测实名认证
 
         $userAuthWhere['user_id'] = $userId;
-        $userAuth = Db::name('user_idconfirm')->where($userAuthWhere)->find();
+        $userAuth = Db::name('user_auth')->where($userAuthWhere)->find();
         if (empty($userAuth)) {
             $this->error('请先实名认证');
         }
@@ -42,14 +42,25 @@ class Userbank extends Api
             $this->error('请先实名认证通过');
         }
 
-        $truename = $userAuth['truename'];
+        $realname = $userAuth['realname'];
         $idCard = $userAuth['idcard'];
 
+        //支付宝三要素验证
+        /*$userService = new UserService();
+        $aliParams = [
+            'bank_no' => $bank_no,
+            'id_card' => $idCard,
+            'real_name' => $realname,
+        ];
+        $aliBankCheckRes = $userService->bankCheck($aliParams);
+        if (!$aliBankCheckRes['status']) {
+            throw new Exception($aliBankCheckRes['msg']);
+        }*/
 
         // 查询是否有过绑定
         $bankInfo = Db::name('user_bank')->where(["user_id"=>$userId])->find();
         $data = [];
-        $data["truename"] = $truename;
+        $data["realname"] = $realname;
         $data["idcard"] = $idCard;
         $data["bank_no"] = $bank_no;
         $data["open_bank"] = $open_bank;
@@ -80,7 +91,7 @@ class Userbank extends Api
      * 绑定支付宝
      */
     public function bindAlipay() {
-        $payNo = $this->request->request('pay_no');//支付宝账号
+        $payNo = input('pay_no');//支付宝账号
         if(!$payNo) {
             $this->error("请将信息填写完整");
         }
@@ -90,7 +101,7 @@ class Userbank extends Api
         //检测实名认证
 
         $userAuthWhere['user_id'] = $userId;
-        $userAuth = Db::name('user_idconfirm')->where($userAuthWhere)->find();
+        $userAuth = Db::name('user_auth')->where($userAuthWhere)->find();
         if (empty($userAuth)) {
             $this->error('请先实名认证');
         }
@@ -102,9 +113,10 @@ class Userbank extends Api
         // 查询是否有过绑定
         $bankInfo = Db::name('user_alipay')->where(["user_id"=>$userId])->find();
         $data = [];
-        $data["truename"] = $userAuth['truename'];
-        $data["pay_no"] = $payNo;
+        $data["realname"] = $userAuth['realname'];
         $data["idcard"] = $userAuth['idcard'];
+        $data["pay_no"] = $payNo;
+
         if($bankInfo) {
             $res = Db::name('user_alipay')->where(["user_id"=>$userId])->update($data);
         } else {

+ 0 - 149
application/api/controller/Withdraw.php

@@ -22,155 +22,6 @@ class Withdraw extends Common
 
 
 
-
-    /**
-     * 绑定银行卡
-     */
-    public function bindBank() {
-        try {
-            //$realname = $this->request->request('realname');// 真实姓名
-            $bank_no = $this->request->request('bank_no');// 银行账号
-            //$idCard = $this->request->request('id_card');// 身份证号
-            /*$bank_name = $this->request->request('bank_name');// 银行名称
-            $open_address = $this->request->request('open_address');// 开户地*/
-            $open_bank = $this->request->request('open_bank');// 开户行
-            /*$bank_mobile = $this->request->request('bank_mobile');// 银行预留手机号
-            $captcha = $this->request->request('captcha'); // 验证码
-            $mobile = $this->request->request('mobile'); // 手机号*/
-            $userId = $this->auth->id;
-            //|| !$bank_name || !$open_address || !$bank_mobile || !$captcha || !$mobile
-            if(!$bank_no || !$open_bank ) {
-                throw new Exception("请将信息填写完整");
-            }
-            $userAuthWhere['user_id'] = $userId;
-            $userAuth = model('UserAuth')->where($userAuthWhere)->find();
-            if (empty($userAuth)) {
-                throw new Exception('请先实名认证');
-            }
-            if ($userAuth['status'] != 1) {
-                throw new Exception('请先实名认证通过');
-            }
-            $realname = $userAuth['realname'];
-            $idCard = $userAuth['idcard'];
-            $userService = new UserService();
-            $aliParams = [
-                'bank_no' => $bank_no,
-                'id_card' => $idCard,
-                'real_name' => $realname,
-            ];
-            $aliBankCheckRes = $userService->bankCheck($aliParams);
-            if (!$aliBankCheckRes['status']) {
-                throw new Exception($aliBankCheckRes['msg']);
-            }
-            // 获取用户信息
-            //$userInfo = \app\common\model\User::where(["id"=>$this->auth->id])->find();
-
-            /*if($userInfo->mobile !== $mobile) $this->error("请输入账号绑定的手机号码!");
-
-            if (!Sms::check($mobile, $captcha, 'binkBank')) {
-                $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;
-            $data["id_card"] = $idCard;
-            /*$data["bank_name"] = $bank_name;
-            $data["open_address"] = $open_address;
-            $data["mobile"] = $bank_mobile;*/
-            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) {
-                throw new Exception("网络异常,请稍后重试!");
-            }
-            $this->success("银行卡绑定成功!");
-        } catch (Exception $e) {
-            $this->error($e->getMessage());
-        }
-    }
-
-    /**
-     * 获取绑定银行卡信息
-     */
-    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');//身份证号
-        //$mobile = $this->request->request('mobile'); //手机号
-        //$captcha = $this->request->request('captcha'); //验证码
-        $userId = $this->auth->id;
-        //姓名和身份证号 取实名认证
-        $userAuthWhere['user_id'] = $userId;
-        $userAuth = model('UserAuth')->where($userAuthWhere)->find();
-        if (empty($userAuth)) {
-            $this->error('请先实名认证');
-        }
-        if ($userAuth['status'] != 1) {
-            $this->error('请先实名认证通过');
-        }
-        $realname = $userAuth['realname'];
-        $cardNo = $userAuth['idcard'];
-        if(!$realname || !$payNo || !$cardNo) {
-            $this->error("请将信息填写完整");
-        }
-        // 获取用户信息
-        //$userInfo = \app\common\model\User::where(["id"=>$this->auth->id])->find();
-        /*if (!Sms::check($mobile, $captcha, 'binkAli')) {
-            $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) {
-            //Sms::flush($mobile, 'binkBank');
-            $this->success("支付宝绑定成功!");
-        } else {
-            $this->error("网络异常,请稍后重试!");
-        }
-    }
-
-    /**
-     * 获取绑定银行卡信息
-     */
-    public function getAlipayInfo() {
-        // 查询是否有过绑定
-        $alipayInfo = UserAlipay::where(["user_id"=>$this->auth->id])->find();
-        //if(!$alipayInfo) $this->error("支付宝信息获取失败!");
-        $this->success("获取成功!",$alipayInfo);
-    }
-
     /**
      * 获取用户账户信息
      */