From 1fa3ddbd09da22b163cf849980eea86b331d5387 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Sat, 18 Nov 2023 14:40:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=8C=81=E6=9C=89?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E7=BB=9F=E8=AE=A1=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/user/IntegralRepository.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/common/repositories/user/IntegralRepository.php b/app/common/repositories/user/IntegralRepository.php index affe148..9cc76af 100644 --- a/app/common/repositories/user/IntegralRepository.php +++ b/app/common/repositories/user/IntegralRepository.php @@ -167,13 +167,10 @@ class IntegralRepository extends BaseRepository * @return array|array[] */ public function getStat(array $params){ - $query = $this->dao->getSearch([]) - ->when((int)$params['uid'] > 0,function($query) use ($params){ - $query->where('uid', (int)$params['uid']); - }) - ->when((int)$params['mer_id'] > 0,function($query) use ($params){ - $query->where('mer_id', (int)$params['mer_id']); - }); + $where = []; + if((int)$params['uid'] > 0) $where['uid'] = (int)$params['uid']; + if((int)$params['mer_id'] > 0) $where['mer_id'] = (int)$params['mer_id']; + $orderQuery = app()->make(StoreOrder::class) ->when((int)$params['uid'] > 0,function($query) use ($params){ $query->where('uid', (int)$params['uid']); @@ -183,7 +180,7 @@ class IntegralRepository extends BaseRepository }); // 商户信息统计 - $holdMerIntegral = (float)$query->where('mer_id','>',0)->sum('number'); + $holdMerIntegral = (float)$this->dao->getSearch([])->where($where)->where('mer_id','>',0)->sum('number'); $useMerIntegral = (float)$orderQuery->sum('use_mer_integral'); if((int)$params['mer_id'] > 0){ return [ @@ -192,7 +189,7 @@ class IntegralRepository extends BaseRepository ]; } // 平台信息统计 - $holdPlatformIntegral = (float)$query->where('mer_id','=',0)->sum('number'); + $holdPlatformIntegral = (float)$this->dao->getSearch([])->where($where)->where('mer_id','=',0)->sum('number'); $usePlatformIntegral = (float)$orderQuery->sum('use_platform_integral'); return [