This commit is contained in:
2025-03-28 18:22:47 +08:00
parent 1012e542c1
commit 5e9359e8a5

View File

@@ -53,13 +53,12 @@ class Feedback extends BaseHttpApi
//查询是否有回访记录
$ret = Db::table('fa_firmcustomerfollowuprecord')
->where('wx_groupid',$wx_groupid)
->where('rel_group',$wx_groupid)
->where('rel_wx',$rel_wx)
->find();
if(empty($ret)){
return Tools::set_fail('该客户无回访记录');
}
Db::table('fa_firmcustomerfeedback')
->data([
'firmcustomer_id'=>$ret['firmcustomer_id'],
@@ -80,16 +79,27 @@ class Feedback extends BaseHttpApi
$chat_obj = new ChatGPT();
$chat_obj->url = $ai_config['base_url'];
$chat_obj->apiKey = $ai_config['api_key'];
Tools::log_to_write_txt(['ai总结反馈消息开始'=>$msg]);
$res = $chat_obj->getchatgptresponse($msg);
$question = <<<EOF
【用户反馈】
$msg
EOF;
//dump($question);
//{"id":"","model":"","usage":{"prompt_tokens":1,"completion_tokens":1,"total_tokens":1},"choices":[{"message":{"role":"assistant","content":"无正式反馈内容"},"finish_reason":"stop","index":0}]}
Tools::log_to_write_txt(['ai总结反馈消息开始'=>$question]);
$res = $chat_obj->getchatgptresponse($question);
Tools::log_to_write_txt(['ai总结反馈消息结束'=>$res]);
//dump(input());
//dump($res);die;
if($res['code'] != 200){
return '';
}
$json_arr = json_decode($res['data'],true);
Tools::log_to_write_txt(['$json_arr'=>$json_arr]);
$str = '';
return $str;
if(empty($json_arr['choices'][0]['message']['content'])){
return '';
}
return $json_arr['choices'][0]['message']['content'];
}
}