Files
douba_shop/app/dao/work/WorkGroupChatMemberDao.php
Karlcarlo c9a98f342c chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材
添加系统版本配置文件(.version)和常量定义文件(.constant)
更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件
添加验证码配置文件(captcha.php)和.gitignore规则
2026-03-06 20:14:23 +08:00

142 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\dao\work;
use app\dao\BaseDao;
use app\model\work\WorkGroupChatMember;
use crmeb\traits\SearchDaoTrait;
/**
* 企业微信群成员
* Class WorkGroupChatMemberDao
* @package app\dao\work
*/
class WorkGroupChatMemberDao extends BaseDao
{
use SearchDaoTrait;
/**
* @return string
*/
protected function setModel(): string
{
return WorkGroupChatMember::class;
}
/**
* 获取今日新增成员数
* @param int $groupId
* @return int
*/
public function getToDaySum(int $groupId)
{
return $this->getModel()->where('status', 1)->where('group_id', $groupId)->whereDay('join_time')->count();
}
/**
* 获取今日退群成员数
* @param int $groupId
* @return int
*/
public function getToDayReturn(int $groupId)
{
return $this->getModel()->where('status', 0)->where('group_id', $groupId)->whereDay('join_time')->count();
}
/**
* 获取人数统计
* @param int $groupId
* @param string $fromUnixtime
* @param array $field
* @param int $status
* @param string $time
* @param int $page
* @param int $limit
* @return mixed
*/
public function getChatMemberStatistics(int $groupId, string $fromUnixtime = 'create_time', array $field = [], int $status = 1, string $time = '', int $page = 0, int $limit = 0)
{
$date = '%Y-%m-%d';
switch ($time) {
case 'today':
case 'yesterday':
$date = '%Y-%m-%d %H';
break;
case 'week':
case 'last week':
case 'last month':
case 'month':
$date = '%Y-%m-%d';
break;
case 'year':
case 'last year':
$date = '%Y-%m';
break;
}
return $this->search(['time' => $time, 'timeKey' => $fromUnixtime])
->where('group_id', $groupId)
->where('status', $status)
->when($page && $limit, function ($query) use ($page, $limit) {
$query->page($page, $limit);
})
->field(array_merge($field, ['from_unixtime(' . $fromUnixtime . ',"' . $date . '") as time']))
->group('time')
->select()->toArray();
}
/**
* 获取人数统计条数
* @param int $groupId
* @param int $status
* @param string $time
* @return mixed
*/
public function getChatMemberStatisticsCount(int $groupId, int $status = 1, string $time = '')
{
$date = '%Y-%m-%d';
switch ($time) {
case 'today':
case 'yesterday':
$date = '%Y-%m-%d %H';
break;
case 'week':
case 'last week':
case 'last month':
case 'month':
$date = '%Y-%m-%d';
break;
case 'year':
case 'last year':
$date = '%Y-%m';
break;
}
return $this->search(['time' => $time, 'timeKey' => 'update_time'])
->where('group_id', $groupId)
->where('status', $status)
->field(['from_unixtime(update_time,"' . $date . '") as time'])
->group('time')
->count();
}
/**
* 当前用户所在群个数
* @param string $userid
* @return int
*/
public function getChatSum(string $userid)
{
return $this->getModel()->where('userid', $userid)->group('group_id')->count();
}
}