Cash.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\api\controller\plus\agent;
  3. use app\api\controller\Controller;
  4. use app\api\model\plus\agent\Setting;
  5. use app\api\model\plus\agent\User as AgentUserModel;
  6. use app\api\model\plus\agent\Cash as CashModel;
  7. /**
  8. * 分销商提现
  9. */
  10. class Cash extends Controller
  11. {
  12. private $user;
  13. private $Agent;
  14. private $setting;
  15. /**
  16. * 构造方法
  17. */
  18. public function initialize()
  19. {
  20. parent::initialize();
  21. // 用户信息
  22. $this->user = $this->getUser();
  23. // 分销商用户信息
  24. $this->Agent = AgentUserModel::detail($this->user['user_id']);
  25. // 分销商设置
  26. $this->setting = Setting::getAll();
  27. }
  28. /**
  29. * 提交提现申请
  30. */
  31. public function submit($data)
  32. {
  33. $formData = json_decode(htmlspecialchars_decode($data), true);
  34. $model = new CashModel;
  35. if ($model->submit($this->Agent, $formData)) {
  36. return $this->renderSuccess('申请提现成功');
  37. }
  38. return $this->renderError($model->getError() ?: '提交失败');
  39. }
  40. /**
  41. * 分销商提现明细
  42. */
  43. public function lists($status = -1)
  44. {
  45. $model = new CashModel;
  46. return $this->renderSuccess('', [
  47. // 提现明细列表
  48. 'list' => $model->getList($this->user['user_id'], (int)$status,$this->postData()),
  49. // 页面文字
  50. 'words' => $this->setting['words']['values'],
  51. ]);
  52. }
  53. }