47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace app\common\library\scrm;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 云控蜘蛛统一返回数据结构
|
||
|
|
*/
|
||
|
|
class UnifiedScrmData
|
||
|
|
{
|
||
|
|
/** @var int 今日新增(完成数量) */
|
||
|
|
public int $todayNewCount = 0;
|
||
|
|
|
||
|
|
/** @var int 在线号码数 */
|
||
|
|
public int $totalOnline = 0;
|
||
|
|
|
||
|
|
/** @var int 离线号码数 */
|
||
|
|
public int $totalOffline = 0;
|
||
|
|
|
||
|
|
/** @var array<int, array{number:string,status:string,newFollowersToday:int}> */
|
||
|
|
public array $numbers = [];
|
||
|
|
|
||
|
|
/** @var int 号码总数 */
|
||
|
|
public int $total = 0;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param string $number 号码
|
||
|
|
* @param bool $isOnline 是否在线
|
||
|
|
* @param int $newFollowersToday 今日进线
|
||
|
|
*/
|
||
|
|
public function addNumber(string $number, bool $isOnline, int $newFollowersToday = 0): void
|
||
|
|
{
|
||
|
|
$this->numbers[] = [
|
||
|
|
'number' => $number,
|
||
|
|
'status' => $isOnline ? 'online' : 'offline',
|
||
|
|
'newFollowersToday' => max(0, $newFollowersToday),
|
||
|
|
];
|
||
|
|
|
||
|
|
if ($isOnline) {
|
||
|
|
$this->totalOnline++;
|
||
|
|
} else {
|
||
|
|
$this->totalOffline++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|