Cash.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // 用户信息
  21. $this->user = $this->getUser();
  22. // 分销商用户信息
  23. $this->Agent = AgentUserModel::detail($this->user['user_id']);
  24. // 分销商设置
  25. $this->setting = Setting::getAll();
  26. }
  27. /**
  28. * 提交提现申请
  29. */
  30. public function submit($data)
  31. {
  32. $formData = json_decode(htmlspecialchars_decode($data), true);
  33. $model = new CashModel;
  34. if ($model->submit($this->Agent, $formData)) {
  35. return $this->renderSuccess('申请提现成功');
  36. }
  37. return $this->renderError($model->getError() ?: '提交失败');
  38. }
  39. /**
  40. * 分销商提现明细
  41. */
  42. public function lists($status = -1)
  43. {
  44. $model = new CashModel;
  45. return $this->renderSuccess('', [
  46. // 提现明细列表
  47. 'list' => $model->getList($this->user['user_id'], (int)$status,$this->postData()),
  48. // 页面文字
  49. 'words' => $this->setting['words']['values'],
  50. ]);
  51. }
  52. }