Files
cunkebao_v3/Server/application/chukebao/controller/CustomerServiceController.php
2025-09-19 16:47:41 +08:00

41 lines
1.5 KiB
PHP

<?php
namespace app\chukebao\controller;
use library\ResponseHelper;
use think\Db;
class CustomerServiceController extends BaseController
{
public function getList(){
$accountId = $this->getUserInfo('s2_accountId');
if (empty($accountId)){
return ResponseHelper::error('请先登录');
}
$accountIds1= Db::table('s2_wechat_friend')->where(['accountId' => $accountId,'isDeleted' => 0])->group('wechatAccountId')->column('wechatAccountId');
$accountIds2 = Db::table('s2_wechat_chatroom')->where(['accountId' => $accountId,'isDeleted' => 0])->group('wechatAccountId')->column('wechatAccountId');
// 确保即使有空数组也不会报错,并且去除重复值
$accountIds = array_unique(array_merge($accountIds1 ?: [], $accountIds2 ?: []));
$list = Db::table('s2_wechat_account')
->whereIn('id',$accountIds)
->order('id desc')
->group('id')
->select();
foreach ($list as $k=>&$v){
$v['createTime'] = !empty($v['createTime']) ? date('Y-m-d H:i:s',$v['createTime']) : '';
$v['updateTime'] = !empty($v['updateTime']) ? date('Y-m-d H:i:s',$v['updateTime']) : '';
$v['labels'] = json_decode($v['labels'],true);
unset(
$v['accountUserName'],
$v['accountRealName'],
$v['accountNickname'],
);
}
unset($v);
return ResponseHelper::success($list);
}
}