Ver código fonte

删除账号

shish 4 anos atrás
pai
commit
66822af4b6
1 arquivos alterados com 46 adições e 0 exclusões
  1. 46 0
      console/controllers/SjController.php

+ 46 - 0
console/controllers/SjController.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace console\controllers;
+
+use biz\admin\classes\AdminClass;
+use biz\shop\classes\ShopClass;
+use biz\sj\classes\SjClass;
+use bizHd\saas\classes\ApplyClass;
+use bizHd\saas\classes\StaffClass;
+use common\components\util;
+use yii\console\Controller;
+
+class SjController extends Controller
+{
+
+    // 删除账号 ssh 2021.2.27
+    // ./yii sj/del 17061583291 15280215347
+    // ./yii.bat sj/del 17061583291 15280215347
+    public function actionDel()
+    {
+        if (getenv('YII_ENV') == 'production') {
+            echo "线上不允许操作";
+            util::stop();
+        }
+        global $argv;
+        foreach ($argv as $key => $item) {
+            if ($key > 1) {
+                $mobile = $item;
+                $shop = ShopClass::getByCondition(['mobile' => $mobile], true);
+                if (!empty($shop)) {
+                    $merchantName = $shop->merchantName ?? '';
+                    if (!empty($merchantName)) {
+                        SjClass::deleteByCondition(['name' => $merchantName]);
+                    }
+                    $shop->delete();
+                }
+                ApplyClass::deleteByCondition(['mobile' => $mobile]);
+                $admin = AdminClass::getByCondition(['mobile' => $mobile], true);
+                $adminId = $admin->id ?? 0;
+                StaffClass::deleteByCondition(['adminId' => $adminId]);
+                $admin->delete();
+            }
+        }
+    }
+
+}