Files
zyt/server/app/adminapi/lists/qywx/CustomerLists.php
T
2026-04-11 18:06:02 +08:00

57 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace app\adminapi\lists\qywx;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\QywxExternalContact;
/**
* 企业微信客户列表
*/
class CustomerLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 搜索条件
*/
public function setSearch(): array
{
return [
'%like%' => ['name', 'follow_user'],
];
}
/**
* @notes 获取列表
*/
public function lists(): array
{
$lists = QywxExternalContact::where($this->searchWhere)
->whereNull('delete_time')
->order('id', 'desc')
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
foreach ($lists as &$item) {
// 解析跟进人JSON
$followUsers = json_decode($item['follow_users'] ?? '[]', true);
$item['follow_users'] = is_array($followUsers) ? $followUsers : [];
}
return $lists;
}
/**
* @notes 获取数量
*/
public function count(): int
{
return QywxExternalContact::where($this->searchWhere)
->whereNull('delete_time')
->count();
}
}