Userbank.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. namespace app\api\controller\doctor;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. *
  7. */
  8. class Userbank extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. /**
  13. * 绑定银行卡
  14. */
  15. public function bindBank() {
  16. /*$captcha = input('captcha');
  17. if (!$captcha) {
  18. $this->error(__('Invalid parameters'));
  19. }
  20. $result = Sms::check($this->auth->mobile, $captcha, 'changemobile');
  21. if (!$result) {
  22. $this->error(__('Captcha is incorrect'));
  23. }*/
  24. //
  25. $bank_no = input('bank_no');// 银行账号
  26. $open_bank = input('open_bank');// 开户行
  27. if(!$bank_no || !$open_bank ) {
  28. $this->error("请将信息填写完整");
  29. }
  30. $userId = $this->auth->id;
  31. //检测实名认证
  32. if ($this->auth->idcard_status != 1) {
  33. $this->error('请先完成实名认证');
  34. }
  35. $realname = $this->auth->realname;
  36. // 查询是否有过绑定
  37. $bankInfo = Db::name('doctor_bank')->where(["doctor_id"=>$userId])->find();
  38. $data = [];
  39. $data["realname"] = $realname;
  40. $data["bank_no"] = $bank_no;
  41. $data["open_bank"] = $open_bank;
  42. if($bankInfo) {
  43. $res = Db::name('doctor_bank')->where(["doctor_id"=>$userId])->update($data);
  44. } else {
  45. $data["doctor_id"] = $userId;
  46. $res = Db::name('doctor_bank')->insertGetId($data);
  47. }
  48. $this->success("银行卡绑定成功!");
  49. }
  50. /**
  51. * 获取绑定银行卡信息
  52. */
  53. public function getBankInfo() {
  54. // 查询是否有过绑定
  55. $bankInfo = Db::name('doctor_bank')->where(["doctor_id"=>$this->auth->id])->find();
  56. $this->success("获取成功!",$bankInfo);
  57. }
  58. /**
  59. * 绑定支付宝
  60. */
  61. public function bindAlipay() {
  62. /*$captcha = input('captcha');
  63. if (!$captcha) {
  64. $this->error(__('Invalid parameters'));
  65. }
  66. $result = Sms::check($this->auth->mobile, $captcha, 'changemobile');
  67. if (!$result) {
  68. $this->error(__('Captcha is incorrect'));
  69. }*/
  70. //
  71. $payNo = input('pay_no');//支付宝账号
  72. if(!$payNo) {
  73. $this->error("请将信息填写完整");
  74. }
  75. $userId = $this->auth->id;
  76. //检测实名认证
  77. if ($this->auth->idcard_status != 1) {
  78. $this->error('请先完成实名认证');
  79. }
  80. $realname = $this->auth->realname;
  81. // 查询是否有过绑定
  82. $bankInfo = Db::name('doctor_alipay')->where(["doctor_id"=>$userId])->find();
  83. $data = [];
  84. $data["realname"] = $realname;
  85. $data["pay_no"] = $payNo;
  86. if($bankInfo) {
  87. $res = Db::name('doctor_alipay')->where(["doctor_id"=>$userId])->update($data);
  88. } else {
  89. $data["doctor_id"] = $userId;
  90. $res = Db::name('doctor_alipay')->insertGetId($data);
  91. }
  92. if($res) {
  93. $this->success("支付宝绑定成功!");
  94. } else {
  95. $this->error("网络异常,请稍后重试!");
  96. }
  97. }
  98. /**
  99. * 获取绑定银行卡信息
  100. */
  101. public function getAlipayInfo() {
  102. // 查询是否有过绑定
  103. $alipayInfo = Db::name('doctor_alipay')->where(["doctor_id"=>$this->auth->id])->find();
  104. $this->success("获取成功!",$alipayInfo);
  105. }
  106. /**
  107. * 绑定微信
  108. */
  109. public function bindWechat() {
  110. /*$captcha = input('captcha');
  111. if (!$captcha) {
  112. $this->error(__('Invalid parameters'));
  113. }
  114. $result = Sms::check($this->auth->mobile, $captcha, 'changemobile');
  115. if (!$result) {
  116. $this->error(__('Captcha is incorrect'));
  117. }*/
  118. //
  119. $payNo = input('pay_no');//支付宝账号
  120. if(!$payNo) {
  121. $this->error("请将信息填写完整");
  122. }
  123. $userId = $this->auth->id;
  124. //检测实名认证
  125. if ($this->auth->idcard_status != 1) {
  126. $this->error('请先完成实名认证');
  127. }
  128. $realname = $this->auth->realname;
  129. // 查询是否有过绑定
  130. $bankInfo = Db::name('doctor_wechat')->where(["doctor_id"=>$userId])->find();
  131. $data = [];
  132. $data["realname"] = $realname;
  133. $data["pay_no"] = $payNo;
  134. if($bankInfo) {
  135. $res = Db::name('doctor_wechat')->where(["doctor_id"=>$userId])->update($data);
  136. } else {
  137. $data["doctor_id"] = $userId;
  138. $res = Db::name('doctor_wechat')->insertGetId($data);
  139. }
  140. if($res) {
  141. $this->success("绑定成功!");
  142. } else {
  143. $this->error("网络异常,请稍后重试!");
  144. }
  145. }
  146. /**
  147. * 获取绑定银行卡信息
  148. */
  149. public function getWechatInfo() {
  150. // 查询是否有过绑定
  151. $alipayInfo = Db::name('doctor_wechat')->where(["doctor_id"=>$this->auth->id])->find();
  152. $this->success("获取成功!",$alipayInfo);
  153. }
  154. }