From fb9e61aafe7de97dd34ecb6afb988f71ac369bed Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Tue, 18 Nov 2025 14:14:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cunkebao/controller/StatsController.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Server/application/cunkebao/controller/StatsController.php b/Server/application/cunkebao/controller/StatsController.php index a6abd115..3855da66 100644 --- a/Server/application/cunkebao/controller/StatsController.php +++ b/Server/application/cunkebao/controller/StatsController.php @@ -404,19 +404,26 @@ class StatsController extends Controller $isAdmin = $this->request->userInfo['isAdmin']; - $device = Db::name('device')->where(['companyId' => $companyId,'deleteTime' => 0]); - $wechat = Db::name('wechat_customer')->where(['companyId' => $companyId]); - $contentLibrary = Db::name('content_library')->where(['companyId' => $companyId,'isDel' => 0]); - $user = Db::name('wechat_friendship')->where(['companyId' => $companyId,'deleteTime' => 0]); + $where = [ + ['departmentId','=',$companyId] + ]; + if (!empty($this->request->userInfo['isAdmin'])){ + $where[] = ['id','=',$this->request->userInfo['s2_accountId']]; + } + $accounts = Db::table('s2_company_account')->where($where)->column('id'); + + $userNum = Db::table('s2_wechat_friend')->whereIn('accountId',$accounts)->where(['isDeleted' => 0])->count(); + $deviceNum = Db::table('s2_device')->whereIn('currentAccountId',$accounts)->where(['isDeleted' => 0])->count(); + $wechatNum = Db::table('s2_wechat_account')->whereIn('deviceAccountId',$accounts)->count(); + + + $contentLibrary = Db::name('content_library')->where(['companyId' => $companyId,'isDel' => 0]); if(empty($isAdmin)){ $contentLibrary = $contentLibrary->where(['userId' => $userId]); } - - $deviceNum = $device->count(); - $wechatNum = $wechat->count(); $contentLibraryNum = $contentLibrary->count(); - $userNum = $user->count(); + $data = [ 'deviceNum' => $deviceNum,