Files
fast_response/admin/application/api/controller/Wxgroup.php
2025-03-26 21:44:17 +08:00

116 lines
3.7 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/25} {14:27}
*/
namespace app\api\controller;
//微信群
use app\common\model\TabConf;
use think\Db;
use wanghua\general_utility_tools_php\Mmodel;
use wanghua\general_utility_tools_php\tool\Tools;
class Wxgroup extends BaseHttpApi
{
/**
* desc获取某群的紧急联系人
* authorwh
*/
//function getEmergencyContact()
//{
// return Mmodel::catchJson(function (){
// $chatroom_id = input('chatroom_id');//52468523601@chatroom
// if(empty($chatroom_id)){
// return Tools::set_fail('群id不能为空');
// }
// $rel_group = Db::table('fa_firmcustomer')
// ->where('rel_group',$chatroom_id)
// ->value('rel_group');
//
// return Tools::set_ok('ok',[
// 'emergency_contact_wxid'=>$rel_group
// ]);
// });
//}
/**
* desc获取某群的责任人wxid
*
* 【请求地址】:
* api/Wxgroup/getEmergencyContactPerson
*
* 【请求参数】:(如果有“必须”标识则表示该字段是必填项)
* rel_group 关联群 【必须】
*
* 【所有字段说明】<span style="color: gray">(可能有部分额外字段未在此体现)</span>
* id ID
* customer_name 客户
* age 年龄
* phone 手机号
* aicustomerservice_ids AI客服可多选
* rel_wx 关联微信
* rel_group 关联群
* firmtags_ids 标签
* headimage 头像
* firmstoreprojectstwo_id 到店项目
* remark 备注
* admin_id 责任人
* responsible_pm 责任PM
* firmcustomerorigin_id 客户来源
* return_visit_content 回访日志
* status 状态:yes=启用,no=禁用
* firm_id 所属企业
* firmstore_id 所属店铺
* create_time 创建时间
* update_time 更新时间
* authorwh
*/
function getEmergencyContactPerson(){
Tools::log_to_write_txt(['获取某群的责任人wxid 入参:'=>input()]);
$api_desc = '获取某群的责任人wxid';
try {
$rel_group = input('rel_group');
if(empty($rel_group)){
return json(Tools::set_fail('参数错误.0',['error_msg'=>'错误信息rel_group错误']));
}
$model_obj = Db::table(TabConf::$fa_firmcustomer);
if(input('rel_group')){
$model_obj->where('rel_group',input('rel_group'));
}
$item = $model_obj->find();
if(empty($item)){
return json(Tools::set_fail('参数错误.1',['error_msg'=>'错误信息该群id未匹配到合适的客户信息']));
}
//责任人
$admin = Db::table(TabConf::$fa_admin)->where('id',$item['admin_id'])->value('wxid');
if(empty($admin)){
return json(Tools::set_fail('参数错误.2',['error_msg'=>'错误信息:该群责任人不存在']));
}
if(empty($admin['rel_wxid'])){
return json(Tools::set_fail('参数错误.3',['error_msg'=>'错误信息:该群责任人未关联微信']));
}
return json(Tools::set_ok('ok',[
'emergency_contact_wxid'=>$admin['rel_wxid']
]));
}catch(\Exception $e){
Tools::log_to_write_txt([
'error'=>'获取某群的责任人wxid.异常.'.$e->getMessage(),
'参数'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_res(500,'操作异常',[]));
}
}
}