fixed listAdBadges

This commit is contained in:
huangguancheng 2025-02-17 16:28:25 +08:00
parent 88a5e048af
commit ca457d5539
2 changed files with 7 additions and 8 deletions

View File

@ -89,7 +89,7 @@ class BpsAdController
$startDateLastWeek = (int)date('Ymd', strtotime('-6 days')); $startDateLastWeek = (int)date('Ymd', strtotime('-6 days'));
// dump($startDateLastWeek, $endDateLastWeek); // dump($startDateLastWeek, $endDateLastWeek);
// if ($startDateLastWeek === $startDate && $endDateLastWeek === $endDate) { // if ($startDateLastWeek === $startDate && $endDateLastWeek === $endDate) {
$ad_data_count = $this->adsInsightService::getAdCountData($accountIds, $startDateLastWeek, $endDateLastWeek); $ad_data_count = $this->adsInsightService::getAdCountData($options['jwtClaims']['merchant_id'], $accountIds, $startDateLastWeek, $endDateLastWeek);
// } else { // } else {
// $ad_data_count = []; // $ad_data_count = [];
// } // }

View File

@ -56,7 +56,7 @@ class AdsInsightService
* @param array $customerIds 客户 ID 数组 * @param array $customerIds 客户 ID 数组
* @return array 各项 count 统计数据 * @return array 各项 count 统计数据
*/ */
public static function getAdCountData($customerIds, $startDate, $endDate) public static function getAdCountData($merchantId, $customerIds, $startDate, $endDate)
{ {
if (empty($customerIds)) { if (empty($customerIds)) {
return []; return [];
@ -70,9 +70,8 @@ class AdsInsightService
if (!empty($cachedData)) { if (!empty($cachedData)) {
return json_decode($cachedData, true); return json_decode($cachedData, true);
} }
// 没有缓存时重新计算 // 没有缓存时重新计算
$countData = self::calculateCountData($customerIds, $startDate, $endDate); $countData = self::calculateCountData($merchantId,$customerIds, $startDate, $endDate);
// 缓存到 Redis有效期 10 分钟 // 缓存到 Redis有效期 10 分钟
Redis::setex($redisKey, 600, json_encode($countData)); Redis::setex($redisKey, 600, json_encode($countData));
@ -84,13 +83,13 @@ class AdsInsightService
/** /**
* 计算广告数据的 count * 计算广告数据的 count
*/ */
protected static function calculateCountData(array $customerIds, $startDate, $endDate) protected static function calculateCountData($merchantId, $customerIds, $startDate, $endDate)
{ {
if (!$startDate || !$endDate) { if (!$startDate || !$endDate) {
[$startDate, $endDate] = self::getLastWeekDateRange(); [$startDate, $endDate] = self::getLastWeekDateRange();
} }
return [ return [
'account_list_count' => self::getAccountListCount($customerIds, $startDate, $endDate), 'account_list_count' => self::getAccountListCount($merchantId,$customerIds, $startDate, $endDate),
'campaign_list_count' => self::getCampaignListCount($customerIds, $startDate, $endDate), 'campaign_list_count' => self::getCampaignListCount($customerIds, $startDate, $endDate),
'adset_list_count' => self::getAdsetListCount($customerIds, $startDate, $endDate), 'adset_list_count' => self::getAdsetListCount($customerIds, $startDate, $endDate),
'ad_list_count' => self::getAdListCount($customerIds, $startDate, $endDate), 'ad_list_count' => self::getAdListCount($customerIds, $startDate, $endDate),
@ -134,9 +133,9 @@ class AdsInsightService
/** /**
* 获取账户列表的 count * 获取账户列表的 count
*/ */
protected static function getAccountListCount(array $customerIds, $startDate, $endDate) protected static function getAccountListCount($merchantId,$customerIds, $startDate, $endDate)
{ {
return self::getAccountList(0, $customerIds, 1, 1, '', $startDate, $endDate, false, true); return self::getAccountList(0, $merchantId,$customerIds, 1, 1, '', $startDate, $endDate, false, true);
} }
/** /**