截流自动化的商城平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

User.php 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\admin\logic\user\TagLogic;
  4. use app\common\basics\AdminBase;
  5. use app\admin\logic\user\LevelLogic;
  6. use app\admin\logic\user\UserLogic;
  7. use app\common\model\user\UserLevel;
  8. use app\common\server\JsonServer;
  9. use app\common\enum\ClientEnum;
  10. use app\admin\validate\user\UserValidate;
  11. use think\exception\ValidateException;
  12. class User extends AdminBase
  13. {
  14. public function lists(){
  15. if ($this->request->isAjax()) {
  16. $get = $this->request->get();
  17. return JsonServer::success('', UserLogic::lists($get));
  18. }
  19. return view('', [
  20. 'level_list' => LevelLogic::getLevelList(),
  21. 'tag_list' => TagLogic::getTagList(),
  22. 'client_list' => ClientEnum::getClient(true)
  23. ]);
  24. }
  25. public function setTag(){
  26. if($this->request->isAjax()){
  27. $post = $this->request->post();
  28. try{
  29. validate(UserValidate::class)->scene('setTag')->check($post);
  30. }catch(ValidateException $e) {
  31. return JsonServer::error($e->getMessage());
  32. }
  33. $result = UserLogic::setTag($post);
  34. if($result === true) {
  35. return JsonServer::success('设置成功');
  36. }
  37. return JsonServer::error(UserLogic::getError());
  38. }
  39. return view('', [
  40. 'tag_list' => json_encode(TagLogic::getTagList())
  41. ]);
  42. }
  43. public function edit(){
  44. if($this->request->isAjax()){
  45. $post = $this->request->post();
  46. try{
  47. validate(UserValidate::class)->scene('edit')->check($post);
  48. }catch(ValidateException $e) {
  49. return JsonServer::error($e->getMessage());
  50. }
  51. $result = UserLogic::edit($post);
  52. if($result === true) {
  53. return JsonServer::success('编辑成功');
  54. }
  55. return JsonServer::error(UserLogic::getError());
  56. }
  57. $id = $this->request->get('id', '', 'intval');
  58. $detail = UserLogic::getUser($id);
  59. return view('', [
  60. 'info' => $detail,
  61. 'tag_list' => json_encode(TagLogic::getTagList())
  62. ]);
  63. }
  64. public function info(){
  65. $id = $this->request->get('id', '', 'intval');
  66. $detail = UserLogic::getInfo($id);
  67. return view('', [
  68. 'detail' => $detail
  69. ]);
  70. }
  71. public function adjustAccount(){
  72. if ($this->request->isAjax()) {
  73. $post = $this->request->post();
  74. try{
  75. validate(UserValidate::class)->scene('adjustAccount')->check($post);
  76. }catch(ValidateException $e) {
  77. return JsonServer::error($e->getError());
  78. }
  79. $result = UserLogic::adjustAccount($post);
  80. if($result === true) {
  81. return JsonServer::success('调整成功');
  82. }
  83. return JsonServer::error(UserLogic::getError());
  84. }
  85. $id = $this->request->get('id', '', 'intval');
  86. return view('', [
  87. 'info' => UserLogic::getUser($id)
  88. ]);
  89. }
  90. public function adjustLevel(){
  91. if ($this->request->isPost()) {
  92. $params = $this->request->post();
  93. $result = UserLogic::adjustLevel($params);
  94. if ($result) {
  95. return JsonServer::success('调整成功');
  96. }
  97. return JsonServer::error(UserLogic::getError());
  98. }
  99. $id = $this->request->get('id/d');
  100. $levels = UserLevel::where('del', 0)->order('growth_value', 'asc')->column('id,name', 'id');
  101. $userLevel = \app\common\model\user\User::where('id', $id)->value('level');
  102. $userLevelName = isset($levels[$userLevel]) ? $levels[$userLevel]['name'] : '无等级';
  103. return view('', [
  104. 'levels' => $levels,
  105. 'user_level_name' => $userLevelName,
  106. 'user_id' => $id
  107. ]);
  108. }
  109. public function adjustFirstLeader()
  110. {
  111. if($this->request->isPost()) {
  112. $params = $this->request->post();
  113. $result = UserLogic::adjustFirstLeader($params);
  114. if ($result) {
  115. return JsonServer::success('调整成功');
  116. }
  117. return JsonServer::error(UserLogic::getError());
  118. }
  119. $id = $this->request->get('id/d');
  120. $user = \app\common\model\user\User::field('id,sn,nickname,first_leader')->findOrEmpty($id)->toArray();
  121. $firstLeader = \app\common\model\user\User::getUserInfo($user['first_leader']);
  122. return view('', [
  123. 'user_id' => $id,
  124. 'user' => $user,
  125. 'first_leader' => $firstLeader
  126. ]);
  127. }
  128. public function userLists()
  129. {
  130. if ($this->request->isPost()) {
  131. $params = $this->request->post();
  132. $lists = UserLogic::userLists($params);
  133. return JsonServer::success('', $lists);
  134. }
  135. return view();
  136. }
  137. /**
  138. * @notes 推荐下级
  139. * @return \think\response\View
  140. * @author Tab
  141. * @date 2021/9/8 20:40
  142. */
  143. public function fans()
  144. {
  145. if ($this->request->isPost()) {
  146. $params = $this->request->post();
  147. $result = UserLogic::fans($params);
  148. return JsonServer::success('', $result);
  149. }
  150. $id = $this->request->get('id/d');
  151. return view('', ['id' => $id]);
  152. }
  153. }