124 lines
4.1 KiB
PHP
Executable File
124 lines
4.1 KiB
PHP
Executable File
<?php
|
||
/*
|
||
* description:
|
||
* author:wh
|
||
* email:
|
||
* createTime:{2025/3/22} {14:10}
|
||
*/
|
||
|
||
namespace app\admin\controller;
|
||
|
||
|
||
use app\api\logic\GewechatFriendsWechatLogic;
|
||
use think\Controller;
|
||
|
||
class Gewechatfriends extends Controller
|
||
{
|
||
|
||
/**
|
||
* desc:查询微信好友列表
|
||
* author:wh
|
||
* @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 GewechatFriendsWechatLogic();
|
||
$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 GewechatFriendsWechatLogic();
|
||
$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:查询好友详细信息
|
||
* author:wh
|
||
*
|
||
* 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)]);
|
||
}
|
||
|
||
} |