Shopwithdraw.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\shopapi\controller;
  13. use app\model\member\Withdraw as MemberWithdrawModel;
  14. use app\model\shop\ShopAccount;
  15. use app\model\shop\Shop as ShopModel;
  16. use app\model\web\Account as AccountModel;
  17. class Shopwithdraw extends BaseApi
  18. {
  19. public function __construct()
  20. {
  21. //执行父类构造函数
  22. parent::__construct();
  23. $token = $this->checkToken();
  24. if ($token['code'] < 0) {
  25. echo $this->response($token);
  26. exit;
  27. }
  28. }
  29. /**
  30. * 账户信息
  31. * @return false|string
  32. */
  33. public function info()
  34. {
  35. $account_model = new AccountModel();
  36. //会员余额
  37. $member_balance_sum = $account_model->getMemberBalanceSum($this->site_id);
  38. $is_memberwithdraw = addon_is_exit('memberwithdraw', $this->site_id);
  39. if ($is_memberwithdraw == 1) {
  40. $data = $member_balance_sum['data'];
  41. } else {
  42. $data = number_format($member_balance_sum['data']['balance'] + $member_balance_sum['data']['balance_money'], 2, '.', '');
  43. }
  44. return $this->response($this->success($data));
  45. }
  46. /**
  47. * 申请提现
  48. * */
  49. public function apply()
  50. {
  51. $money = isset($this->params['apply_money']) ? $this->params['apply_money'] : '';
  52. $shop_account_model = new ShopAccount();
  53. $result = $shop_account_model->applyWithdraw($this->site_id, $money);
  54. return $this->response($result);
  55. }
  56. /**
  57. * 获取提现记录
  58. */
  59. public function lists()
  60. {
  61. $withdraw_model = new MemberWithdrawModel();
  62. $page = isset($this->params['page']) ? $this->params['page'] : 1;
  63. $page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
  64. $status = isset($this->params['status']) ? $this->params['status'] : '';
  65. $start_time = isset($this->params['start_time']) ? $this->params['start_time'] : '';
  66. $end_time = isset($this->params['end_time']) ? $this->params['end_time'] : '';
  67. $search_text = isset($this->params['search_text'])?$this->params['search_text']:'';
  68. $condition[] = ['site_id', '=', $this->site_id];
  69. if (!empty($status)) {
  70. if ($status == 3) {//待审核
  71. $condition[] = ['status', '=', 0];
  72. } else {
  73. $condition[] = ['status', '=', $status];
  74. }
  75. }
  76. if(!empty($search_text)){
  77. $condition[] =['withdraw_no|member_name|realname|mobile|account_number' , "like", "%" . $search_text . "%"];
  78. }
  79. if (!empty($start_time) && empty($end_time)) {
  80. $condition[] = ['apply_time', '>=', $start_time];
  81. } elseif (empty($start_time) && !empty($end_time)) {
  82. $condition[] = ['apply_time', '<=', $end_time];
  83. } elseif (!empty($start_time) && !empty($end_time)) {
  84. $condition[] = ['apply_time', 'between', [$start_time, $end_time]];
  85. }
  86. $order = "id desc";
  87. $list = $withdraw_model->getMemberWithdrawPageList($condition, $page, $page_size, $order);
  88. return $this->response($list);
  89. }
  90. /**
  91. * 提现信息
  92. */
  93. public function detail()
  94. {
  95. $id = isset($this->params['id']) ? $this->params['id'] : 0;
  96. $withdraw_model = new MemberWithdrawModel();
  97. $info = $withdraw_model->getMemberWithdrawInfo([["id", "=", $id], ['site_id', '=', $this->site_id]]);
  98. return $this->response($info);
  99. }
  100. /**
  101. * 同意
  102. * @return array
  103. */
  104. public function agree()
  105. {
  106. $id = isset($this->params['id']) ? $this->params['id'] : 0;
  107. $withdraw_model = new MemberWithdrawModel();
  108. $condition = array(
  109. ['site_id', '=', $this->site_id],
  110. ["id", "=", $id]
  111. );
  112. $result = $withdraw_model->agree($condition);
  113. return $this->response($result);
  114. }
  115. /**
  116. * 拒绝
  117. * @return array
  118. */
  119. public function refuse()
  120. {
  121. $id = isset($this->params['id']) ? $this->params['id'] : 0;
  122. $refuse_reason = isset($this->params['refuse_reason']) ? $this->params['refuse_reason'] : 0;
  123. $withdraw_model = new MemberWithdrawModel();
  124. $condition = array(
  125. ['site_id', '=', $this->site_id],
  126. ["id", "=", $id]
  127. );
  128. $data = array(
  129. "refuse_reason" => $refuse_reason
  130. );
  131. $result = $withdraw_model->refuse($condition, $data);
  132. return $this->response($result);
  133. }
  134. }