Userbank.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. namespace app\api\controller\company;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. use app\common\library\Sms;
  6. /**
  7. * 银行卡
  8. */
  9. class Userbank extends Apic
  10. {
  11. protected $noNeedLogin = [];
  12. protected $noNeedRight = '*';
  13. //列表
  14. public function lists(){
  15. $list = Db::name('company_bank')->order('id desc')->select();
  16. $this->success(1,$list);
  17. }
  18. //提现账号添加
  19. public function bankadd() {
  20. //验证
  21. if($this->auth->type != 1){
  22. $this->error('只有门店老板才能设置银行卡');
  23. }
  24. //验证手机和验证码
  25. $captcha = input('captcha', '', 'trim'); //账户真实姓名
  26. if (!Sms::check($this->auth->mobile, $captcha, 'mobilelogin')) {
  27. $this->error('验证码错误');
  28. }
  29. //
  30. $bank_account = input('bank_account', '', 'trim'); //账户真实姓名
  31. $bank_card = input('bank_card', '', 'trim'); //卡号或账号
  32. $bank_name = input('bank_name', '', 'trim'); //银行名称
  33. // $bank_branchname = input('bank_branchname', '', 'trim'); //支行名称
  34. if ($bank_account === '' || iconv_strlen($bank_account, 'utf-8') > 30) {
  35. $this->error('账号姓名1-30位');
  36. }
  37. if ($bank_card === '' || iconv_strlen($bank_card, 'utf-8') > 50) {
  38. $this->error('卡号1-50位');
  39. }
  40. if ($bank_name === '' || iconv_strlen($bank_name, 'utf-8') > 50) {
  41. $this->error('银行名称1-50位');
  42. }
  43. /* if ($bank_branchname === '' || iconv_strlen($bank_branchname, 'utf-8') > 50) {
  44. $this->error('支行名称1-50位');
  45. }*/
  46. //添加
  47. $count = Db::name('company_bank')->where(['company_id' => $this->auth->company_id])->count('id');
  48. if ($count) {
  49. $this->error('您已经拥有该类型账号,不能再添加');
  50. }
  51. $data['company_id'] = $this->auth->company_id;
  52. $data['bank_account'] = $bank_account;
  53. $data['bank_card'] = $bank_card;
  54. $data['bank_name'] = $bank_name;
  55. // $data['bank_branchname'] = $bank_branchname;
  56. $data['createtime'] = time();
  57. $rs = Db::name('company_bank')->insertGetId($data);
  58. if (!$rs) {
  59. $this->error('设置失败');
  60. }
  61. $this->success('设置成功');
  62. }
  63. //提现账号编辑
  64. public function bankedit(){
  65. //验证
  66. if($this->auth->type != 1){
  67. $this->error('只有门店老板才能设置银行卡');
  68. }
  69. //验证手机和验证码
  70. $captcha = input('captcha', '', 'trim'); //账户真实姓名
  71. if (!Sms::check($this->auth->mobile, $captcha, 'mobilelogin')) {
  72. $this->error('验证码错误');
  73. }
  74. //
  75. $id = input('id', 0, 'intval'); //账号id
  76. $bank_account = input('bank_account', '', 'trim'); //账户真实姓名
  77. $bank_card = input('bank_card', '', 'trim'); //卡号或账号
  78. $bank_name = input('bank_name', '', 'trim'); //银行名称
  79. // $bank_branchname = input('bank_branchname', '', 'trim'); //支行名称
  80. if ($bank_account === '' || iconv_strlen($bank_account, 'utf-8') > 30) {
  81. $this->error('账号姓名1-30位');
  82. }
  83. if ($bank_card === '' || iconv_strlen($bank_card, 'utf-8') > 50) {
  84. $this->error('卡号1-50位');
  85. }
  86. if ($bank_name === '' || iconv_strlen($bank_name, 'utf-8') > 50) {
  87. $this->error('银行名称1-50位');
  88. }
  89. // if ($bank_branchname === '' || iconv_strlen($bank_branchname, 'utf-8') > 50) {
  90. // $this->error('支行名称1-50位');
  91. // }
  92. //查询账号是否存在
  93. $info = Db::name('company_bank')->where(['id' => $id, 'company_id' => $this->auth->company_id])->find();
  94. if (!$info) {
  95. $this->error('账号不存在');
  96. }
  97. $data['bank_account'] = $bank_account;
  98. $data['bank_card'] = $bank_card;
  99. $data['bank_name'] = $bank_name;
  100. // $data['bank_branchname'] = $bank_branchname;
  101. $data['updatetime'] = time();
  102. $rs = Db::name('company_bank')->where(['id' => $id])->update($data);
  103. if ($rs === false) {
  104. $this->error('设置失败');
  105. }
  106. $this->success('设置成功');
  107. }
  108. //提现账号信息
  109. public function bankinfo() {
  110. $info = Db::name('company_bank')->where(['company_id' => $this->auth->company_id])->find();
  111. if (!$info) {
  112. $info = (object)[];
  113. }
  114. $rs = [
  115. 'bank_info' => $info,
  116. 'set_mobile'=> Db::name('company_staff')->where('company_id',$this->auth->company_id)->where('type',1)->value('mobile'),
  117. ];
  118. $this->success('账户信息', $rs);
  119. }
  120. }