Memberwithdraw.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\api\controller;
  13. use app\model\member\Withdraw as WithdrawModel;
  14. use app\model\member\Member as MemberModel;
  15. /**
  16. * 会员提现
  17. */
  18. class Memberwithdraw extends BaseApi
  19. {
  20. /**
  21. * 会员提现信息
  22. */
  23. public function info()
  24. {
  25. $token = $this->checkToken();
  26. if ($token['code'] < 0) return $this->response($token);
  27. $member_model = new MemberModel();
  28. $member_info_result = $member_model->getMemberInfo([ [ 'member_id', '=', $token['data']['member_id'] ] ], 'balance_money,balance_withdraw_apply,balance_withdraw');
  29. // $withdraw_model = new WithdrawModel();
  30. // $transfer_type_list = $withdraw_model->getTransferType();
  31. $config_model = new WithdrawModel();
  32. $config_result = $config_model->getConfig();
  33. $config = $config_result["data"]['value'];
  34. $config['is_use'] = $config_result["data"]['is_use'];
  35. $data = array(
  36. "member_info" => $member_info_result["data"],
  37. // "transfer_type_list" => $transfer_type_list,
  38. "config" => $config
  39. );
  40. return $this->response($this->success($data));
  41. }
  42. /**
  43. * 会员提现配置
  44. */
  45. public function config()
  46. {
  47. $token = $this->checkToken();
  48. if ($token['code'] < 0) return $this->response($token);
  49. $config_model = new WithdrawModel();
  50. $config_result = $config_model->getConfig();
  51. return $this->response($config_result);
  52. }
  53. /**
  54. * 获取转账方式
  55. * @return false|string
  56. */
  57. public function transferType()
  58. {
  59. $withdraw_model = new WithdrawModel();
  60. $transfer_type_list = $withdraw_model->getTransferType();
  61. return $this->response($this->success($transfer_type_list));
  62. }
  63. /**
  64. * 申请提现
  65. * @return mixed
  66. */
  67. public function apply()
  68. {
  69. $token = $this->checkToken();
  70. if ($token['code'] < 0) return $this->response($token);
  71. $apply_money = isset($this->params['apply_money']) ? $this->params['apply_money'] : 0;
  72. $transfer_type = isset($this->params['transfer_type']) ? $this->params['transfer_type'] : 'bank';//提现方式
  73. $realname = isset($this->params['realname']) ? $this->params['realname'] : '';//真实姓名
  74. $bank_name = isset($this->params['bank_name']) ? $this->params['bank_name'] : '';//银行名称
  75. $account_number = isset($this->params['account_number']) ? $this->params['account_number'] : '';//账号名称
  76. $mobile = isset($this->params['mobile']) ? $this->params['mobile'] : '';//手机号
  77. $app_type = isset($this->params['app_type']) ? $this->params['app_type'] : '';;
  78. $withdraw_model = new WithdrawModel();
  79. $data = array(
  80. "member_id" => $token['data']['member_id'],
  81. "transfer_type" => $transfer_type,
  82. "realname" => $realname,
  83. "bank_name" => $bank_name,
  84. "account_number" => $account_number,
  85. "apply_money" => $apply_money,
  86. "mobile" => $mobile,
  87. "app_type" => $app_type
  88. );
  89. $result = $withdraw_model->apply($data);
  90. $member_account_modle = new \app\model\member\MemberAccount();
  91. $member_account_modle->addMemberAccount($token['data']['member_id'], 'balance_money', -$apply_money, 'withdrawal', '提现', '提现');
  92. return $this->response($result);
  93. }
  94. /**
  95. * 提现详情
  96. * @return mixed
  97. */
  98. public function detail()
  99. {
  100. $token = $this->checkToken();
  101. if ($token['code'] < 0) return $this->response($token);
  102. $id = isset($this->params['id']) ? $this->params['id'] : 0;
  103. if (empty($id)) {
  104. return $this->response($this->error('', 'REQUEST_ID'));
  105. }
  106. $condition = [
  107. [ "member_id", "=", $token['data']['member_id'] ],
  108. [ "id", "=", $id ]
  109. ];
  110. $withdraw_model = new WithdrawModel();
  111. $info = $withdraw_model->getMemberWithdrawDetail($condition);
  112. return $this->response($info);
  113. }
  114. /**
  115. * 提现记录
  116. * @return mixed
  117. */
  118. public function page()
  119. {
  120. $token = $this->checkToken();
  121. if ($token['code'] < 0) return $this->response($token);
  122. $page = isset($this->params['page']) ? $this->params['page'] : 1;
  123. $page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
  124. $condition = [
  125. [ "member_id", "=", $token['data']['member_id'] ]
  126. ];
  127. $withdraw_model = new WithdrawModel();
  128. $list = $withdraw_model->getMemberWithdrawPageList($condition, $page, $page_size, "apply_time desc", "id,withdraw_no,apply_money,apply_time,status,status_name,transfer_type_name");
  129. return $this->response($list);
  130. }
  131. }