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, ];