Memberbank.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 用户提现账户控制器
  14. */
  15. class Memberbank extends MobileMember {
  16. public function initialize() {
  17. parent::initialize();
  18. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/memberbank.lang.php');
  19. }
  20. /**
  21. * @api {POST} api/memberbank/bank_list 获取用户提现账户
  22. * @apiVersion 1.0.0
  23. * @apiGroup Memberbank
  24. *
  25. * @apiHeader {String} X-DS-KEY 用户授权token
  26. *
  27. * @apiSuccess {String} code 返回码,10000为成功
  28. * @apiSuccess {String} message 返回消息
  29. * @apiSuccess {Object} result 返回数据
  30. * @apiSuccess {String} result.bank_list 提现账户
  31. * @apiSuccess {String} result.bank_list.memberbank_id ID
  32. * @apiSuccess {String} result.bank_list.memberbank_type 类型bank银行 alipay支付宝
  33. * @apiSuccess {String} result.bank_list.memberbank_truename 收款人姓名
  34. * @apiSuccess {String} result.bank_list.memberbank_name 收款银行
  35. * @apiSuccess {String} result.bank_list.memberbank_no 收款账户
  36. */
  37. public function bank_list() {
  38. $memberbank_model = model('memberbank');
  39. $bank_list = $memberbank_model->getMemberbankList(array('member_id' => $this->member_info['member_id']));
  40. $member_wxinfo = unserialize($this->member_info['member_wxinfo']);
  41. if (!empty($member_wxinfo) && is_array($member_wxinfo) && isset($member_wxinfo['member_wxopenid']) && $member_wxinfo['member_wxopenid']) {
  42. if (empty($bank_list)) {
  43. $bank_list = array();
  44. }
  45. $bank_list[] = array('memberbank_id' => -1, 'memberbank_type' => 'weixin', 'memberbank_no' => $member_wxinfo['nickname'], 'member_wxinfo' => $member_wxinfo);
  46. }
  47. ds_json_encode(10000, '', array('bank_list' => $bank_list));
  48. }
  49. /**
  50. * @api {POST} api/memberbank/bank_info 获取提现账户
  51. * @apiVersion 1.0.0
  52. * @apiGroup Memberbank
  53. *
  54. * @apiHeader {String} X-DS-KEY 用户授权token
  55. *
  56. * @apiParam {String} memberbank_id 提现账户ID
  57. *
  58. * @apiSuccess {String} code 返回码,10000为成功
  59. * @apiSuccess {String} message 返回消息
  60. * @apiSuccess {Object} result 返回数据
  61. * @apiSuccess {String} result.bank_info 提现账户信息
  62. * @apiSuccess {String} result.bank_info.memberbank_id ID
  63. * @apiSuccess {String} result.bank_info.memberbank_type 类型bank银行 alipay支付宝
  64. * @apiSuccess {String} result.bank_info.memberbank_truename 收款人姓名
  65. * @apiSuccess {String} result.bank_info.memberbank_name 收款银行
  66. * @apiSuccess {String} result.bank_info.memberbank_no 收款账户
  67. */
  68. public function bank_info() {
  69. $memberbank_id = intval(input('post.memberbank_id'));
  70. $memberbank_model = model('memberbank');
  71. $condition = array();
  72. $condition[] = array('memberbank_id','=',$memberbank_id);
  73. $bank_info = $memberbank_model->getMemberbankInfo($condition);
  74. if (!empty($memberbank_id) && $bank_info['member_id'] == $this->member_info['member_id']) {
  75. ds_json_encode(10000, '', array('bank_info' => $bank_info));
  76. } else {
  77. ds_json_encode(10001, lang('memberbank_does_not_exist'));
  78. }
  79. }
  80. /**
  81. * @api {POST} api/memberbank/bank_del 删除提现账户
  82. * @apiVersion 1.0.0
  83. * @apiGroup Memberbank
  84. *
  85. * @apiHeader {String} X-DS-KEY 用户授权token
  86. *
  87. * @apiParam {String} memberbank_id 提现账户ID
  88. *
  89. * @apiSuccess {String} code 返回码,10000为成功
  90. * @apiSuccess {String} message 返回消息
  91. * @apiSuccess {Object} result 返回数据
  92. */
  93. public function bank_del() {
  94. $memberbank_id = intval(input('post.memberbank_id'));
  95. $memberbank_model = model('memberbank');
  96. $condition = array();
  97. $condition[] = array('memberbank_id','=',$memberbank_id);
  98. $condition[] = array('member_id','=',$this->member_info['member_id']);
  99. $memberbank_model->delMemberbank($condition);
  100. ds_json_encode(10000, '', 1);
  101. }
  102. /**
  103. * @api {POST} api/memberbank/bank_add 新增提现账户
  104. * @apiVersion 1.0.0
  105. * @apiGroup Memberbank
  106. *
  107. * @apiHeader {String} X-DS-KEY 用户授权token
  108. *
  109. * @apiParam {String} memberbank_type 类型bank银行 alipay支付宝
  110. * @apiParam {String} memberbank_truename 收款人姓名
  111. * @apiParam {String} memberbank_name 收款银行
  112. * @apiParam {String} memberbank_no 收款账户
  113. *
  114. * @apiSuccess {String} code 返回码,10000为成功
  115. * @apiSuccess {String} message 返回消息
  116. * @apiSuccess {Object} result 返回数据
  117. */
  118. public function bank_add() {
  119. $memberbank_model = model('memberbank');
  120. $data = array(
  121. 'member_id' => $this->member_info['member_id'],
  122. 'memberbank_type' => input('post.memberbank_type'),
  123. 'memberbank_truename' => input('post.memberbank_truename'),
  124. 'memberbank_name' => input('post.memberbank_name'),
  125. 'memberbank_no' => input('post.memberbank_no'),
  126. );
  127. $memberbank_validate = ds_validate('memberbank');
  128. if (!$memberbank_validate->scene('add')->check($data)) {
  129. ds_json_encode(10001, $memberbank_validate->getError());
  130. }
  131. $result = $memberbank_model->addMemberbank($data);
  132. if ($result) {
  133. ds_json_encode(10000, '', array('memberbank_id' => $result));
  134. } else {
  135. ds_json_encode(10001, lang('ds_common_op_fail'));
  136. }
  137. }
  138. /**
  139. * @api {POST} api/memberbank/bank_edit 编辑提现账户
  140. * @apiVersion 1.0.0
  141. * @apiGroup Memberbank
  142. *
  143. * @apiHeader {String} X-DS-KEY 用户授权token
  144. *
  145. * @apiParam {String} memberbank_id 提现账户ID
  146. * @apiParam {String} memberbank_type 类型bank银行 alipay支付宝
  147. * @apiParam {String} memberbank_truename 收款人姓名
  148. * @apiParam {String} memberbank_name 收款银行
  149. * @apiParam {String} memberbank_no 收款账户
  150. *
  151. * @apiSuccess {String} code 返回码,10000为成功
  152. * @apiSuccess {String} message 返回消息
  153. * @apiSuccess {Object} result 返回数据
  154. */
  155. public function bank_edit() {
  156. $memberbank_id = intval(input('post.memberbank_id'));
  157. $memberbank_model = model('memberbank');
  158. //验证提现账户是否为本人
  159. $memberbank_info = $memberbank_model->getOneMemberbank($memberbank_id);
  160. if ($memberbank_info['member_id'] != $this->member_info['member_id']) {
  161. ds_json_encode(10001, lang('param_error'));
  162. }
  163. $data = array(
  164. 'memberbank_type' => input('post.memberbank_type'),
  165. 'memberbank_truename' => input('post.memberbank_truename'),
  166. 'memberbank_name' => input('post.memberbank_name'),
  167. 'memberbank_no' => input('post.memberbank_no'),
  168. );
  169. $memberbank_validate = ds_validate('memberbank');
  170. if (!$memberbank_validate->scene('edit')->check($data)) {
  171. ds_json_encode(10001, $memberbank_validate->getError());
  172. }
  173. $result = $memberbank_model->editMemberbank($data, array('memberbank_id' => $memberbank_id, 'member_id' => $this->member_info['member_id']));
  174. if ($result) {
  175. ds_json_encode(10000, '', 1);
  176. } else {
  177. ds_json_encode(10001, lang('ds_common_op_fail'));
  178. }
  179. }
  180. }