persona_531
This commit is contained in:
@@ -30,8 +30,8 @@ Class Lichene extends HD_Controller
|
||||
*/
|
||||
public function temp()
|
||||
{
|
||||
$param = $this->input->get();
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
$param = $this->input->get();
|
||||
// $re_wx = $this->wx_qyapi->getSignPackage();
|
||||
if ($param) {
|
||||
$re_wx = $this->wx_qyapi->get_external_contact($param);
|
||||
@@ -79,10 +79,11 @@ Class Lichene extends HD_Controller
|
||||
if ($errCode == 0) {
|
||||
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
|
||||
$re_msg = (array)simplexml_load_string($sMsg, 'SimpleXMLElement', LIBXML_NOCDATA);//xml转json
|
||||
$qy_user = [];
|
||||
if ($re_msg['ChangeType']) {
|
||||
$change_type = $this->mdWechatqyLog->change_type($re_msg['ChangeType']);
|
||||
$userid = $re_msg['UserID'];
|
||||
$ExternalUserID = $re_msg['ExternalUserID'];
|
||||
$external_userid = $re_msg['ExternalUserID'];
|
||||
if ($change_type) {//只记录现有的
|
||||
if ($userid) {//企业成员
|
||||
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
|
||||
@@ -97,7 +98,7 @@ Class Lichene extends HD_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
$re_msg['log_id'] = $this->mdWechatqyLog->add(['external_userid' => $ExternalUserID, 'userid' => $userid,
|
||||
$re_msg['log_id'] = $this->mdWechatqyLog->add(['external_userid' => $external_userid, 'userid' => $userid,
|
||||
'change_type' => $re_msg['ChangeType'], 'remark' => $change_type, 'c_time' => $re_msg['CreateTime']]);
|
||||
$wxqy = 0;
|
||||
if ($re_msg['ChangeType'] == 'add_external_contact') {//新增
|
||||
@@ -105,17 +106,18 @@ Class Lichene extends HD_Controller
|
||||
} else if ($re_msg['ChangeType'] == 'del_external_contact' || $re_msg['ChangeType'] == 'del_follow_user') {//删除
|
||||
$wxqy = -1;
|
||||
}
|
||||
if ($wxqy && $re_use && $ExternalUserID) {//查找关连企微客户
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $ExternalUserID));
|
||||
if ($wxqy && $re_use && $external_userid) {//查找关连企微客户
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $external_userid));
|
||||
if ($re_wx['errcode'] == 0) {
|
||||
$follow_user = [];
|
||||
$qy_user['external_contact'] = $re_wx['external_contact'];
|
||||
$remark_mobiles = '';
|
||||
foreach ($re_wx['follow_user'] as $key => $val) {
|
||||
if ($val['userid'] == $userid) {//找出当前企业员工
|
||||
$follow_user = $val;
|
||||
$remark_mobiles = $val['remark_mobiles'];//用户手机
|
||||
$qy_user['follow_info'] = $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$remark_mobiles = $follow_user['remark_mobiles'];//用户手机
|
||||
if ($remark_mobiles && $remark_mobiles != '[]' && is_array($remark_mobiles)) {
|
||||
$mobile = $remark_mobiles[0];//取第一个手机号
|
||||
$biz_id = intval($re_use['biz_id']);
|
||||
@@ -129,6 +131,24 @@ Class Lichene extends HD_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($re_msg['ChangeType'] == 'add_external_contact') {//添加企业客户
|
||||
if (!$qy_user) {
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $external_userid));
|
||||
if ($re_wx['errcode'] == 0) {
|
||||
$qy_user['external_contact'] = $re_wx['external_contact'];
|
||||
foreach ($re_wx['follow_user'] as $key => $val) {
|
||||
if ($val['userid'] == $userid) {//找出当前企业员工
|
||||
$qy_user['follow_info'] = $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($qy_user) {
|
||||
$this->load->model('app/app_lichene_qy_model', 'mdWechatqy');
|
||||
$this->set_wechatqy(['userid' => $userid, 'external_userid' => $external_userid], $qy_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
exit;
|
||||
@@ -515,6 +535,10 @@ Class Lichene extends HD_Controller
|
||||
//读取成员
|
||||
// $re = $this->wx_qyapi->get_external_contact(array('url' => 'user_get', 'userid' => 'DengBingWen'));
|
||||
// echo json_encode($re, JSON_UNESCAPED_UNICODE);
|
||||
// exit;
|
||||
//获取客户详情
|
||||
// $re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => 'wm2x4YKwAAqdNIMj9eOt1LXroR6cn-NQ'));
|
||||
// echo json_encode($re, JSON_UNESCAPED_UNICODE);
|
||||
// exit;
|
||||
//用户分页分别获取避免超时
|
||||
// $userid = "DianCheDaRenXiaoLi";
|
||||
@@ -565,40 +589,52 @@ Class Lichene extends HD_Controller
|
||||
$next_cursor = $re['next_cursor'];
|
||||
foreach ($re['external_contact_list'] as $key => $value) {
|
||||
$external_userid = $value['external_contact']['external_userid'];
|
||||
if ($external_userid) {
|
||||
$re_qy = $this->mdWechatqy->get(['userid' => $userid, 'external_userid' => $external_userid]);
|
||||
$jsondata = [];
|
||||
$jsondata['external_contact'] = $value['external_contact'] ? $value['external_contact'] : '';
|
||||
$jsondata['follow_info'] = $value['follow_info'] ? $value['follow_info'] : '';
|
||||
$remark_mobiles = $value['follow_info']['remark_mobiles'];
|
||||
$mobile = '';
|
||||
if ($remark_mobiles && $remark_mobiles != '[]' && is_array($remark_mobiles)) {
|
||||
$mobile = $remark_mobiles[0];//取第一个手机号
|
||||
}
|
||||
$addData = array(
|
||||
'external_userid' => $value['external_contact']['external_userid'],
|
||||
'name' => $value['external_contact']['name'],
|
||||
'avatar' => $value['external_contact']['avatar'],
|
||||
'unionid' => $value['external_contact']['unionid'] ? $value['external_contact']['unionid'] : '',
|
||||
'userid' => $value['follow_info']['userid'] ? $value['follow_info']['userid'] : '',
|
||||
'remark' => $value['follow_info']['remark'] ? $value['follow_info']['remark'] : '',
|
||||
'mobile' => $mobile,
|
||||
'c_time' => $value['follow_info']['createtime'] ? $value['follow_info']['createtime'] : time(),
|
||||
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
|
||||
'status' => 1,
|
||||
);
|
||||
if (!$re_qy) {
|
||||
$this->mdWechatqy->add($addData);
|
||||
} else {
|
||||
$this->mdWechatqy->update($addData, ['id' => $re_qy['id']]);
|
||||
}
|
||||
}
|
||||
$this->set_wechatqy(['userid' => $userid, 'external_userid' => $external_userid], $value);
|
||||
}
|
||||
echo '<br>next_cursor=' . $next_cursor . '&external_contact_list=' . count($re['external_contact_list']);
|
||||
}
|
||||
return $next_cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:新增/更新企微用户
|
||||
* Created on: 2022/5/31 9:54
|
||||
* Created by: dengbw
|
||||
* @param array $param
|
||||
* @param array $user
|
||||
*/
|
||||
private function set_wechatqy($param = [], $user = [])
|
||||
{
|
||||
if (!$param['userid'] || !$param['external_userid'] || !$user) {
|
||||
return;
|
||||
}
|
||||
$jsondata['external_contact'] = $user['external_contact'] ? $user['external_contact'] : '';
|
||||
$jsondata['follow_info'] = $user['follow_info'] ? $user['follow_info'] : '';
|
||||
$remark_mobiles = $user['follow_info']['remark_mobiles'];
|
||||
$mobile = '';
|
||||
if ($remark_mobiles && $remark_mobiles != '[]' && is_array($remark_mobiles)) {
|
||||
$mobile = $remark_mobiles[0];//取第一个手机号
|
||||
}
|
||||
$addData = array(
|
||||
'external_userid' => $user['external_contact']['external_userid'],
|
||||
'userid' => $user['follow_info']['userid'] ? $user['follow_info']['userid'] : '',
|
||||
'name' => $user['external_contact']['name'],
|
||||
'avatar' => $user['external_contact']['avatar'],
|
||||
'unionid' => $user['external_contact']['unionid'] ? $user['external_contact']['unionid'] : '',
|
||||
'remark' => $user['follow_info']['remark'] ? $user['follow_info']['remark'] : '',
|
||||
'mobile' => $mobile,
|
||||
'c_time' => $user['follow_info']['createtime'] ? $user['follow_info']['createtime'] : time(),
|
||||
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
|
||||
'status' => 1,
|
||||
);
|
||||
$re_qy = $this->mdWechatqy->get(['userid' => $param['userid'], 'external_userid' => $param['external_userid']]);
|
||||
if (!$re_qy) {
|
||||
$this->mdWechatqy->add($addData);
|
||||
} else {
|
||||
$this->mdWechatqy->update($addData, ['id' => $re_qy['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:添加企业客户事件
|
||||
* https://liche-api-dev.xiaoyu.com/wechat/lichene/add_wechatqy
|
||||
|
||||
@@ -72,13 +72,15 @@ class Persona extends CI_Controller
|
||||
if ($params['external_userid']) {
|
||||
//外部联系人
|
||||
$re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $params['external_userid']));
|
||||
if (!$re) {
|
||||
if ($re['errcode'] != 0) {
|
||||
$this->show_json(400, '加载失败请重试!');
|
||||
}
|
||||
$follow_user = [];
|
||||
$follow_user = $qy_user = [];
|
||||
$qy_user['external_contact'] = $re['external_contact'];
|
||||
foreach ($re['follow_user'] as $key => $val) {
|
||||
if ($val['userid'] == $params['user_id']) {//找出当前企业员工
|
||||
$follow_user = $val;
|
||||
$qy_user['follow_info'] = $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -139,6 +141,7 @@ class Persona extends CI_Controller
|
||||
}
|
||||
if (!$c_id && $params['user_id']) {
|
||||
$this->load->model('app/app_lichene_qy_model', 'mdWechatqy');
|
||||
$this->set_wechatqy(['userid' => $params['user_id'], 'external_userid' => $params['external_userid']], $qy_user);
|
||||
$re_qy = $this->mdWechatqy->get(['userid' => $params['user_id'], 'external_userid' => $params['external_userid']]);
|
||||
$re_qy && $buddy_type = $re_qy['buddy_type'];
|
||||
}
|
||||
@@ -345,6 +348,44 @@ class Persona extends CI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:新增/更新企微用户
|
||||
* Created on: 2022/5/31 9:54
|
||||
* Created by: dengbw
|
||||
* @param array $param
|
||||
* @param array $user
|
||||
*/
|
||||
private function set_wechatqy($param = [], $user = [])
|
||||
{
|
||||
if (!$param['userid'] || !$param['external_userid'] || !$user) {
|
||||
return;
|
||||
}
|
||||
$jsondata['external_contact'] = $user['external_contact'] ? $user['external_contact'] : '';
|
||||
$jsondata['follow_info'] = $user['follow_info'] ? $user['follow_info'] : '';
|
||||
$remark_mobiles = $user['follow_info']['remark_mobiles'];
|
||||
$mobile = '';
|
||||
if ($remark_mobiles && $remark_mobiles != '[]' && is_array($remark_mobiles)) {
|
||||
$mobile = $remark_mobiles[0];//取第一个手机号
|
||||
}
|
||||
$addData = array(
|
||||
'external_userid' => $user['external_contact']['external_userid'],
|
||||
'userid' => $user['follow_info']['userid'] ? $user['follow_info']['userid'] : '',
|
||||
'name' => $user['external_contact']['name'],
|
||||
'avatar' => $user['external_contact']['avatar'],
|
||||
'unionid' => $user['external_contact']['unionid'] ? $user['external_contact']['unionid'] : '',
|
||||
'remark' => $user['follow_info']['remark'] ? $user['follow_info']['remark'] : '',
|
||||
'mobile' => $mobile,
|
||||
'c_time' => $user['follow_info']['createtime'] ? $user['follow_info']['createtime'] : time(),
|
||||
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
|
||||
'status' => 1,
|
||||
);
|
||||
$re_qy = $this->mdWechatqy->get(['userid' => $param['userid'], 'external_userid' => $param['external_userid']]);
|
||||
if (!$re_qy) {
|
||||
$this->mdWechatqy->add($addData);
|
||||
} else {
|
||||
$this->mdWechatqy->update($addData, ['id' => $re_qy['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:授权获取企业员工UserId
|
||||
|
||||
Reference in New Issue
Block a user