UserLevelController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. use think\db\exception\DataNotFoundException;
  8. use think\db\exception\DbException;
  9. use think\db\exception\ModelNotFoundException;
  10. /**
  11. * 会员等级类
  12. * Class UserLevelController
  13. * @package app\api\controller\user
  14. */
  15. class UserLevelController
  16. {
  17. /**
  18. * 检测用户是否可以成为会员
  19. * @param Request $request
  20. * @return mixed
  21. * @throws DataNotFoundException
  22. * @throws ModelNotFoundException
  23. * @throws DbException
  24. */
  25. public function detection(Request $request)
  26. {
  27. return app('json')->successful(UserLevel::setLevelComplete($request->uid(), false, $request->mer_id()));
  28. }
  29. /**
  30. * 会员等级列表
  31. * @param Request $request
  32. * @return mixed
  33. * @throws DataNotFoundException
  34. * @throws ModelNotFoundException
  35. * @throws DbException
  36. */
  37. public function grade(Request $request)
  38. {
  39. return app('json')->successful(SystemUserLevel::getLevelList($request->uid(), $request->mer_id()));
  40. }
  41. /**
  42. * 获取等级任务
  43. * @param Request $request
  44. * @param $id
  45. * @return mixed
  46. * @throws DataNotFoundException
  47. * @throws DbException
  48. * @throws ModelNotFoundException
  49. */
  50. public function task(Request $request, $id)
  51. {
  52. return app('json')->successful(SystemUserTask::getTashList($id, $request->uid(), null, 1400, $request->mer_id()));
  53. }
  54. }