shish 4 лет назад
Родитель
Сommit
03eeca9be0
1 измененных файлов с 15 добавлено и 11 удалено
  1. 15 11
      console/controllers/SjController.php

+ 15 - 11
console/controllers/SjController.php

@@ -26,20 +26,24 @@ class SjController extends Controller
         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]);
+                $shopList = ShopClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
+                if (!empty($shopList)) {
+                    foreach ($shopList as $shop) {
+                        $merchantName = $shop->merchantName ?? '';
+                        if (!empty($merchantName)) {
+                            SjClass::deleteByCondition(['name' => $merchantName]);
+                        }
+                        $shop->delete();
                     }
-                    $shop->delete();
                 }
                 ApplyClass::deleteByCondition(['mobile' => $mobile]);
-                $admin = AdminClass::getByCondition(['mobile' => $mobile], true);
-                if (!empty($admin)) {
-                    $adminId = $admin->id ?? 0;
-                    ShopAdminClass::deleteByCondition(['adminId' => $adminId]);
-                    $admin->delete();
+                $adminList = AdminClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
+                if (!empty($adminList)) {
+                    foreach ($adminList as $admin) {
+                        $adminId = $admin->id ?? 0;
+                        ShopAdminClass::deleteByCondition(['adminId' => $adminId]);
+                        $admin->delete();
+                    }
                 }
             }
         }