This commit is contained in:
2025-03-29 13:59:40 +08:00
parent 4bfb021df2
commit 744815db87
15 changed files with 105 additions and 42 deletions

View File

@@ -0,0 +1,58 @@
<?php
/*
* description
* authorwh
* email
* createTime{2025/3/29} {13:46}
*/
namespace app\api\controller;
use app\api\logic\PyappLofic;
use think\Controller;
class Test extends Controller
{
function test(){
$obj = new PyappLofic();
$res = $obj->setFollowupModel('54116019493@chatroom','测试内容');
dump($res);die;
$url = 'https://wechat-api-test.excn.vip/vip_groups/follow-up';
$data = [
"chatroom_id" => "54116019493@chatroom",
"is_follow_up" => true,
"follow_up_content" => "测试回访内容"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'accept: application/json',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo 'Response:' . $response;
echo 'HTTP Code:' . $httpCode;
}
curl_close($ch);
}
}

View File

@@ -11,7 +11,7 @@ namespace app\api\logic;
use think\Db;
class BaseLogic
class BaseWechatLogic
{
public $base_url = '';
@@ -37,7 +37,7 @@ class BaseLogic
if(empty($this->base_url)){
throw new \Exception('请先设置ai客服配置');
}
$tokenArr = (new TokenLogic())->getToken();
$tokenArr = (new TokenWechatLogic())->getToken();
$postdata['appId'] = $tokenArr['appId'];
$domain = $this->base_url;
$timeout = 4;

View File

@@ -11,7 +11,7 @@ namespace app\api\logic;
use wanghua\general_utility_tools_php\tool\Tools;
class GechatroomLogic extends BaseLogic
class GechatroomWechatLogic extends BaseWechatLogic
{
/**
@@ -26,7 +26,7 @@ class GechatroomLogic extends BaseLogic
//$this->getChatroomMemberList();die;
//$base_url = config('gewechat.base_url');
//去查询群名称
$logic = new GewechatFriendsLogic();
$logic = new GewechatFriendsWechatLogic();
$logic->setBaseUrlByAiCustmerConfig($ai_config_id);
$wxids_arr = $logic->getFriendWxIdsList();
$chatrooms = $wxids_arr['data']['chatrooms'];
@@ -49,7 +49,7 @@ class GechatroomLogic extends BaseLogic
function getChatroomMemberList(){
//去查询群名称
$wxids_arr = (new GewechatFriendsLogic())->getFriendWxIdsList();
$wxids_arr = (new GewechatFriendsWechatLogic())->getFriendWxIdsList();
$chatrooms = $wxids_arr['data']['chatrooms'];
dump($chatrooms);
$url = '/group/getChatroomMemberDetail';
@@ -75,7 +75,7 @@ class GechatroomLogic extends BaseLogic
*/
function getChatroomMemberDetail(){
//去查询群名称
$wxids_arr = (new GewechatFriendsLogic())->getFriendWxIdsList();
$wxids_arr = (new GewechatFriendsWechatLogic())->getFriendWxIdsList();
$chatrooms = $wxids_arr['data']['chatrooms'];
dump($chatrooms);
$url = '/group/getChatroomMemberDetail';

View File

@@ -0,0 +1,80 @@
<?php
/*
* description
* authorwh
* email
* createTime{2025/3/22} {14:11}
*/
namespace app\api\logic;
use wanghua\general_utility_tools_php\tool\Tools;
class GewechatFriendsWechatLogic extends BaseWechatLogic
{
/**
* desc查询微信好友/群/关注的公众号列表[不带昵称]
* authorwh
* @return array 返回的是好友的微信id需要昵称就要调好友查询接口
*
* array(3) {
["ret"] => int(200)
["msg"] => string(12) "操作成功"
["data"] => array(3) {
["friends"] => array(11) {
[0] => string(8) "fmessage"
[1] => string(9) "medianote"
[2] => string(11) "floatbottle"
[3] => string(8) "qmessage"
[4] => string(6) "qqmail"
[5] => string(6) "weixin"
[6] => string(19) "wxid_lqhlkt5nq80n12"
[7] => string(19) "wxid_xazzsfs57xt321"
[8] => string(8) "antas001"
[9] => string(19) "wxid_28a3dob3olc522"
[10] => string(19) "wxid_b7m1xkqu2s7l22"
}
["chatrooms"] => array(3) {
[0] => string(19) "7037032174@chatroom"
[1] => string(20) "52468523601@chatroom"
[2] => string(20) "52984126208@chatroom"
}
["ghs"] => array(1) {
[0] => string(15) "gh_3dfda90e39d6"
}
}
}
*
*
* @throws \Exception
*/
function getFriendWxIdsList()
{
$url = '/contacts/fetchContactsList';
$post_data = [];
Tools::log_to_write_txt(['查询微信好友列表[不带昵称],入参:$post_data'=>$post_data]);
$res = $this->curl_post_json($url, $post_data);
Tools::log_to_write_txt(['查询微信好友列表[不带昵称],出参:$res'=>$res]);
return $res;
}
/**
* desc查询微信好友列表[带昵称]
* authorwh
* @return array 返回的是好友的微信id需要昵称就要调好友查询接口
* @throws \Exception
*/
function getFriendDetailList()
{
$wxids_arr = $this->getFriendWxIdsList();
$wxids = $wxids_arr['data']['friends'];
$url = '/contacts/getDetailInfo';
$post_data = ['wxids'=>$wxids];
Tools::log_to_write_txt(['查询微信好友列表[带昵称],入参:$url:'=>$url,'$post_data'=>$post_data]);
$res = $this->curl_post_json($url, $post_data);
Tools::log_to_write_txt(['查询微信好友列表[带昵称],出参:$res'=>$res]);
return $res;
}
}

View File

@@ -11,7 +11,7 @@ namespace app\api\logic;
use wanghua\general_utility_tools_php\tool\Tools;
class MessageLogic extends BaseLogic
class MessageWechatLogic extends BaseWechatLogic
{
/**

View File

@@ -11,7 +11,7 @@ namespace app\api\logic;
use wanghua\general_utility_tools_php\tool\Tools;
class PersonalLogic extends BaseLogic
class PersonalWechatLogic extends BaseWechatLogic
{
function getProfile()
{

View File

@@ -10,13 +10,15 @@ namespace app\api\logic;
use wanghua\general_utility_tools_php\http\Curl;
use wanghua\general_utility_tools_php\SundryConfig;
use wanghua\general_utility_tools_php\tool\Tools;
/**
* python项目逻辑
* Class PyappLofic
* @package app\api\logic
*/
class PyappLofic extends BaseLogic
class PyappLofic
{
/**
@@ -25,16 +27,18 @@ class PyappLofic extends BaseLogic
* @throws \Exception
*/
function setFollowupModel($chatroom_id,$follow_up_content){
$url = '/vip_groups/follow-up';
$base_url = SundryConfig::val('py_app_base_url');
$url = $base_url.'/vip_groups/follow-up';
$post_data = [
'chatroom_id' => $chatroom_id,
'followup_model' => true,
'is_follow_up' => true,
'follow_up_content'=>$follow_up_content
];
$res = Curl::curl_post($url, $post_data);
$res = Curl::curl_post_json($url, $post_data);
if(empty($res['data'])){
throw new \Exception('设置回访模式失败');
return Tools::set_fail('设置回访模式失败',$res);
}
$res_data = json_decode($res['data'], true);
return $res_data;
@@ -46,7 +50,7 @@ class PyappLofic extends BaseLogic
* @throws \Exception
*/
function closeFollowupModel($chatroom_id){
$base_url = config('py_app_base_url.base_url');
$base_url = SundryConfig::val('py_app_base_url');
$url = $base_url.'/vip_groups/follow-up';
$post_data = [

View File

@@ -7,7 +7,9 @@
*/
namespace app\api\logic;
class TokenLogic extends BaseLogic
use wanghua\general_utility_tools_php\SundryConfig;
class TokenWechatLogic
{
public function __construct()
{
@@ -22,12 +24,11 @@ class TokenLogic extends BaseLogic
["data"] => string(84) "{"gewe-token":"8bd053cb84f24770ae4df11441500427","appId":"wx_N3vKyMW8nl41epbcu891k"}"
}
* authorwh
* @return string
* @throws \Exception
*/
function getToken()
{
$base_url = config('py_app_base_url.base_url');
$base_url = SundryConfig::val('py_app_base_url');
$url = $base_url.'/vip_groups/auth_info';
$res = \wanghua\general_utility_tools_php\http\Curl::curl_post($url, []);
if(empty($res['data'])){