UserExtract.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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. /**
  34. * 提现记录
  35. * @return \think\response\Json
  36. * @author wuhaotian
  37. * @email 442384644@qq.com
  38. * @date 2024/7/10
  39. */
  40. public function lst()
  41. {
  42. [$page,$limit] = $this->getPage();
  43. $where = $this->request->params(['status']);
  44. [$start,$stop]= $this->request->params(['start','stop'],true);
  45. $where['date'] = $start&&$stop ? date('Y/m/d',$start).'-'.date('Y/m/d',$stop) : '';
  46. $where['uid'] = $this->request->uid();
  47. return app('json')->success($this->repository->getList($where,$page,$limit));
  48. }
  49. /**
  50. * 提现记录详情
  51. *
  52. * @param $id
  53. * @return void
  54. */
  55. public function detail($id)
  56. {
  57. if(!$id) return app('json')->fail('参数错误');
  58. $info = $this->repository->get($id);
  59. if(!$info) {
  60. return app('json')->fail('提现记录不存在');
  61. }
  62. return app('json')->success($info);
  63. }
  64. /**
  65. * 用户提现
  66. * @param validate $validate
  67. * @return \think\response\Json
  68. * @author wuhaotian
  69. * @email 442384644@qq.com
  70. * @date 2024/7/10
  71. */
  72. public function create(validate $validate)
  73. {
  74. $data = $this->checkParams($validate);
  75. $user = $this->request->userInfo();
  76. $this->repository->create($user,$data);
  77. return app('json')->success($data['extract_type'] == $this->repository::EXTRACT_TYPE_YUE ? '已提现至余额' : '申请已提交');
  78. }
  79. /**
  80. * 验证数据
  81. * @param validate $validate
  82. * @return array|mixed|string|string[]
  83. * @author wuhaotian
  84. * @email 442384644@qq.com
  85. * @date 2024/7/10
  86. */
  87. public function checkParams(validate $validate)
  88. {
  89. $data = $this->request->params(['extract_type','bank_code','bank_address','alipay_code','wechat','extract_pic','extract_price','real_name','bank_name']);
  90. $validate->check($data);
  91. return $data;
  92. }
  93. /**
  94. * 银行列表
  95. * @return \think\response\Json
  96. * @author wuhaotian
  97. * @email 442384644@qq.com
  98. * @date 2024/7/10
  99. */
  100. public function bankLst()
  101. {
  102. [$page,$limit] = $this->getPage();
  103. $data = app()->make(GroupDataRepository::class)->groupData('bank_list',0,$page,100);
  104. return app('json')->success($data);
  105. }
  106. /**
  107. * 历史银行数据
  108. * @return \think\response\Json
  109. * @author wuhaotian
  110. * @email 442384644@qq.com
  111. * @date 2024/7/10
  112. */
  113. public function historyBank()
  114. {
  115. $data = $this->repository->getHistoryBank($this->request->userInfo()->uid);
  116. return app('json')->success($data ?? []);
  117. }
  118. }