UserExtract.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\user;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\system\groupData\GroupDataRepository;
  14. use think\App;
  15. use app\validate\api\UserExtractValidate as validate;
  16. use app\common\repositories\user\UserExtractRepository as repository;
  17. class UserExtract extends BaseController
  18. {
  19. /**
  20. * @var repository
  21. */
  22. public $repository;
  23. /**
  24. * UserExtract constructor.
  25. * @param App $app
  26. * @param repository $repository
  27. */
  28. public function __construct(App $app,repository $repository)
  29. {
  30. parent::__construct($app);
  31. $this->repository = $repository;
  32. }
  33. public function lst()
  34. {
  35. [$page,$limit] = $this->getPage();
  36. $where = $this->request->params(['status']);
  37. $where['uid'] = $this->request->uid();
  38. return app('json')->success($this->repository->search($where,$page,$limit));
  39. }
  40. public function create(validate $validate)
  41. {
  42. $data = $this->checkParams($validate);
  43. $user = $this->request->userInfo();
  44. if($user['brokerage_price'] < (systemConfig('user_extract_min')))
  45. return app('json')->fail('可提现金额不足');
  46. if($data['extract_price'] < (systemConfig('user_extract_min')))
  47. return app('json')->fail('提现金额不得小于最低额度');
  48. if($user['brokerage_price'] < $data['extract_price'])
  49. return app('json')->fail('提现金额不足');
  50. $this->repository->create($user,$data);
  51. return app('json')->success('申请已提交');
  52. }
  53. public function checkParams(validate $validate)
  54. {
  55. $data = $this->request->params(['extract_type','bank_code','bank_address','alipay_code','wechat','extract_pic','extract_price','real_name']);
  56. $validate->check($data);
  57. return $data;
  58. }
  59. public function bankLst()
  60. {
  61. [$page,$limit] = $this->getPage();
  62. $data = app()->make(GroupDataRepository::class)->groupData('bank_list',0,$page,100);
  63. return app('json')->success($data);
  64. }
  65. }