From 505eff067a384f61fcd68c31728faaa686b863f4 Mon Sep 17 00:00:00 2001 From: huangguancheng Date: Mon, 10 Feb 2025 17:44:55 +0800 Subject: [PATCH] =?UTF-8?q?google=20ads=20account=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8E=E9=BB=98=E8=AE=A4=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=8F=AA=E8=83=BD10=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/event/GoogleAdsCustomers.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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'