Memberbankaccount.php 7.4 KB

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