瀏覽代碼

更新数据

shish 6 月之前
父節點
當前提交
9d0741ec66
共有 1 個文件被更改,包括 9 次插入7 次删除
  1. 9 7
      console/controllers/TestController.php

+ 9 - 7
console/controllers/TestController.php

@@ -54,11 +54,6 @@ class TestController extends Controller
                 $respond = MobileSnClass::add(['id' => null], true);
                 $newMobile = $respond->id;
 
-                $admin = AdminClass::getByCondition(['mobile' => $mobile], true);
-                if (!empty($admin)) {
-                    $admin->mobile = $newMobile;
-                    $admin->save();
-                }
                 $staffList = StaffClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
                 if (!empty($staffList)) {
                     foreach ($staffList as $staff) {
@@ -114,9 +109,16 @@ class TestController extends Controller
                         $user->save();
                     }
                 }
+                $adminList = AdminClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
+                if (!empty($adminList)) {
+                    foreach ($adminList as $admin) {
+                        $admin->mobile = $newMobile;
+                        $admin->save();
+                    }
+                }
+
                 $transaction->commit();
-                echo $mobile . ' ' . $newMobile;
-                die;
+                echo $mobile . ' ' . $newMobile . "\n";
             } catch (\Exception $e) {
                 $transaction->rollBack();
                 $msg = $e->getMessage();