This commit is contained in:
2025-03-25 19:43:26 +08:00
parent 517709254a
commit 3e7295fec4
12 changed files with 191 additions and 59 deletions

View File

@@ -9,13 +9,34 @@
namespace app\api\logic;
use think\Db;
class BaseLogic
{
public $base_url = '';
static function curl_post_json(string $url, array $postdata, $header=[]) {
function setBaseUrl($ai_config_id){
//$ai_config_id = input('ai_config_id');
$conf = Db::table('fa_aicustomerservice')
->where('id',$ai_config_id)
->find();
if(empty($conf)){
throw new \Exception('ai客服配置不存在');
}
if(empty($conf['server_url'])){
throw new \Exception('ai客服配置的server_url不能为空');
}
$this->base_url = $conf['server_url'];
return $conf['server_url'];
}
function curl_post_json($url, array $postdata, $header=[]) {
if(empty($this->base_url)){
throw new \Exception('请先设置ai客服配置');
}
$tokenArr = (new TokenLogic())->getToken();
$postdata['appId'] = $tokenArr['appId'];
$domain = config('gewechat.base_url');
$domain = $this->base_url;
$timeout = 4;
$connect_timeout = 1;
$set_time_limit = 5;