Files
fast_response/admin/application/api/logic/PyappLofic.php
2025-04-22 11:39:12 +08:00

79 lines
2.3 KiB
PHP
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/28} {21:41}
*/
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
{
/**
* desc设置回访模式
* authorwh
* @throws \Exception
*/
function setFollowupModel($url,$chatroom_id,$return_record){
if (empty($url)){
throw new \Exception('获取url失败');
}
$base_url = parse_url($url);
if (!is_array($base_url) || !isset($base_url['scheme']) || !isset($base_url['host'])) {
throw new \Exception("URL解析失败: 输入的URL格式不正确 - {$url}");
}
$url = $base_url['scheme'].'://'.$base_url['host'].'/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,
'is_follow_up' => true,
'follow_up_content'=>$return_record['visit_msg'],
'followup_record_id'=>$return_record['id'].'',
];
Tools::log_to_write_txt(['设置AI客服回访模式开始$url'=>$url,'$post_data'=>$post_data]);
$res = Curl::curl_post_json($url, $post_data);
Tools::log_to_write_txt(['设置AI客服回访模式结束$res'=>$res]);
if(empty($res['data'])){
return Tools::set_fail('设置回访模式失败',$res);
}
$res_data = json_decode($res['data'], true);
return $res_data;
}
/**
* desc关闭回访模式
* authorwh
* @throws \Exception
*/
function closeFollowupModel($chatroom_id){
$base_url = SundryConfig::val('py_app_base_url');
$url = $base_url.'/vip_groups/follow-up';
$post_data = [
'chatroom_id' => $chatroom_id,
'followup_model' => false,
];
$res = Curl::curl_post($url, $post_data);
if(empty($res['data'])){
throw new \Exception('关闭回访模式失败');
}
$res_data = json_decode($res['data'], true);
return $res_data;
}
}