Files
fast_response/superadmin/application/admin/controller/Gewechatfriends.php
Your Name dce091da91 t
2025-03-27 07:52:44 +00:00

124 lines
4.1 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
* description
* authorwh
* email
* createTime{2025/3/22} {14:10}
*/
namespace app\admin\controller;
use app\api\logic\GewechatFriendsLogic;
use think\Controller;
class Gewechatfriends extends Controller
{
/**
* desc查询微信好友列表
* authorwh
* @return \think\response\Json
* @throws \Exception
*
* /api/Gewechatfriends/getFriendList
*/
function getFriendList()
{
//获取AI客服配置
//$ai_customer_id = input('ai_customer_id');
if(cache('cache_getFriendDetailList_data'.session_admin_firm_id())){
$data = cache('cache_getFriendDetailList_data'.session_admin_firm_id());
return json(['list' => $data, 'total' => count($data)]);
}
$obj_logic = new GewechatFriendsLogic();
$ai_config_id = input('ai_config_id');
if(empty($ai_config_id)){
throw new \Exception('请先配置AI客服');
}
$obj_logic->setBaseUrlByAiCustmerConfig($ai_config_id);
$res = $obj_logic->getFriendDetailList();
$data = $res['data'];
foreach ($data as $k => &$v){
$v['id'] = $v['userName'] ?? '无';
$v['name'] = $v['nickName'] ?? '无';
}
cache('cache_getFriendDetailList_data'.session_admin_firm_id(),$data,86400);
return json(['list' => $data, 'total' => count($data)]);
}
function getFriendsByAiConfigId()
{
if(cache('cache_getFriendDetailList_data'.session_admin_firm_id())){
$data = cache('cache_getFriendDetailList_data'.session_admin_firm_id());
return json(['list' => $data, 'total' => count($data)]);
}
$obj_logic = new GewechatFriendsLogic();
$ai_config_id = input('ai_config_id');
$obj_logic->setBaseUrlByAiCustmerConfig($ai_config_id);
$res = $obj_logic->getFriendDetailList();
$data = $res['data'];
foreach ($data as $k => &$v){
$v['id'] = $v['userName'] ?? '无';
$v['name'] = $v['nickName'] ?? '无';
}
cache('cache_getFriendDetailList_data'.session_admin_firm_id(),$data,86400);
return json(['list' => $data, 'total' => count($data)]);
}
/**
* desc查询好友详细信息
* authorwh
*
* array(22) {
["userName"] => string(19) "wxid_lqhlkt5nq80n12"
["nickName"] => string(6) "AI dev"
["pyInitial"] => string(5) "AIDEV"
["quanPin"] => string(5) "AIdev"
["sex"] => int(0)
["remark"] => NULL
["remarkPyInitial"] => NULL
["remarkQuanPin"] => NULL
["signature"] => NULL
["alias"] => string(7) "AIhuamn"
["snsBgImg"] => NULL
["country"] => NULL
["bigHeadImgUrl"] => string(194) "https://wx.qlogo.cn/mmhead/ver_1/iaHvw1ich96Wdvm3SF81ySOczyzUxvHj1DviaGVlt7R8OicvmItOD61GaCGG0A5UhoHZfIOolV4Q7tHHMGgicNicEGjGWDE0nZh0udwMNFicHTV5bLoXJiae6AZRzhzbeoQ9DJnhJTAI9h300LjicaTGkAvZt1A/0"
["smallHeadImgUrl"] => string(196) "https://wx.qlogo.cn/mmhead/ver_1/iaHvw1ich96Wdvm3SF81ySOczyzUxvHj1DviaGVlt7R8OicvmItOD61GaCGG0A5UhoHZfIOolV4Q7tHHMGgicNicEGjGWDE0nZh0udwMNFicHTV5bLoXJiae6AZRzhzbeoQ9DJnhJTAI9h300LjicaTGkAvZt1A/132"
["description"] => NULL
["cardImgUrl"] => NULL
["labelList"] => NULL
["province"] => NULL
["city"] => NULL
["phoneNumList"] => NULL
["id"] => string(19) "wxid_lqhlkt5nq80n12"
["name"] => string(6) "AI dev"
}
*
*
* @return \think\response\Json
* @throws \Exception
*
* /api/Gewechatfriends/getFriendDetail
*/
function getFriendDetail()
{
$wx_id = input('wx_id');
$data = [];
if(cache('cache_getFriendDetailList_data'.session_admin_firm_id())){
$cache_data = cache('cache_getFriendDetailList_data'.session_admin_firm_id());
foreach ($cache_data as $k => $v){
if($v['id'] == $wx_id){
$data = $v;
break;
}
}
return json(['data' => $data, 'total' => count($data)]);
}
return json(['data' => $data, 'total' => count($data)]);
}
}