fixed
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -21,18 +21,21 @@ class GechatroomLogic extends BaseLogic
|
||||
*
|
||||
*
|
||||
*/
|
||||
function getChatroomList()
|
||||
function getChatroomList($ai_config_id)
|
||||
{
|
||||
//$this->getChatroomMemberList();die;
|
||||
//$base_url = config('gewechat.base_url');
|
||||
//去查询群名称
|
||||
$wxids_arr = (new GewechatFriendsLogic())->getFriendWxIdsList();
|
||||
$logic = new GewechatFriendsLogic();
|
||||
$logic->setBaseUrl($ai_config_id);
|
||||
$wxids_arr = $logic->getFriendWxIdsList();
|
||||
$chatrooms = $wxids_arr['data']['chatrooms'];
|
||||
$url = '/group/getChatroomInfo';
|
||||
Tools::log_to_write_txt(['获取群列表[带群名称],包含了群成员列表,入参:$chatrooms'=>$chatrooms]);
|
||||
$arr = [];
|
||||
foreach ($chatrooms as $v){
|
||||
$post_data = ['chatroomId'=>$v];
|
||||
$res = self::curl_post_json($url, $post_data);
|
||||
$res = $logic->curl_post_json($url, $post_data);
|
||||
//群号=>群信息[含群成员列表]
|
||||
$arr[] = array_merge($res['data'],[
|
||||
'id'=>$v,
|
||||
@@ -54,7 +57,7 @@ class GechatroomLogic extends BaseLogic
|
||||
$arr = [];
|
||||
foreach ($chatrooms as $v){
|
||||
$post_data = ['chatroomId'=>$v];
|
||||
$res = self::curl_post_json($url, $post_data);
|
||||
$res = $this->curl_post_json($url, $post_data);
|
||||
dump($res);die;
|
||||
//群号=>群信息[含群成员列表]
|
||||
$arr[$v] = array_merge($res['data'],[
|
||||
@@ -80,7 +83,7 @@ class GechatroomLogic extends BaseLogic
|
||||
$arr = [];
|
||||
foreach ($chatrooms as $v){
|
||||
$post_data = ['chatroomId'=>$v];
|
||||
$res = self::curl_post_json($url, $post_data);
|
||||
$res = $this->curl_post_json($url, $post_data);
|
||||
dump($res);die;
|
||||
//群号=>群信息[含群成员列表]
|
||||
$arr[$v] = array_merge($res['data'],[
|
||||
|
||||
@@ -56,7 +56,7 @@ class GewechatFriendsLogic extends BaseLogic
|
||||
$url = '/contacts/fetchContactsList';
|
||||
$post_data = [];
|
||||
Tools::log_to_write_txt(['查询微信好友列表[不带昵称],入参:$post_data'=>$post_data]);
|
||||
$res = self::curl_post_json($url, $post_data);
|
||||
$res = $this->curl_post_json($url, $post_data);
|
||||
Tools::log_to_write_txt(['查询微信好友列表[不带昵称],出参:$res'=>$res]);
|
||||
return $res;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ class GewechatFriendsLogic extends BaseLogic
|
||||
$url = '/contacts/getDetailInfo';
|
||||
$post_data = ['wxids'=>$wxids];
|
||||
Tools::log_to_write_txt(['查询微信好友列表[带昵称],入参:$post_data'=>$post_data]);
|
||||
$res = self::curl_post_json($url, $post_data);
|
||||
$res = $this->curl_post_json($url, $post_data);
|
||||
Tools::log_to_write_txt(['查询微信好友列表[带昵称],出参:$res'=>$res]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace app\api\logic;
|
||||
|
||||
class TokenLogic extends BaseLogic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:
|
||||
@@ -22,7 +25,7 @@ class TokenLogic extends BaseLogic
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
static function getToken()
|
||||
function getToken()
|
||||
{
|
||||
$url = 'https://wechat-api-test.excn.vip/vip_groups/auth_info';
|
||||
$res = \wanghua\general_utility_tools_php\http\Curl::curl_post($url, []);
|
||||
|
||||
Reference in New Issue
Block a user