diff --git a/app/controller/BpsAdController.php b/app/controller/BpsAdController.php index 37c4e50..83ab437 100644 --- a/app/controller/BpsAdController.php +++ b/app/controller/BpsAdController.php @@ -127,6 +127,7 @@ class BpsAdController // 调用 Service 层查询广告列表 $result = $this->adsInsightService::getAccountList( $platformType, // 平台类型 + $options['jwtClaims']['merchant_id'], // 店铺 $accountIds, // 客户 ID 数组 $page, // 页码 $pageSize, // 每页数量 diff --git a/app/service/AdsInsightService.php b/app/service/AdsInsightService.php index 1a1a333..b702277 100644 --- a/app/service/AdsInsightService.php +++ b/app/service/AdsInsightService.php @@ -1163,7 +1163,7 @@ class AdsInsightService } } - public static function getAccountList($platformType, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null, $requireSpend = false, $countOnly = false) + public static function getAccountList($platformType, $merchantId, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null, $requireSpend = false, $countOnly = false) { // 检查 customerIds 是否为空,直接返回计数为 0 if (empty($customerIds)) { @@ -1186,8 +1186,10 @@ class AdsInsightService // ->where('a.advertiser_id', 'in', $customerIds); $query = BpsAdsMerchantRelation::alias('bamr') ->cache(false) + ->where('bamr.merchant_id', '=', $merchantId) ->where('bamr.account_id', 'in', $customerIds); + // 仅计数时优化查询 if ($countOnly) { return $query->count('distinct(bamr.account_id)'); // 只查询总记录数