Memberbankaccount.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. /**
  3. * Index.php
  4. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  5. * =========================================================
  6. * Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
  7. * ----------------------------------------------
  8. * 官方网址: https://www.niushop.com
  9. * =========================================================
  10. * @author : niuteam
  11. * @date : 2022.8.8
  12. * @version : v5.0.0.1
  13. */
  14. namespace app\api\controller;
  15. use app\model\member\MemberBankAccount as MemberBankAccountModel;
  16. /**
  17. * 会员提现账号
  18. * Class Memberbankaccount
  19. * @package app\api\controller
  20. */
  21. class Memberbankaccount extends BaseApi
  22. {
  23. /**
  24. * 添加信息
  25. */
  26. public function add()
  27. {
  28. $token = $this->checkToken();
  29. if ($token[ 'code' ] < 0) return $this->response($token);
  30. $realname = isset($this->params[ 'realname' ]) ? $this->params[ 'realname' ] : '';
  31. $mobile = isset($this->params[ 'mobile' ]) ? $this->params[ 'mobile' ] : '';
  32. $withdraw_type = isset($this->params[ 'withdraw_type' ]) ? $this->params[ 'withdraw_type' ] : '';// '账户类型 alipay 支付宝 bank 银行卡
  33. $branch_bank_name = isset($this->params[ 'branch_bank_name' ]) ? $this->params[ 'branch_bank_name' ] : '';// 银行支行信息
  34. $bank_account = isset($this->params[ 'bank_account' ]) ? $this->params[ 'bank_account' ] : '';// 银行账号
  35. if (empty($realname)) {
  36. return $this->response($this->error('', 'REQUEST_REAL_NAME'));
  37. }
  38. if (empty($mobile)) {
  39. return $this->response($this->error('', 'REQUEST_MOBILE'));
  40. }
  41. if (empty($withdraw_type)) {
  42. return $this->response($this->error('', 'REQUEST_WITHDRAW_TYPE'));
  43. }
  44. if (!empty($withdraw_type) && $withdraw_type == 'bank') {
  45. if (empty($branch_bank_name)) {
  46. return $this->response($this->error('', 'REQUEST_BRANCH_BANK_NAME'));
  47. }
  48. if (empty($bank_account)) {
  49. return $this->response($this->error('', 'REQUEST_BRANCH_BANK_ACCOUNT'));
  50. }
  51. }
  52. $member_bank_account_model = new MemberBankAccountModel();
  53. $data = [
  54. 'member_id' => $this->member_id,
  55. 'realname' => $realname,
  56. 'mobile' => $mobile,
  57. 'withdraw_type' => $withdraw_type,
  58. 'branch_bank_name' => $branch_bank_name,
  59. 'bank_account' => $bank_account,
  60. 'is_default' => 1
  61. ];
  62. $res = $member_bank_account_model->addMemberBankAccount($data);
  63. return $this->response($res);
  64. }
  65. /**
  66. * 编辑信息
  67. */
  68. public function edit()
  69. {
  70. $token = $this->checkToken();
  71. if ($token[ 'code' ] < 0) return $this->response($token);
  72. $id = isset($this->params[ 'id' ]) ? $this->params[ 'id' ] : 0;
  73. $realname = isset($this->params[ 'realname' ]) ? $this->params[ 'realname' ] : '';
  74. $mobile = isset($this->params[ 'mobile' ]) ? $this->params[ 'mobile' ] : '';
  75. $withdraw_type = isset($this->params[ 'withdraw_type' ]) ? $this->params[ 'withdraw_type' ] : '';// '账户类型 alipay 支付宝 bank 银行卡
  76. $branch_bank_name = isset($this->params[ 'branch_bank_name' ]) ? $this->params[ 'branch_bank_name' ] : '';// 银行支行信息
  77. $bank_account = isset($this->params[ 'bank_account' ]) ? $this->params[ 'bank_account' ] : '';// 银行账号
  78. if (empty($id)) {
  79. return $this->response($this->error('', 'REQUEST_ID'));
  80. }
  81. if (empty($realname)) {
  82. return $this->response($this->error('', 'REQUEST_REAL_NAME'));
  83. }
  84. if (empty($mobile)) {
  85. return $this->response($this->error('', 'REQUEST_MOBILE'));
  86. }
  87. if (empty($withdraw_type)) {
  88. return $this->response($this->error('', 'REQUEST_WITHDRAW_TYPE'));
  89. }
  90. if (!empty($withdraw_type) && $withdraw_type == 'bank') {
  91. if (empty($branch_bank_name)) {
  92. return $this->response($this->error('', 'REQUEST_BRANCH_BANK_NAME'));
  93. }
  94. if (empty($bank_account)) {
  95. return $this->response($this->error('', 'REQUEST_BRANCH_BANK_ACCOUNT'));
  96. }
  97. }
  98. $member_bank_account_model = new MemberBankAccountModel();
  99. $data = [
  100. 'id' => $id,
  101. 'member_id' => $this->member_id,
  102. 'realname' => $realname,
  103. 'mobile' => $mobile,
  104. 'withdraw_type' => $withdraw_type,
  105. 'branch_bank_name' => $branch_bank_name,
  106. 'bank_account' => $bank_account,
  107. 'is_default' => 1
  108. ];
  109. $res = $member_bank_account_model->editMemberBankAccount($data);
  110. return $this->response($res);
  111. }
  112. /**
  113. * 删除信息
  114. */
  115. public function delete()
  116. {
  117. $token = $this->checkToken();
  118. if ($token[ 'code' ] < 0) return $this->response($token);
  119. $id = isset($this->params[ 'id' ]) ? $this->params[ 'id' ] : 0;
  120. if (empty($id)) {
  121. return $this->response($this->error('', 'REQUEST_ID'));
  122. }
  123. $member_bank_account_model = new MemberBankAccountModel();
  124. $res = $member_bank_account_model->deleteMemberBankAccount([ [ 'member_id', '=', $this->member_id ], [ 'id', '=', $id ] ]);
  125. return $this->response($res);
  126. }
  127. /**
  128. * 基础信息
  129. */
  130. public function setDefault()
  131. {
  132. $token = $this->checkToken();
  133. if ($token[ 'code' ] < 0) return $this->response($token);
  134. $id = isset($this->params[ 'id' ]) ? $this->params[ 'id' ] : 0;
  135. if (empty($id)) {
  136. return $this->response($this->error('', 'REQUEST_ID'));
  137. }
  138. $member_bank_account_model = new MemberBankAccountModel();
  139. $info = $member_bank_account_model->modifyDefaultAccount($id, $this->member_id);
  140. return $this->response($info);
  141. }
  142. /**
  143. * 基础信息
  144. */
  145. public function info()
  146. {
  147. $token = $this->checkToken();
  148. if ($token[ 'code' ] < 0) return $this->response($token);
  149. $id = isset($this->params[ 'id' ]) ? $this->params[ 'id' ] : 0;
  150. if (empty($id)) {
  151. return $this->response($this->error('', 'REQUEST_ID'));
  152. }
  153. $member_bank_account_model = new MemberBankAccountModel();
  154. $info = $member_bank_account_model->getMemberBankAccountInfo([ [ 'member_id', '=', $this->member_id ], [ 'id', '=', $id ] ], 'id,member_id,realname,mobile,withdraw_type,branch_bank_name,bank_account,is_default');
  155. if (!empty($info[ 'data' ])) {
  156. $info[ 'data' ][ 'withdraw_type_name' ] = $member_bank_account_model->getWithdrawType()[ $info[ 'data' ][ 'withdraw_type' ] ];
  157. }
  158. return $this->response($info);
  159. }
  160. /**
  161. * 获取默认账户信息
  162. */
  163. public function defaultInfo()
  164. {
  165. $token = $this->checkToken();
  166. if ($token[ 'code' ] < 0) return $this->response($token);
  167. $member_bank_account_model = new MemberBankAccountModel();
  168. $info = $member_bank_account_model->getMemberBankAccountInfo([ [ 'member_id', '=', $this->member_id ], [ 'is_default', '=', 1 ] ], 'id,member_id,realname,mobile,withdraw_type,branch_bank_name,bank_account,is_default');
  169. if (!empty($info[ 'data' ])) {
  170. $info[ 'data' ][ 'withdraw_type_name' ] = $member_bank_account_model->getWithdrawType()[ $info[ 'data' ][ 'withdraw_type' ] ];
  171. }
  172. return $this->response($info);
  173. }
  174. /**
  175. * 分页列表信息
  176. */
  177. public function page()
  178. {
  179. $token = $this->checkToken();
  180. if ($token[ 'code' ] < 0) return $this->response($token);
  181. $page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1;
  182. $page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS;
  183. $member_bank_account_model = new MemberBankAccountModel();
  184. $list = $member_bank_account_model->getMemberBankAccountPageList([ [ 'member_id', '=', $this->member_id ] ], $page, $page_size);
  185. return $this->response($list);
  186. }
  187. }