数据统计

This commit is contained in:
wong
2025-11-18 14:14:09 +08:00
parent 316cac8149
commit fb9e61aafe

View File

@@ -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,