Withdraw.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace addons\shopro\controller;
  3. use app\admin\model\shopro\Withdraw as WithdrawModel;
  4. use addons\shopro\service\Withdraw as WithdrawLibrary;
  5. class Withdraw extends Common
  6. {
  7. protected $noNeedLogin = [];
  8. protected $noNeedRight = ['*'];
  9. public function index()
  10. {
  11. $user = auth_user();
  12. $withdraws = WithdrawModel::where(['user_id' => $user->id])->order('id desc')->paginate($this->request->param('list_rows', 10))->each(function ($withdraw) {
  13. $withdraw->hidden(['withdraw_info']);
  14. });
  15. $this->success('获取成功', $withdraws);
  16. }
  17. // 提现规则
  18. public function rules()
  19. {
  20. $user = auth_user();
  21. $config = (new WithdrawLibrary($user))->config;
  22. $this->success('提现规则', $config);
  23. }
  24. // 发起提现请求
  25. public function apply()
  26. {
  27. $user = auth_user();
  28. $params = $this->request->param();
  29. $this->svalidate($params, ".apply");
  30. $withdrawLib = new WithdrawLibrary($user);
  31. $withdraw = $withdrawLib->apply($params);
  32. $this->success('申请成功', $withdraw);
  33. }
  34. }