MemberController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Http\Validator\MemberValidator;
  13. use App\Services\Common\MemberService;
  14. /**
  15. * 会员管理-控制器
  16. * @author laravel开发员
  17. * @since 2020/11/11
  18. * Class MemberController
  19. * @package App\Http\Controllers
  20. */
  21. class MemberController extends Backend
  22. {
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. * MemberController constructor.
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. $this->service = new MemberService();
  33. }
  34. /**
  35. * 列表
  36. * @return array
  37. */
  38. public function index()
  39. {
  40. return $this->service->getList();
  41. }
  42. /**
  43. * 修改上级
  44. * @return array
  45. */
  46. public function modifyParent()
  47. {
  48. $params = request()->post();
  49. if(MemberService::make()->modifyParent($this->userId,$params)){
  50. return message(MemberService::make()->getError(), true);
  51. }else{
  52. return message(MemberService::make()->getError(), false);
  53. }
  54. }
  55. /**
  56. * 账户充值
  57. * @return array
  58. */
  59. public function recharge()
  60. {
  61. $params = request()->post();
  62. if(MemberService::make()->recharge($this->userId,$params)){
  63. return message(MemberService::make()->getError(), true);
  64. }else{
  65. return message(MemberService::make()->getError(), false);
  66. }
  67. }
  68. /**
  69. * 选项列表
  70. * @return mixed
  71. */
  72. public function options(){
  73. $result = $this->service->options();
  74. return message(1002,true, $result);
  75. }
  76. /**
  77. * 搜索用户(用于下拉选择)
  78. * @return array
  79. */
  80. public function search()
  81. {
  82. $keyword = request()->input('keyword', '');
  83. $accountType = request()->input('account_type', 1);
  84. $limit = request()->input('limit', 20);
  85. $result = $this->service->searchUsers($keyword, $accountType, $limit);
  86. return showJson($result['msg'], $result['code'] == 0, $result['data'] ?? []);
  87. }
  88. /**
  89. * 获取详情
  90. */
  91. public function read()
  92. {
  93. $result = $this->service->getInfo();
  94. return showJson($result['msg'], $result['code'] == 0, $result['data'] ?? []);
  95. }
  96. /**
  97. * 添加
  98. */
  99. public function add()
  100. {
  101. $result = $this->service->add();
  102. return showJson($result['msg'], $result['code'] == 0);
  103. }
  104. /**
  105. * 设置状态
  106. */
  107. public function status()
  108. {
  109. $result = $this->service->status();
  110. return showJson($result['msg'], $result['code'] == 0);
  111. }
  112. }