User.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\user;
  12. use app\jobs\BatchHandleJob;
  13. use app\services\other\queue\QueueServices;
  14. use app\services\product\product\StoreProductLogServices;
  15. use app\services\user\group\UserGroupServices;
  16. use app\services\user\label\UserLabelServices;
  17. use app\services\user\level\UserLevelServices;
  18. use app\services\user\UserBatchProcessServices;
  19. use app\services\user\UserServices;
  20. use app\controller\admin\AuthController;
  21. use app\services\user\UserSpreadServices;
  22. use app\services\user\UserWechatuserServices;
  23. use think\exception\ValidateException;
  24. use think\facade\App;
  25. class User extends AuthController
  26. {
  27. /**
  28. * user constructor.
  29. * @param App $app
  30. * @param UserServices $services
  31. */
  32. public function __construct(App $app, UserServices $services)
  33. {
  34. parent::__construct($app);
  35. $this->services = $services;
  36. }
  37. /**
  38. * 显示资源列表头部
  39. *
  40. * @return \think\Response
  41. */
  42. public function type_header()
  43. {
  44. $list = $this->services->typeHead();
  45. return $this->success(compact('list'));
  46. }
  47. /**
  48. * 显示资源列表
  49. *
  50. * @return \think\Response
  51. */
  52. public function index()
  53. {
  54. $where = $this->request->getMore([
  55. ['page', 1],
  56. ['limit', 20],
  57. ['nickname', ''],
  58. ['status', ''],
  59. ['pay_count', ''],
  60. ['is_promoter', ''],
  61. ['order', ''],
  62. ['data', ''],
  63. ['user_type', ''],
  64. ['country', ''],
  65. ['province', ''],
  66. ['city', ''],
  67. ['user_time_type', ''],
  68. ['user_time', ''],
  69. ['sex', ''],
  70. [['level', 0], 0],
  71. [['group_id', 'd'], 0],
  72. [['label_id', 'd'], 0],
  73. ['now_money', 'normal'],
  74. ['field_key', ''],
  75. ['isMember', ''],
  76. ['label_ids', '']
  77. ]);
  78. if ($where['label_ids']) {
  79. $where['label_id'] = explode(',', $where['label_ids']);
  80. unset($where['label_ids']);
  81. }
  82. $where['user_time_type'] = $where['user_time_type'] == 'all' ? '' : $where['user_time_type'];
  83. return $this->success($this->services->index($where));
  84. }
  85. /**
  86. * 补充信息表单
  87. * @param $id
  88. * @return mixed
  89. * @throws \FormBuilder\Exception\FormBuilderException
  90. */
  91. public function extendInfoForm($id)
  92. {
  93. return $this->success($this->services->extendInfoForm((int)$id));
  94. }
  95. /**
  96. * 保存用户补充信息
  97. * @param $id
  98. * @return mixed
  99. */
  100. public function saveExtendForm($id)
  101. {
  102. $data = $this->request->post();
  103. if (!$data) {
  104. return $this->fail('请提交要保存信息');
  105. }
  106. $this->services->saveExtendForm((int)$id, $data);
  107. return $this->success('保存成功');
  108. }
  109. /**
  110. * 显示创建资源表单页.
  111. *
  112. * @return \think\Response
  113. */
  114. public function create()
  115. {
  116. return $this->success($this->services->saveForm());
  117. }
  118. /**
  119. * 保存新建的资源
  120. *
  121. * @param \think\Request $request
  122. * @return \think\Response
  123. */
  124. public function save()
  125. {
  126. $data = $this->request->postMore([
  127. ['is_promoter', 0],
  128. ['real_name', ''],
  129. ['card_id', ''],
  130. ['birthday', ''],
  131. ['mark', ''],
  132. ['status', 0],
  133. ['level', 0],
  134. ['phone', 0],
  135. ['addres', ''],
  136. ['label_id', []],
  137. ['group_id', 0],
  138. ['pwd', ''],
  139. ['true_pwd', ''],
  140. ['spread_open', 1],
  141. ['sex', 0],
  142. ['provincials', ''],
  143. ['province', 0],
  144. ['city', 0],
  145. ['area', 0],
  146. ['street', 0],
  147. ['extend_info', []],
  148. ]);
  149. $this->validate(['pwd' => $data['pwd']], \app\validate\admin\user\UserValidate::class);
  150. if ($data['phone']) {
  151. if (!check_phone($data['phone'])) {
  152. return $this->fail('手机号码格式不正确');
  153. }
  154. if ($this->services->count(['phone' => $data['phone']])) {
  155. return $this->fail('手机号已经存在不能添加相同的手机号用户');
  156. }
  157. $data['nickname'] = substr_replace($data['phone'], '****', 3, 4);
  158. }
  159. if ($data['card_id']) {
  160. try {
  161. if (!check_card($data['card_id'])) return $this->fail('请输入正确的身份证');
  162. } catch (\Throwable $e) {
  163. // return $this->fail('请输入正确的身份证');
  164. }
  165. }
  166. if ($data['birthday']) {
  167. if (strtotime($data['birthday']) > time()) return $this->fail('生日请选择今天之前日期');
  168. }
  169. if ($data['pwd']) {
  170. if (!$data['true_pwd']) {
  171. return $this->fail('请输入确认密码');
  172. }
  173. if ($data['pwd'] != $data['true_pwd']) {
  174. return $this->fail('两次输入的密码不一致');
  175. }
  176. if ($data['pwd'] == '123456') {
  177. return $this->fail('您设置的密码太过简单');
  178. }
  179. $data['pwd'] = md5($data['pwd']);
  180. } else {
  181. unset($data['pwd']);
  182. }
  183. unset($data['true_pwd']);
  184. $data['avatar'] = sys_config('h5_avatar');
  185. $data['adminId'] = $this->adminId;
  186. $data['user_type'] = 'h5';
  187. $labels = $data['label_id'];
  188. unset($data['label_id']);
  189. foreach ($labels as $k => $v) {
  190. if (!$v) {
  191. unset($labels[$k]);
  192. }
  193. }
  194. $data['birthday'] = empty($data['birthday']) ? 0 : strtotime($data['birthday']);
  195. $data['add_time'] = time();
  196. $data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
  197. $this->services->transaction(function () use ($data, $labels) {
  198. $res = true;
  199. $userInfo = $this->services->save($data);
  200. $res = $this->services->saveSetLabel([$userInfo->uid], $labels);
  201. if ($data['level']) {
  202. $res = $this->services->saveGiveLevel((int)$userInfo->uid, (int)$data['level']);
  203. }
  204. if (!$res) {
  205. throw new ValidateException('保存添加用户失败');
  206. }
  207. event('user.register', [$this->services->get((int)$userInfo->uid), true, 0]);
  208. });
  209. event('user.create', $data);
  210. return $this->success('添加成功');
  211. }
  212. /**
  213. * 显示指定的资源
  214. *
  215. * @param int $id
  216. * @return \think\Response
  217. */
  218. public function read($id)
  219. {
  220. if (is_string($id)) {
  221. $id = (int)$id;
  222. }
  223. return $this->success($this->services->read($id));
  224. }
  225. /**
  226. * 赠送会员等级
  227. * @param int $uid
  228. * @return mixed
  229. * */
  230. public function give_level($id)
  231. {
  232. if (!$id) return $this->fail('缺少参数');
  233. return $this->success($this->services->giveLevel((int)$id));
  234. }
  235. /**
  236. * 执行赠送会员等级
  237. * @param int $uid
  238. * @return mixed
  239. * */
  240. public function save_give_level($id)
  241. {
  242. if (!$id) return $this->fail('缺少参数');
  243. [$level_id] = $this->request->postMore([
  244. ['level_id', 0],
  245. ], true);
  246. return $this->success($this->services->saveGiveLevel((int)$id, (int)$level_id) ? '赠送成功' : '赠送失败');
  247. }
  248. /**
  249. * 赠送付费会员时长
  250. * @param int $uid
  251. * @return mixed
  252. * */
  253. public function give_level_time($id)
  254. {
  255. if (!$id) return $this->fail('缺少参数');
  256. return $this->success($this->services->giveLevelTime((int)$id));
  257. }
  258. /**
  259. * 执行赠送付费会员时长
  260. * @param int $uid
  261. * @return mixed
  262. * */
  263. public function save_give_level_time($id)
  264. {
  265. if (!$id) return $this->fail('缺少参数');
  266. [$days_status, $days] = $this->request->postMore([
  267. ['days_status', 1],
  268. ['days', 0],
  269. ], true);
  270. return $this->success($this->services->saveGiveLevelTime((int)$id, (int)$days, (int)$days_status) ? '赠送成功' : '赠送失败');
  271. }
  272. /**
  273. * 清除会员等级
  274. * @param int $uid
  275. * @return json
  276. */
  277. public function del_level($id)
  278. {
  279. if (!$id) return $this->fail('缺少参数');
  280. return $this->success($this->services->cleanUpLevel((int)$id) ? '清除成功' : '清除失败');
  281. }
  282. /**
  283. * 设置会员分组
  284. * @param $id
  285. * @return mixed
  286. * @throws \FormBuilder\Exception\FormBuilderException
  287. * @throws \think\db\exception\DataNotFoundException
  288. * @throws \think\db\exception\DbException
  289. * @throws \think\db\exception\ModelNotFoundException
  290. */
  291. public function set_group()
  292. {
  293. [$uids, $all, $where] = $this->request->postMore([
  294. ['uids', []],
  295. ['all', 0],
  296. ['where', []],
  297. ], true);
  298. return $this->success($this->services->setGroup($uids, $all, $where));
  299. }
  300. /**
  301. * 保存会员分组
  302. * @param $id
  303. * @return mixed
  304. */
  305. public function save_set_group()
  306. {
  307. [$group_id, $uids, $all, $where] = $this->request->postMore([
  308. ['group_id', 0],
  309. ['uids', ''],
  310. ['all', 0],
  311. ['where', ""],
  312. ], true);
  313. if (!$uids && $all == 0) return $this->fail('缺少参数');
  314. if (!$group_id) return $this->fail('请选择分组');
  315. $type = 2;//代表设置用户标签
  316. if ($all == 0) {
  317. $uids = explode(',', $uids);
  318. $where = [];
  319. }
  320. if ($all == 1) {
  321. $where = $where ? json_decode($where, true) : [];
  322. /** @var UserWechatuserServices $userWechatUser */
  323. $userWechatUser = app()->make(UserWechatuserServices::class);
  324. $fields = 'u.uid';
  325. [$list, $count] = $userWechatUser->getWhereUserList($where, $fields);
  326. $uids = array_unique(array_column($list, 'uid'));
  327. $where = [];
  328. }
  329. /** @var UserGroupServices $userGroup */
  330. $userGroup = app()->make(UserGroupServices::class);
  331. if (!$userGroup->getGroup($group_id)) {
  332. return $this->fail('该分组不存在');
  333. }
  334. /** @var QueueServices $queueService */
  335. $queueService = app()->make(QueueServices::class);
  336. $queueService->setQueueData($where, 'uid', $uids, $type, $group_id);
  337. //加入队列
  338. BatchHandleJob::dispatch([$group_id, $type]);
  339. return $this->success('后台程序已执行用户分组任务!');
  340. }
  341. /**
  342. * 设置用户标签
  343. * @return mixed
  344. * @throws \FormBuilder\Exception\FormBuilderException
  345. * @throws \think\db\exception\DataNotFoundException
  346. * @throws \think\db\exception\DbException
  347. * @throws \think\db\exception\ModelNotFoundException
  348. */
  349. public function set_label()
  350. {
  351. [$uids, $all, $where] = $this->request->postMore([
  352. ['uids', []],
  353. ['all', 0],
  354. ['where', ""],
  355. ], true);
  356. return $this->success($this->services->setLabel($uids, $all, $where));
  357. }
  358. /**
  359. * 保存用户标签
  360. * @return mixed
  361. */
  362. public function save_set_label()
  363. {
  364. [$lables, $uids, $all, $where] = $this->request->postMore([
  365. ['label_id', []],
  366. ['uids', ''],
  367. ['all', 0],
  368. ['where', ""],
  369. ], true);
  370. if (!$uids && $all == 0) return $this->fail('缺少参数');
  371. if (!$lables) return $this->fail('请选择标签');
  372. if ($all == 0) {
  373. $uids = is_array($uids) ? $uids : explode(',', $uids);
  374. $where = [];
  375. }
  376. if ($all == 1) {
  377. $where = $where ? (is_string($where) ? json_decode($where, true) : $where) : [];
  378. /** @var UserWechatuserServices $userWechatUser */
  379. $userWechatUser = app()->make(UserWechatuserServices::class);
  380. $fields = 'u.uid';
  381. [$list, $count] = $userWechatUser->getWhereUserList($where, $fields);
  382. $uids = array_unique(array_column($list, 'uid'));
  383. $where = [];
  384. }
  385. /** @var UserLabelServices $userLabelServices */
  386. $userLabelServices = app()->make(UserLabelServices::class);
  387. $count = $userLabelServices->getCount([['id', 'IN', $lables]]);
  388. if ($count != count($lables)) {
  389. return app('json')->fail('用户标签不存在或被删除');
  390. }
  391. $type = 3;//批量设置用户标签
  392. /** @var QueueServices $queueService */
  393. $queueService = app()->make(QueueServices::class);
  394. $queueService->setQueueData($where, 'uid', $uids, $type, $lables);
  395. //加入队列
  396. BatchHandleJob::dispatch([$lables, $type]);
  397. return $this->success('后台程序已执行批量设置用户标签任务!');
  398. }
  399. /**
  400. * 编辑其他
  401. * @param $id
  402. * @return mixed
  403. * @throws \FormBuilder\Exception\FormBuilderException
  404. */
  405. public function edit_other($id)
  406. {
  407. if (!$id) return $this->fail('数据不存在');
  408. return $this->success($this->services->editOther((int)$id));
  409. }
  410. /**
  411. * 执行编辑其他
  412. * @param int $id
  413. * @return mixed
  414. */
  415. public function update_other($id)
  416. {
  417. $data = $this->request->postMore([
  418. ['money_status', 0],
  419. ['money', 0],
  420. ['integration_status', 0],
  421. ['integration', 0],
  422. ]);
  423. if (!$id) return $this->fail('数据不存在');
  424. $data['adminId'] = $this->adminId;
  425. $data['money'] = (string)$data['money'];
  426. $data['integration'] = (string)$data['integration'];
  427. $data['is_other'] = true;
  428. return $this->success($this->services->updateInfo($id, $data) ? '修改成功' : '修改失败');
  429. }
  430. /**
  431. * 修改user表状态
  432. *
  433. * @return array
  434. */
  435. public function set_status($status, $id)
  436. {
  437. // if ($status == '' || $id == 0) return $this->fail('参数错误');
  438. // UserModel::where(['uid' => $id])->update(['status' => $status]);
  439. return $this->success($status == 0 ? '禁用成功' : '解禁成功');
  440. }
  441. /**
  442. * 编辑会员信息
  443. * @param $id
  444. * @return mixed|\think\response\Json|void
  445. */
  446. public function edit($id)
  447. {
  448. if (!$id) return $this->fail('数据不存在');
  449. return $this->success($this->services->edit($id));
  450. }
  451. public function update($id)
  452. {
  453. $data = $this->request->postMore([
  454. ['money_status', 0],
  455. ['is_promoter', -1],
  456. ['real_name', ''],
  457. ['card_id', ''],
  458. ['birthday', ''],
  459. ['mark', ''],
  460. ['money', 0],
  461. ['integration_status', 0],
  462. ['integration', 0],
  463. ['status', 0],
  464. ['award_switch', 0],
  465. ['level', 0],
  466. ['phone', 0],
  467. ['addres', ''],
  468. ['label_id', []],
  469. ['group_id', 0],
  470. ['pwd', ''],
  471. ['true_pwd'],
  472. ['spread_open', 1],
  473. ['sex', 0],
  474. ['provincials', ''],
  475. ['province', 0],
  476. ['city', 0],
  477. ['area', 0],
  478. ['street', 0],
  479. ['spread_uid', -1],
  480. ['area_admin', -1],
  481. ['is_shop', -1],
  482. ['reorder', -1],
  483. ['max_order_count', -1],
  484. ['area_admin_province', ''],
  485. ['area_admin_city', ''],
  486. ['area_admin_district', ''],
  487. ['area_provincials', ''],
  488. ['extend_info', []]
  489. ]);
  490. if ($data['phone']) {
  491. if (!check_phone($data['phone'])) return $this->fail('手机号码格式不正确');
  492. }
  493. if ($data['card_id']) {
  494. try {
  495. if (!check_card($data['card_id'])) return $this->fail('请输入正确的身份证');
  496. } catch (\Throwable $e) {
  497. // return $this->fail('请输入正确的身份证');
  498. }
  499. }
  500. if ($data['birthday']) {
  501. if (strtotime($data['birthday']) > time()) return $this->fail('生日请选择今天之前日期');
  502. }
  503. if ($data['pwd']) {
  504. if (!$data['true_pwd']) {
  505. return $this->fail('请输入确认密码');
  506. }
  507. if ($data['pwd'] != $data['true_pwd']) {
  508. return $this->fail('两次输入的密码不一致');
  509. }
  510. if ($data['pwd'] == '123456') {
  511. return $this->fail('您设置的密码太过简单');
  512. }
  513. $this->validate(['pwd' => $data['pwd']], \app\validate\admin\user\UserValidate::class);
  514. $data['pwd'] = md5($data['pwd']);
  515. } else {
  516. unset($data['pwd']);
  517. }
  518. $userInfo = $this->services->get($id);
  519. if (!$userInfo) {
  520. return $this->fail('用户不存在');
  521. }
  522. if (!in_array($data['spread_uid'], [0, -1])) {
  523. $spreadUid = $data['spread_uid'];
  524. if ($id == $spreadUid) {
  525. return $this->fail('上级推广人不能为自己');
  526. }
  527. if (!$this->services->count(['uid' => $spreadUid])) {
  528. return $this->fail('上级用户不存在');
  529. }
  530. $spreadInfo = $this->services->get($spreadUid);
  531. if ($spreadInfo->spread_uid == $id) {
  532. return $this->fail('上级推广人不能为自己下级');
  533. }
  534. }
  535. unset($data['true_pwd']);
  536. if (!$id) return $this->fail('数据不存在');
  537. $data['adminId'] = $this->adminId;
  538. $data['money'] = (string)$data['money'];
  539. $data['integration'] = (string)$data['integration'];
  540. if ($data['extend_info']) {
  541. $data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
  542. }
  543. if ($data['area_admin'] >= 0) {
  544. if (!in_array($data['area_admin'], [0, 1, 2, 3])) {
  545. return $this->fail('请选择正确的代理等级');
  546. }
  547. if ($data['area_admin'] == 3) {
  548. if (!$data['area_admin_province'])
  549. return $this->fail('请选择代理省份');
  550. else {
  551. $data['area_admin_city'] = '';
  552. $data['area_admin_district'] = '';
  553. }
  554. }
  555. if ($data['area_admin'] == 2) {
  556. if (!$data['area_admin_province'] || !$data['area_admin_city'])
  557. return $this->fail('请选择代理省市');
  558. else {
  559. $data['area_admin_district'] = '';
  560. }
  561. }
  562. if ($data['area_admin'] == 1) {
  563. if (!$data['area_admin_province'] || !$data['area_admin_city'] || !$data['area_admin_district'])
  564. return $this->fail('请选择代理省市区');
  565. }
  566. if ($data['area_admin'] == 0) {
  567. $data['area_admin_province'] = '';
  568. $data['area_admin_city'] = '';
  569. $data['area_admin_district'] = '';
  570. }
  571. }
  572. $res = $this->services->updateInfo((int)$id, $data);
  573. if ($res) {
  574. $userInfo = $this->services->get($id);
  575. /** @var UserLevelServices $levelServices */
  576. $levelServices = app()->make(UserLevelServices::class);
  577. $levelServices->detection((int)$userInfo['uid']);
  578. $pass = [$userInfo['uid']];
  579. $spread = $this->services->getUserInfo($userInfo['spread_uid']);
  580. while ($spread && !in_array($spread['uid'], $pass)) {
  581. $levelServices->detection((int)$spread['uid']);
  582. $pass[] = $spread['uid'];
  583. $spread = $this->services->getUserInfo($spread['spread_uid']);
  584. }
  585. }
  586. return $this->success($res ? '修改成功' : '修改失败');
  587. }
  588. /**
  589. * 获取单个用户信息
  590. * @param $id 用户id
  591. * @return mixed
  592. */
  593. public function oneUserInfo($id)
  594. {
  595. $data = $this->request->getMore([
  596. ['type', ''],
  597. ]);
  598. $id = (int)$id;
  599. if ($data['type'] == '') return $this->fail('缺少参数');
  600. return $this->success($this->services->oneUserInfo($id, $data['type']));
  601. }
  602. /**
  603. * 同步微信粉丝用户
  604. * @return mixed
  605. */
  606. public function syncWechatUsers()
  607. {
  608. $this->services->syncWechatUsers();
  609. return $this->success('加入消息队列成功,正在异步执行中');
  610. }
  611. /**
  612. * 商品浏览记录
  613. * @param $id
  614. * @param StoreProductLogServices $services
  615. * @return mixed
  616. * @throws \think\db\exception\DataNotFoundException
  617. * @throws \think\db\exception\DbException
  618. * @throws \think\db\exception\ModelNotFoundException
  619. */
  620. public function visitList($id, StoreProductLogServices $services)
  621. {
  622. $where['uid'] = (int)$id;
  623. $where['type'] = 'visit';
  624. return app('json')->success($services->getList($where, 'product_id'));
  625. }
  626. /**
  627. * 获取推广人记录
  628. * @param $id
  629. * @param UserSpreadServices $services
  630. * @return mixed
  631. * @throws \think\db\exception\DataNotFoundException
  632. * @throws \think\db\exception\DbException
  633. * @throws \think\db\exception\ModelNotFoundException
  634. */
  635. public function spreadList($id, UserSpreadServices $services)
  636. {
  637. $where['store_id'] = 0;
  638. $where['staff_id'] = 0;
  639. $where['uid'] = $id;
  640. return app('json')->success($services->getSpreadList($where, '*', ['spreadUser', 'admin'], false));
  641. }
  642. /**
  643. * 用户批量操作
  644. * @return mixed
  645. * @throws \think\db\exception\DataNotFoundException
  646. * @throws \think\db\exception\DbException
  647. * @throws \think\db\exception\ModelNotFoundException
  648. */
  649. public function batchProcess(UserBatchProcessServices $batchProcessServices)
  650. {
  651. [$type, $uids, $all, $where, $data] = $this->request->postMore([
  652. ['type', 1],
  653. ['uids', ''],
  654. ['all', 0],
  655. ['where', ""],
  656. ['data', []]
  657. ], true);
  658. if (!$uids && $all == 0) return $this->fail('请选择批处理用户');
  659. if (!$data) {
  660. return $this->fail('请选择批处理数据');
  661. }
  662. //批量操作
  663. $batchProcessServices->batchProcess((int)$type, $uids, $data, !!$all, (array)$where);
  664. return app('json')->success('已加入消息队列,请稍后查看');
  665. }
  666. /**
  667. * 用户注销
  668. * @return mixed
  669. */
  670. public function cancelUser()
  671. {
  672. $uid = $this->request->post('uid', 0);
  673. if (!$uid) return app('json')->fail('用户不存在');
  674. event('user.cancelUser', [$uid]);
  675. return app('json')->success('注销成功');
  676. }
  677. }