Browse Source

银行管理

lizhen_gitee 1 year ago
parent
commit
8714b33414
1 changed files with 26 additions and 21 deletions
  1. 26 21
      application/api/controller/company/Userbank.php

+ 26 - 21
application/api/controller/company/Userbank.php

@@ -1,53 +1,58 @@
 <?php
 
-namespace app\api\controller;
+namespace app\api\controller\company;
 
-use app\common\controller\Api;
+use app\common\controller\Apic;
 use think\Db;
 
 /**
- * 会员银行卡
+ * 银行卡
  */
-class Usercenter extends Api
+class Userbank extends Apic
 {
     protected $noNeedLogin = [];
     protected $noNeedRight = '*';
 
+    //列表
+    public function lists(){
+        $list = Db::name('company_bank')->order('id desc')->select();
+        $this->success(1,$list);
+    }
 
     //提现账号添加
     public function bankadd() {
         $bank_account    = input('bank_account', '', 'trim'); //账户真实姓名
         $bank_card       = input('bank_card', '', 'trim'); //卡号或账号
         $bank_name       = input('bank_name', '', 'trim'); //银行名称
-        $bank_branchname = input('bank_branchname', '', 'trim'); //支行名称
+//        $bank_branchname = input('bank_branchname', '', 'trim'); //支行名称
 
         if ($bank_account === '' || iconv_strlen($bank_account, 'utf-8') > 30) {
             $this->error('账号姓名1-30位');
         }
         if ($bank_card === '' || iconv_strlen($bank_card, 'utf-8') > 50) {
-            $this->error('号1-50位');
+            $this->error('号1-50位');
         }
         if ($bank_name === '' || iconv_strlen($bank_name, 'utf-8') > 50) {
             $this->error('银行名称1-50位');
         }
-        if ($bank_branchname === '' || iconv_strlen($bank_branchname, 'utf-8') > 50) {
+       /* if ($bank_branchname === '' || iconv_strlen($bank_branchname, 'utf-8') > 50) {
             $this->error('支行名称1-50位');
-        }
+        }*/
 
         //添加
-        $count = Db::name('user_bank')->where(['user_id' => $this->auth->id])->count('id');
+        $count = Db::name('company_bank')->where(['company_id' => $this->auth->company_id])->count('id');
         if ($count) {
             $this->error('您已经拥有该类型账号,不能再添加');
         }
 
-        $data['user_id'] = $this->auth->id;
+        $data['company_id'] = $this->auth->company_id;
         $data['bank_account'] = $bank_account;
         $data['bank_card'] = $bank_card;
         $data['bank_name'] = $bank_name;
-        $data['bank_branchname'] = $bank_branchname;
+//        $data['bank_branchname'] = $bank_branchname;
         $data['createtime'] = time();
 
-        $rs = Db::name('user_bank')->insertGetId($data);
+        $rs = Db::name('company_bank')->insertGetId($data);
         if (!$rs) {
             $this->error('添加失败');
         }
@@ -61,23 +66,23 @@ class Usercenter extends Api
         $bank_account    = input('bank_account', '', 'trim'); //账户真实姓名
         $bank_card       = input('bank_card', '', 'trim'); //卡号或账号
         $bank_name       = input('bank_name', '', 'trim'); //银行名称
-        $bank_branchname = input('bank_branchname', '', 'trim'); //支行名称
+//        $bank_branchname = input('bank_branchname', '', 'trim'); //支行名称
 
         if ($bank_account === '' || iconv_strlen($bank_account, 'utf-8') > 30) {
             $this->error('账号姓名1-30位');
         }
         if ($bank_card === '' || iconv_strlen($bank_card, 'utf-8') > 50) {
-            $this->error('号1-50位');
+            $this->error('号1-50位');
         }
         if ($bank_name === '' || iconv_strlen($bank_name, 'utf-8') > 50) {
             $this->error('银行名称1-50位');
         }
-        if ($bank_branchname === '' || iconv_strlen($bank_branchname, 'utf-8') > 50) {
-            $this->error('支行名称1-50位');
-        }
+//        if ($bank_branchname === '' || iconv_strlen($bank_branchname, 'utf-8') > 50) {
+//            $this->error('支行名称1-50位');
+//        }
 
         //查询账号是否存在
-        $info = Db::name('user_bank')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
+        $info = Db::name('company_bank')->where(['id' => $id, 'company_id' => $this->auth->company_id])->find();
         if (!$info) {
             $this->error('账号不存在');
         }
@@ -85,10 +90,10 @@ class Usercenter extends Api
         $data['bank_account'] = $bank_account;
         $data['bank_card'] = $bank_card;
         $data['bank_name'] = $bank_name;
-        $data['bank_branchname'] = $bank_branchname;
+//        $data['bank_branchname'] = $bank_branchname;
         $data['updatetime'] = time();
 
-        $rs = Db::name('user_bank')->where(['id' => $id])->update($data);
+        $rs = Db::name('company_bank')->where(['id' => $id])->update($data);
         if ($rs === false) {
             $this->error('修改失败');
         }
@@ -99,7 +104,7 @@ class Usercenter extends Api
     //提现账号信息
     public function bankinfo() {
 
-        $info = Db::name('user_bank')->where(['user_id' => $this->auth->id])->find();
+        $info = Db::name('company_bank')->where(['company_id' => $this->auth->company_id])->find();
         if (!$info) {
             $info = (object)[];
         }