From 419c578b2cfabaa07be1f951d3232a97c4bf1aa9 Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 14 Oct 2026 14:59:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E4=BD=A3=E8=AE=A2=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/common/service/PromotionService.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/application/common/service/PromotionService.php b/backend/application/common/service/PromotionService.php index e1e429b..f313ee4 100644 --- a/backend/application/common/service/PromotionService.php +++ b/backend/application/common/service/PromotionService.php @@ -270,16 +270,21 @@ class PromotionService */ public static function getOverview(int $userId): array { - $base = self::where('promoter_id', $userId)->where('order_status', 'in', self::VISIBLE_ORDER_STATUS); - $settledAmount = (clone $base)->where('commission_status', self::COMMISSION_STATUS_SETTLED)->sum('commission_amount'); - $pendingCount = (clone $base)->where('commission_status', self::COMMISSION_STATUS_PENDING)->count(); + //TP5.0 克隆查询对象会共用参数绑定导致 HY093,每次都新建查询 + $base = [ + 'promoter_id' => $userId, + 'order_status' => ['in', self::VISIBLE_ORDER_STATUS], + ]; + $settledAmount = self::where($base)->where('commission_status', self::COMMISSION_STATUS_SETTLED)->sum('commission_amount'); + $pendingCount = self::where($base)->where('commission_status', self::COMMISSION_STATUS_PENDING)->count(); + $orderCount = self::where($base)->count(); return [ 'enabled' => self::isEnabled(), 'soft_ratio_percent' => floatval(bcmul(self::getRatio(OrderService::ORDER_TYPE_SOFTWARE), '100', 2)), 'demand_ratio_percent' => floatval(bcmul(self::getRatio(OrderService::ORDER_TYPE_FIRST_PAYMENT), '100', 2)), 'invite_count' => User::where('promoter_id', $userId)->count(), - 'order_count' => (clone $base)->count(), + 'order_count' => $orderCount, 'settled_amount' => bcadd((string)$settledAmount, '0', 2), 'pending_count' => $pendingCount, ];