SjController.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace console\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\ghs\classes\GhsClass;
  5. use biz\shop\classes\ShopAdminClass;
  6. use biz\shop\classes\ShopClass;
  7. use biz\sj\classes\SjClass;
  8. use bizGhs\custom\classes\CustomClass;
  9. use bizHd\saas\classes\ApplyClass;
  10. use common\components\util;
  11. use yii\console\Controller;
  12. class SjController extends Controller
  13. {
  14. // 删除账号 ssh 2021.2.27
  15. // ./yii sj/del 17061583291 15280215347
  16. // ./yii.bat sj/del 17061583291 15280215347
  17. public function actionDel()
  18. {
  19. if (getenv('YII_ENV') == 'production') {
  20. echo "线上不允许操作";
  21. util::stop();
  22. }
  23. global $argv;
  24. foreach ($argv as $key => $item) {
  25. if ($key > 1) {
  26. $mobile = $item;
  27. $shopList = ShopClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
  28. if (!empty($shopList)) {
  29. foreach ($shopList as $shop) {
  30. $merchantName = $shop->merchantName ?? '';
  31. if (!empty($merchantName)) {
  32. SjClass::deleteByCondition(['name' => $merchantName]);
  33. }
  34. $sjId = $shop->sjId ?? 0;
  35. $shop->delete();
  36. if (!empty($sjId)) {
  37. $ghsList = GhsClass::getAllByCondition(['ownSjId' => $sjId], null, '*', null, true);
  38. if (!empty($ghsList)) {
  39. foreach ($ghsList as $ghs) {
  40. $customId = $ghs->customId;
  41. $ghs->delete();
  42. $current = CustomClass::getById($customId, true);
  43. if (!empty($current)) {
  44. $current->delete();
  45. }
  46. }
  47. }
  48. $customList = CustomClass::getAllByCondition(['ownSjId' => $sjId], null, '*', null, true);
  49. if (!empty($customList)) {
  50. foreach ($customList as $custom) {
  51. $ghsId = $custom->ghsId;
  52. $custom->delete();
  53. $current = GhsClass::getById($ghsId, true);
  54. if (!empty($current)) {
  55. $current->delete();
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. ApplyClass::deleteByCondition(['mobile' => $mobile]);
  63. $adminList = AdminClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
  64. if (!empty($adminList)) {
  65. foreach ($adminList as $admin) {
  66. $adminId = $admin->id ?? 0;
  67. ShopAdminClass::deleteByCondition(['adminId' => $adminId]);
  68. $admin->delete();
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }