User.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\store\controller\apps\dealer;
  3. use app\store\controller\Controller;
  4. use app\common\service\qrcode\Poster;
  5. use app\store\model\dealer\User as UserModel;
  6. use app\store\model\dealer\Referee as RefereeModel;
  7. use app\store\model\dealer\Setting as SettingModel;
  8. /**
  9. * 分销商管理
  10. * Class User
  11. * @package app\store\controller\apps\dealer
  12. */
  13. class User extends Controller
  14. {
  15. /**
  16. * 构造方法
  17. * @throws \app\common\exception\BaseException
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @throws \think\exception\DbException
  21. */
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. }
  26. /**
  27. * 分销商用户列表
  28. * @param string $search
  29. * @return mixed
  30. * @throws \think\exception\DbException
  31. */
  32. public function index($search = '')
  33. {
  34. $model = new UserModel;
  35. return $this->fetch('index', [
  36. 'list' => $model->getList($search),
  37. 'basicSetting' => SettingModel::getItem('basic'),
  38. ]);
  39. }
  40. /**
  41. * 分销商用户列表
  42. * @param string $user_id
  43. * @param int $level
  44. * @return mixed
  45. * @throws \think\exception\DbException
  46. */
  47. public function fans($user_id, $level = -1)
  48. {
  49. $model = new RefereeModel;
  50. return $this->fetch('fans', [
  51. 'list' => $model->getList($user_id, $level),
  52. 'basicSetting' => SettingModel::getItem('basic'),
  53. ]);
  54. }
  55. /**
  56. * 删除分销商
  57. * @param $dealer_id
  58. * @return array
  59. * @throws \think\exception\DbException
  60. */
  61. public function delete($dealer_id)
  62. {
  63. $model = UserModel::detail($dealer_id);
  64. if (!$model->setDelete()) {
  65. return $this->renderError('删除失败');
  66. }
  67. return $this->renderSuccess('删除成功');
  68. }
  69. /**
  70. * 分销商二维码
  71. * @param $dealer_id
  72. * @throws \app\common\exception\BaseException
  73. * @throws \think\exception\DbException
  74. * @throws \Exception
  75. */
  76. public function qrcode($dealer_id)
  77. {
  78. $model = UserModel::detail($dealer_id);
  79. $Qrcode = new Poster($model);
  80. $this->redirect($Qrcode->getImage());
  81. }
  82. }