diff --git a/app/event/GoogleAdsCustomers.php b/app/event/GoogleAdsCustomers.php index a788e21..305f355 100644 --- a/app/event/GoogleAdsCustomers.php +++ b/app/event/GoogleAdsCustomers.php @@ -69,7 +69,7 @@ class GoogleAdsCustomers // $customerId = $account['customer_id']; // dump($customerId, $thirdUser->id, $rootAccountId, $account); // if($account['customer_id'] == 1509096882)continue; - $this->googleOAuthService->saveThirdUserAdvertiser($account['customer_id'], $thirdUser->id, $rootAccountId, $account,$thirdUser->merchant_id); + $this->googleOAuthService->saveThirdUserAdvertiser($account['customer_id'], $thirdUser->id, $rootAccountId, $account, $thirdUser->merchant_id); } } $this->googleOAuthService->updateThirdUserDefault($thirdUser->id, 't'); @@ -90,6 +90,9 @@ class GoogleAdsCustomers $option = []; $option['refresh_token'] = $thirdUser->access_token; $listAccessibleCustomers = $this->googleAdsAccountService->runListAccessibleCustomers($option); + + // Add a counter to limit the number of executions + $executionCount = 0; foreach ($listAccessibleCustomers as $rootAccountId) { $option['manager_customer_id'] = $rootAccountId; //开发者 $option['login_customer_id'] = $rootAccountId; @@ -99,6 +102,12 @@ class GoogleAdsCustomers // dump($allAccountsByRoot,333); foreach ($allAccountsByRoot as $rootId => $accounts) { foreach ($accounts as $account) { + // Ensure we only execute 10 times + if ($executionCount >= 10) { + dump('Executed 10 times, stopping further calls.'); + break 3; // Break out of both inner and outer loops + } +// dump($account); $this->googleOAuthService->saveThirdUserAdvertiser( $account['customer_id'], $thirdUser->id, @@ -106,6 +115,8 @@ class GoogleAdsCustomers $account, $thirdUser->merchant_id ); + // Increment the counter + $executionCount++; } } // 绑定的授权主体全部账号更新后将状态从 'f' 更新为 't'