UserLevelController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\api\controller\user;
  3. use app\models\system\SystemUserLevel;
  4. use app\models\system\SystemUserTask;
  5. use app\models\user\UserLevel;
  6. use app\Request;
  7. /**
  8. * 会员等级类
  9. * Class UserLevelController
  10. * @package app\api\controller\user
  11. */
  12. class UserLevelController
  13. {
  14. /**
  15. * 检测用户是否可以成为会员
  16. * @param Request $request
  17. * @return mixed
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public function detection(Request $request)
  22. {
  23. UserLevel::beginTrans();
  24. $res = UserLevel::setLevelComplete($request->uid());
  25. UserLevel::checkTrans($res);
  26. return app('json')->successful($res);
  27. }
  28. /**
  29. * 会员等级列表
  30. * @param Request $request
  31. * @return mixed
  32. */
  33. public function grade(Request $request)
  34. {
  35. return app('json')->successful(SystemUserLevel::getLevelList($request->uid()));
  36. }
  37. /**
  38. * 获取等级任务
  39. * @param Request $request
  40. * @param $id
  41. * @return mixed
  42. */
  43. public function task(Request $request, $id)
  44. {
  45. return app('json')->successful(SystemUserTask::getTashList($id, $request->uid()));
  46. }
  47. }