delQappUser.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Modules\User\Models\QappPackage;
  4. use App\Modules\User\Models\QappUser;
  5. use App\Modules\User\Models\User;
  6. use Illuminate\Console\Command;
  7. class delQappUser extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'qappUser:del';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Command description';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. $this->info('用户删除开始');
  38. try {
  39. $uid = $this->ask('请输入你想要删除的用户uid?');
  40. $user = QappUser::getUserByUid($uid);
  41. if ($user) {
  42. $channel = QappPackage::where(['channel_id' => $user['channel_id']])->value("name");
  43. if ($this->confirm("确定要删除" . $channel . "的uid为{$uid}的用户吗? [y|N]")) {
  44. $this->info("用户删除中........");
  45. QappUser::where(['uid' => $user['uid']])->update(['device_no' => $user['androidid'].$user['uid'] ]);
  46. User::where(['id' => $user['uid']])->update(['openid' => $user['androidid'].$user['uid'],'unionid' => $user['androidid'].$user['uid']]);
  47. } else {
  48. $this->info("取消删除");
  49. }
  50. } else {
  51. $this->info("UID为{$uid}的用户不存在");
  52. }
  53. $this->info("操作完成");
  54. } catch (\Exception $exception) {
  55. $this->error("uid 为{$uid}的用户删除你是失败");
  56. }
  57. }
  58. }