Withdraw.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\api\controller\user\dealer;
  10. use app\api\controller\Controller;
  11. use app\api\model\dealer\Setting;
  12. use app\api\model\dealer\User as DealerUserModel;
  13. use app\api\model\dealer\Withdraw as WithdrawModel;
  14. /**
  15. * 分销商提现
  16. * Class Withdraw
  17. * @package app\api\controller\user\dealer
  18. */
  19. class Withdraw extends Controller
  20. {
  21. /* @var \app\api\model\User $user */
  22. private $user;
  23. private $dealer;
  24. private $setting;
  25. /**
  26. * 构造方法
  27. * @throws \app\common\exception\BaseException
  28. * @throws \think\exception\DbException
  29. */
  30. public function _initialize()
  31. {
  32. parent::_initialize();
  33. // 用户信息
  34. $this->user = $this->getUser();
  35. // 分销商用户信息
  36. $this->dealer = DealerUserModel::detail($this->user['user_id']);
  37. // 分销商设置
  38. $this->setting = Setting::getAll();
  39. }
  40. /**
  41. * 提交提现申请
  42. * @param $data
  43. * @return array
  44. * @throws \app\common\exception\BaseException
  45. */
  46. public function submit($data)
  47. {
  48. $formData = json_decode(htmlspecialchars_decode($data), true);
  49. $model = new WithdrawModel;
  50. if ($model->submit($this->dealer, $formData)) {
  51. return $this->renderSuccess([], '申请提现成功');
  52. }
  53. return $this->renderError($model->getError() ?: '提交失败');
  54. }
  55. /**
  56. * 分销商提现明细
  57. * @param int $status
  58. * @return array
  59. * @throws \think\exception\DbException
  60. */
  61. public function lists($status = -1)
  62. {
  63. $model = new WithdrawModel;
  64. return $this->renderSuccess([
  65. // 提现明细列表
  66. 'list' => $model->getList($this->user['user_id'], (int)$status),
  67. // 页面文字
  68. 'words' => $this->setting['words']['values'],
  69. ]);
  70. }
  71. }