google ads account账号添加后默认控制绑定只能10个

This commit is contained in:
huangguancheng 2025-02-10 17:44:55 +08:00
parent 13107526fe
commit 505eff067a

View File

@ -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'