SjController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace console\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\shop\classes\ShopClass;
  5. use biz\sj\classes\SjClass;
  6. use bizHd\saas\classes\ApplyClass;
  7. use bizHd\saas\classes\StaffClass;
  8. use common\components\util;
  9. use yii\console\Controller;
  10. class SjController extends Controller
  11. {
  12. // 删除账号 ssh 2021.2.27
  13. // ./yii sj/del 17061583291 15280215347
  14. // ./yii.bat sj/del 17061583291 15280215347
  15. public function actionDel()
  16. {
  17. if (getenv('YII_ENV') == 'production') {
  18. echo "线上不允许操作";
  19. util::stop();
  20. }
  21. global $argv;
  22. foreach ($argv as $key => $item) {
  23. if ($key > 1) {
  24. $mobile = $item;
  25. $shop = ShopClass::getByCondition(['mobile' => $mobile], true);
  26. if (!empty($shop)) {
  27. $merchantName = $shop->merchantName ?? '';
  28. if (!empty($merchantName)) {
  29. SjClass::deleteByCondition(['name' => $merchantName]);
  30. }
  31. $shop->delete();
  32. }
  33. ApplyClass::deleteByCondition(['mobile' => $mobile]);
  34. $admin = AdminClass::getByCondition(['mobile' => $mobile], true);
  35. if (!empty($admin)) {
  36. $adminId = $admin->id ?? 0;
  37. StaffClass::deleteByCondition(['adminId' => $adminId]);
  38. $admin->delete();
  39. }
  40. }
  41. }
  42. }
  43. }