Withdraw.php 1.9 KB

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