企业微信外部联系人同步
This commit is contained in:
@@ -31,8 +31,8 @@ abstract class BaseAdminDataLists extends BaseDataLists
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->adminInfo = $this->request->adminInfo;
|
||||
$this->adminId = $this->request->adminId;
|
||||
$this->adminInfo = $this->request->adminInfo ?? [];
|
||||
$this->adminId = $this->request->adminId ?? 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\lists\qywx;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\BaseDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\QywxExternalContact;
|
||||
|
||||
/**
|
||||
* 企业微信客户列表
|
||||
*/
|
||||
class CustomerLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
class CustomerLists extends BaseDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
@@ -28,29 +28,38 @@ class CustomerLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = QywxExternalContact::where($this->searchWhere)
|
||||
->whereNull('delete_time')
|
||||
->order('id', 'desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
try {
|
||||
$lists = QywxExternalContact::where($this->searchWhere)
|
||||
->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 : [];
|
||||
foreach ($lists as &$item) {
|
||||
// 解析跟进人JSON(如果字段存在)
|
||||
if (isset($item['follow_users'])) {
|
||||
$followUsers = json_decode($item['follow_users'] ?? '[]', true);
|
||||
$item['follow_users'] = is_array($followUsers) ? $followUsers : [];
|
||||
} else {
|
||||
$item['follow_users'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $lists;
|
||||
} catch (\Throwable $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @notes 获取总数
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return QywxExternalContact::where($this->searchWhere)
|
||||
->whereNull('delete_time')
|
||||
->count();
|
||||
try {
|
||||
return QywxExternalContact::where($this->searchWhere)->count();
|
||||
} catch (\Throwable $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user