瀏覽代碼

快应用用户删除

wangzq 2 年之前
父節點
當前提交
dfd025c38d
共有 2 個文件被更改,包括 67 次插入0 次删除
  1. 66 0
      app/Console/Commands/delQappUser.php
  2. 1 0
      app/Console/Kernel.php

+ 66 - 0
app/Console/Commands/delQappUser.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Modules\User\Models\QappPackage;
+use App\Modules\User\Models\QappUser;
+use App\Modules\User\Models\User;
+use Illuminate\Console\Command;
+
+class delQappUser extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'qappUser:del';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Command description';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $this->info('用户删除开始');
+        try {
+            $uid = $this->ask('请输入你想要删除的用户uid?');
+            $user = QappUser::getUserByUid($uid);
+            if ($user) {
+                $channel = QappPackage::where(['channel_id' => $user['channel_id']])->value("name");
+                if ($this->confirm("确定要删除" . $channel . "的uid为{$uid}的用户吗? [y|N]")) {
+                    $this->info("用户删除中........");
+                    QappUser::where(['uid' => $user['uid']])->update(['device_no' =>  $user['androidid'].$user['uid']]);
+                    User::where(['id' =>  $user['uid']])->update(['openid' =>  $user['androidid'].$user['uid']]);
+                } else {
+                    $this->info("取消删除");
+                }
+            } else {
+                $this->info("UID为{$uid}的用户不存在");
+            }
+            $this->info("操作完成");
+        } catch (\Exception $exception) {
+            $this->error("uid 为{$uid}的用户删除你是失败");
+        }
+
+
+    }
+}

+ 1 - 0
app/Console/Kernel.php

@@ -40,6 +40,7 @@ class Kernel extends ConsoleKernel
         Commands\NewVersionPrepare::class,
         Commands\FixPushUserChannel::class,
         Commands\Test::class,
+        Commands\delQappUser::class,
     ];
 
     /**