123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- use app\common\service\UserService;
- class Userbank extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
-
- public function bindBank() {
- $bank_no = $this->request->request('bank_no');
- $open_bank = $this->request->request('open_bank');
- if(!$bank_no || !$open_bank ) {
- $this->error("请将信息填写完整");
- }
- $userId = $this->auth->id;
-
- if(config('site.user_auth_switch') == 1){
- $userAuthWhere['user_id'] = $userId;
- $userAuth = Db::name('user_idconfirm')->where($userAuthWhere)->find();
- if (empty($userAuth)) {
- $this->error('请先实名认证');
- }
- if ($userAuth['status'] != 1) {
- $this->error('请先实名认证通过');
- }
- }
- $truename = $userAuth['truename'];
- $idCard = $userAuth['idcard'];
-
-
-
- $bankInfo = Db::name('user_bank')->where(["user_id"=>$userId])->find();
- $data = [];
- $data["truename"] = $truename;
- $data["idcard"] = $idCard;
- $data["bank_no"] = $bank_no;
- $data["open_bank"] = $open_bank;
- if($bankInfo) {
- $res = Db::name('user_bank')->where(["user_id"=>$userId])->update($data);
- } else {
- $data["user_id"] = $userId;
- $res = Db::name('user_bank')->insertGetId($data);
- }
- $this->success("银行卡绑定成功!");
- }
-
- public function getBankInfo() {
-
- $bankInfo = Db::name('user_bank')->where(["user_id"=>$this->auth->id])->find();
- $this->success("获取成功!",$bankInfo);
- }
-
- public function bindAlipay() {
- $payNo = $this->request->request('pay_no');
- if(!$payNo) {
- $this->error("请将信息填写完整");
- }
- $userId = $this->auth->id;
-
- if(config('site.user_auth_switch') == 1){
- $userAuthWhere['user_id'] = $userId;
- $userAuth = Db::name('user_idconfirm')->where($userAuthWhere)->find();
- if (empty($userAuth)) {
- $this->error('请先实名认证');
- }
- if ($userAuth['status'] != 1) {
- $this->error('请先实名认证通过');
- }
- }
-
- $bankInfo = Db::name('user_alipay')->where(["user_id"=>$userId])->find();
- $data = [];
- $data["truename"] = $userAuth['truename'];
- $data["pay_no"] = $payNo;
- $data["idcard"] = $userAuth['idcard'];
- if($bankInfo) {
- $res = Db::name('user_alipay')->where(["user_id"=>$userId])->update($data);
- } else {
- $data["user_id"] = $userId;
- $res = Db::name('user_alipay')->insertGetId($data);
- }
- if($res) {
- $this->success("支付宝绑定成功!");
- } else {
- $this->error("网络异常,请稍后重试!");
- }
- }
-
- public function getAlipayInfo() {
-
- $alipayInfo = Db::name('user_alipay')->where(["user_id"=>$this->auth->id])->find();
- $this->success("获取成功!",$alipayInfo);
- }
- }
|