From e59e187af6316da1b02438103667bc1d65eb5f6a Mon Sep 17 00:00:00 2001 From: huangguancheng Date: Sat, 15 Feb 2025 18:36:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E4=B8=AA=E5=B9=BF=E5=91=8A=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=9B=B4=E6=8D=A2=E8=B4=A6=E5=8F=B7=E8=A1=A8=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/BpsAdController.php | 1 + app/service/AdsInsightService.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) 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)'); // 只查询总记录数