2025-03-19 12:01:02 +08:00
|
|
|
<?php
|
2025-05-10 10:17:58 +08:00
|
|
|
|
2025-04-09 10:35:28 +08:00
|
|
|
namespace app\cunkebao\model;
|
2025-03-19 12:01:02 +08:00
|
|
|
|
|
|
|
|
use think\Model;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 微信账号模型类
|
|
|
|
|
*/
|
|
|
|
|
class WechatAccount extends Model
|
|
|
|
|
{
|
|
|
|
|
// 设置表名
|
|
|
|
|
protected $name = 'wechat_account';
|
2025-05-10 10:17:58 +08:00
|
|
|
|
2025-03-19 12:01:02 +08:00
|
|
|
/**
|
|
|
|
|
* 获取在线微信账号数量
|
2025-05-10 10:17:58 +08:00
|
|
|
*
|
2025-03-19 12:01:02 +08:00
|
|
|
* @param array $where 额外的查询条件
|
|
|
|
|
* @return int 微信账号数量
|
|
|
|
|
*/
|
|
|
|
|
public static function getOnlineWechatCount($where = [])
|
|
|
|
|
{
|
|
|
|
|
$condition = [
|
|
|
|
|
'deviceAlive' => 1,
|
|
|
|
|
'wechatAlive' => 1,
|
2025-05-10 10:17:58 +08:00
|
|
|
'isDeleted' => 0
|
2025-03-19 12:01:02 +08:00
|
|
|
];
|
2025-05-10 10:17:58 +08:00
|
|
|
|
2025-03-19 12:01:02 +08:00
|
|
|
// 合并额外条件
|
|
|
|
|
if (!empty($where)) {
|
|
|
|
|
$condition = array_merge($condition, $where);
|
|
|
|
|
}
|
2025-05-10 10:17:58 +08:00
|
|
|
|
2025-03-19 12:01:02 +08:00
|
|
|
return self::where($condition)->count();
|
|
|
|
|
}
|
2025-05-10 10:17:58 +08:00
|
|
|
|
2025-03-19 12:01:02 +08:00
|
|
|
/**
|
|
|
|
|
* 获取有登录微信的设备数量
|
2025-05-10 10:17:58 +08:00
|
|
|
*
|
2025-03-19 12:01:02 +08:00
|
|
|
* @param array $where 额外的查询条件
|
|
|
|
|
* @return int 设备数量
|
|
|
|
|
*/
|
|
|
|
|
public static function getDeviceWithWechatCount($where = [])
|
|
|
|
|
{
|
|
|
|
|
$condition = [
|
|
|
|
|
'deviceAlive' => 1,
|
2025-05-10 10:17:58 +08:00
|
|
|
'isDeleted' => 0
|
2025-03-19 12:01:02 +08:00
|
|
|
];
|
2025-05-10 10:17:58 +08:00
|
|
|
|
2025-03-19 12:01:02 +08:00
|
|
|
// 合并额外条件
|
|
|
|
|
if (!empty($where)) {
|
|
|
|
|
$condition = array_merge($condition, $where);
|
|
|
|
|
}
|
2025-05-10 10:17:58 +08:00
|
|
|
|
2025-03-19 12:01:02 +08:00
|
|
|
return self::where($condition)->count();
|
|
|
|
|
}
|
|
|
|
|
}
|