Memberbank.php 8.2 KB

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