Withdraw.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\fenxiao\api\controller;
  11. use addon\fenxiao\model\FenxiaoWithdraw;
  12. use app\api\controller\BaseApi;
  13. use app\model\member\Member;
  14. /**
  15. * 分销提现
  16. */
  17. class Withdraw extends BaseApi
  18. {
  19. // /**
  20. // * 申请提现
  21. // */
  22. // public function apply()
  23. // {
  24. // $token = $this->checkToken();
  25. // if ($token['code'] < 0) return $this->response($token);
  26. //
  27. // $member_id = $this->member_id;
  28. // $money = isset($this->params['money']) ? $this->params['money'] : '';
  29. //
  30. // if (empty($money)) {
  31. // return $this->response($this->error('', 'REQUEST_MONEY'));
  32. // }
  33. //
  34. // $data = [
  35. // 'member_id' => $member_id,
  36. // 'money' => $money,
  37. // 'site_id' => $this->site_id
  38. // ];
  39. //
  40. // $withdraw_model = new FenxiaoWithdraw();
  41. // $res = $withdraw_model->addFenxiaoWithdraw($data);
  42. //
  43. // return $this->response($res);
  44. // }
  45. /**
  46. * 提现记录分页
  47. * @return false|string
  48. */
  49. public function page()
  50. {
  51. $token = $this->checkToken();
  52. if ($token['code'] < 0) return $this->response($token);
  53. $page = isset($this->params['page']) ? $this->params['page'] : 1;
  54. $page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
  55. $status = isset($this->params['status']) ? $this->params['status'] : 0;// 当前状态 1待审核 2待转账 3已转账 -1 已拒绝
  56. $condition = [
  57. ['member_id', '=', $this->member_id]
  58. ];
  59. if (!empty($status)) {
  60. $condition[] = ['status', '=', $status];
  61. }
  62. $order = 'id desc';
  63. $withdraw_model = new FenxiaoWithdraw();
  64. $list = $withdraw_model->getFenxiaoWithdrawPageList($condition, $page, $page_size, $order);
  65. foreach($list['data']['list'] as $k => $v){
  66. $list['data']['list'][$k] = $withdraw_model->tran($v);
  67. }
  68. return $this->response($list);
  69. }
  70. /**
  71. * 获取转账方式
  72. * @return false|string
  73. */
  74. public function transferType()
  75. {
  76. $token = $this->checkToken();
  77. if ($token[ 'code' ] < 0) return $this->response($token);
  78. $member_model = new Member();
  79. $member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $token[ 'data' ][ 'member_id' ] ] ], 'site_id,wx_openid,weapp_openid');
  80. $withdraw_config_model = new \addon\fenxiao\model\Config();
  81. $transfer_type_list = $withdraw_config_model->getTransferType($member_info[ 'data' ][ 'site_id' ], 'shop');
  82. if (empty($member_info[ 'data' ][ 'wx_openid' ]) && empty($member_info[ 'data' ][ 'weapp_openid' ])) {
  83. unset($transfer_type_list[ 'wechatpay' ]);
  84. }
  85. return $this->response($this->success($transfer_type_list));
  86. }
  87. /**
  88. * 申请提现
  89. * @return mixed
  90. */
  91. public function apply()
  92. {
  93. $token = $this->checkToken();
  94. if ($token[ 'code' ] < 0) return $this->response($token);
  95. $apply_money = $this->params[ 'apply_money' ] ?? 0;
  96. $transfer_type = $this->params[ 'transfer_type' ] ?? '';//提现方式
  97. $realname = $this->params[ 'realname' ] ?? '';//真实姓名
  98. $bank_name = $this->params[ 'bank_name' ] ?? '';//银行名称
  99. $account_number = $this->params[ 'account_number' ] ?? '';//账号名称
  100. $mobile = $this->params[ 'mobile' ] ?? '';//手机号
  101. $app_type = $this->params[ 'app_type' ];
  102. $fenxiao_withdraw_model = new FenxiaoWithdraw();
  103. $data = array (
  104. 'member_id' => $this->member_id,
  105. 'transfer_type' => $transfer_type,
  106. 'realname' => $realname,
  107. 'bank_name' => $bank_name,
  108. 'account_number' => $account_number,
  109. 'apply_money' => $apply_money,
  110. 'mobile' => $mobile,
  111. 'app_type' => $app_type
  112. );
  113. $result = $fenxiao_withdraw_model->apply($data, $this->site_id, 'shop');
  114. return $this->response($result);
  115. }
  116. /**
  117. * 提现详情
  118. * @return mixed
  119. */
  120. public function detail()
  121. {
  122. $token = $this->checkToken();
  123. if ($token[ 'code' ] < 0) return $this->response($token);
  124. $id = $this->params[ 'id' ] ?? 0;
  125. $fenxiao_withdraw_model = new FenxiaoWithdraw();
  126. $params = array (
  127. 'id' => $id,
  128. 'site_id' => $this->site_id
  129. );
  130. $result = $fenxiao_withdraw_model->getFenxiaoWithdrawDetail($params);
  131. return $this->response($result);
  132. }
  133. }