User.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\outapi\controller;
  12. use think\facade\App;
  13. use app\services\user\OutUserServices;
  14. /**
  15. * 用户控制器
  16. * Class User
  17. * @package app\outapi\controller
  18. */
  19. class User extends AuthController
  20. {
  21. /**
  22. * User constructor.
  23. * @param App $app
  24. * @param OutUserServices $service
  25. * @method temp
  26. */
  27. public function __construct(App $app, OutUserServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 用户列表
  34. * @return mixed
  35. */
  36. public function lst()
  37. {
  38. $where = $this->request->getMore([
  39. ['nickname', ''],
  40. ['status', ''],
  41. ['field_key', ''],
  42. ]);
  43. return app('json')->success($this->services->getUserList($where));
  44. }
  45. /**
  46. * 保存新建的资源
  47. *
  48. * @param \think\Request $request
  49. * @return \think\Response
  50. */
  51. public function save()
  52. {
  53. $data = $this->request->postMore([
  54. ['real_name', ''],
  55. ['phone', 0],
  56. ['mark', ''],
  57. ['pwd', ''],
  58. ['level', 0],
  59. ['spread_open', 0],
  60. ['is_promoter', 0],
  61. ['status', 1]
  62. ]);
  63. $uid = $this->services->saveUser(0, $data);
  64. if (!$uid) {
  65. return app('json')->fail(100022);
  66. }
  67. return app('json')->success(100021, ['uid' => $uid]);
  68. }
  69. /**
  70. * 更新用户
  71. * @param $uid
  72. * @return mixed
  73. */
  74. public function update($uid)
  75. {
  76. $data = $this->request->postMore([
  77. ['real_name', ''],
  78. ['phone', 0],
  79. ['mark', ''],
  80. ['pwd', ''],
  81. ['level', 0],
  82. ['spread_open', 1],
  83. ['is_promoter', 0],
  84. ['status', 1]
  85. ]);
  86. if (!$uid) return app('json')->fail(100100);
  87. $this->services->saveUser((int)$uid, $data);
  88. return app('json')->success(100001);
  89. }
  90. /**
  91. * 赠送相关
  92. * @param int $uid
  93. * @return mixed
  94. */
  95. public function give($uid)
  96. {
  97. $data = $this->request->postMore([
  98. ['money_status', 0],
  99. ['money', 0],
  100. ['integration_status', 0],
  101. ['integration', 0],
  102. ['days', 0],
  103. ['coupon', 0]
  104. ]);
  105. if (!$uid) return app('json')->fail(100100);
  106. if (!$this->services->otherGive((int)$uid, $data)) {
  107. return app('json')->fail(100005);
  108. }
  109. return app('json')->success(100010);
  110. }
  111. }