persona_320_2
This commit is contained in:
@@ -10,14 +10,11 @@ class Persona extends CI_Controller
|
||||
{
|
||||
private $config_qyapi;
|
||||
private $config_qyapi_agent;
|
||||
private $log_file;
|
||||
private $aid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$target_class = lcfirst(get_class($this));//调用类的名称,子类或者当前类名称
|
||||
$this->log_file = "home_h5_{$target_class}.log";
|
||||
$aid = $this->input->get('aid') ? $this->input->get('aid') : $this->input->post('aid');
|
||||
$this->aid = intval($aid);
|
||||
if ($this->aid == 1) {
|
||||
@@ -47,12 +44,8 @@ class Persona extends CI_Controller
|
||||
if ($result['errcode'] == 0 && $result['UserId']) {//获取企业员工userid
|
||||
$user_id = $result['UserId'];
|
||||
}
|
||||
//echo 'user_id=' . $result['UserId'] . '&aid=' . $this->aid;
|
||||
$sign_package = $this->wx_qyapi->getSignPackage();
|
||||
$sign_package_agent = $this->wx_qyapi_agent->getSignPackage();
|
||||
// echo json_encode($sign_package, JSON_UNESCAPED_UNICODE);
|
||||
// echo '<br><br>';
|
||||
// echo json_encode($sign_package_agent, JSON_UNESCAPED_UNICODE);
|
||||
$data = ['_title' => '客户画像', 'sign_package' => $sign_package, 'sign_package_agent' => $sign_package_agent
|
||||
, 'user_id' => $user_id, 'aid' => $this->aid];
|
||||
$this->load->view('/h5/persona/index', $data);
|
||||
@@ -77,10 +70,8 @@ class Persona extends CI_Controller
|
||||
$this->show_json(400, '加载失败请重试~');
|
||||
}
|
||||
if ($params['external_userid']) {
|
||||
//$this->load->library('wx_qyapi', $this->config_qyapi);
|
||||
//外部联系人
|
||||
$re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $params['external_userid']));
|
||||
//debug_log('externalcontact_get:' . json_encode($re, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
if (!$re) {
|
||||
$this->show_json(400, '加载失败请重试!');
|
||||
}
|
||||
@@ -116,7 +107,7 @@ class Persona extends CI_Controller
|
||||
$external_contact['unionid'] && $unionid = $external_contact['unionid'];
|
||||
}
|
||||
$userInfo = [
|
||||
'avatar' => $avatar, 'mobile' => $mobile, 'name' => $name, 'gender' => $gender, 'source' => '@微信'
|
||||
'avatar' => $avatar, 'mobile' => $mobile, 'remark_mobile' => $mobile, 'name' => $name, 'gender' => $gender, 'source' => '@微信'
|
||||
, 'unionid' => $unionid, 'external_userid' => $params['external_userid'], 'userid' => $userid, 'tags_name' => $tags_name
|
||||
];
|
||||
//企业成员
|
||||
@@ -272,8 +263,43 @@ class Persona extends CI_Controller
|
||||
}
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$this->customers_entity->add_log($c_id, $userInfo['admin_id'], $userInfo['admin_name'], $log);
|
||||
$up_customer_tag = 1;//1更新客户标签
|
||||
if (!$re_cus || !$userInfo['remark_mobile']) {//新增客户/首次绑定手机 更新企微信息
|
||||
$up_customer_tag = 0;
|
||||
$remark_mobiles = $userInfo['mobile'] ? [$userInfo['mobile']] : '';
|
||||
$description = $params['of_title'] ? $params['of_title'] : '';
|
||||
if ($description && $params['of2_title']) {
|
||||
$description .= '-' . $params['of2_title'];
|
||||
}
|
||||
//企微备注操作
|
||||
$this->wx_qyapi->get_external_contact(['url' => 'remark', 'userid' => $userInfo['userid']
|
||||
, 'external_userid' => $userInfo['external_userid'], 'remark_mobiles' => $remark_mobiles, 'description' => $description]);
|
||||
$tags_name = $userInfo['tags_name'];
|
||||
$add_tag = $remove_tag = '';
|
||||
if ($params['taglList']) {
|
||||
foreach ($params['taglList'] as $key => $val) {
|
||||
foreach ($val['list'] as $key2 => $val2) {
|
||||
if ($val2['checked'] == 'true') {
|
||||
$up_customer_tag = 1;
|
||||
if (!$tags_name || !in_array($val2['name'], $tags_name)) {//未加标签,新增
|
||||
$add_tag[] = $val2['qy_id'];
|
||||
}
|
||||
} else {
|
||||
if ($tags_name && in_array($val2['name'], $tags_name)) {//删除标签
|
||||
$remove_tag[] = $val2['qy_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//企微标签操作
|
||||
if ($add_tag || $remove_tag) {
|
||||
$this->wx_qyapi->get_external_contact(['url' => 'mark_tag', 'userid' => $userInfo['userid'],
|
||||
'external_userid' => $userInfo['external_userid'], 'add_tag' => $add_tag, 'remove_tag' => $remove_tag]);
|
||||
}
|
||||
}
|
||||
//客户标签
|
||||
if ($params['taglList']) {
|
||||
if ($params['taglList'] && $up_customer_tag) {
|
||||
$this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata');
|
||||
$add_tag = [];
|
||||
//查找已加入标签
|
||||
@@ -296,39 +322,6 @@ class Persona extends CI_Controller
|
||||
$this->mdCustomerTagdata->add_batch($add_tag);
|
||||
}
|
||||
}
|
||||
if (!$re_cus) {//新增客户 更新企微信息
|
||||
//$this->load->library('wx_qyapi', $this->config_qyapi);
|
||||
$remark_mobiles = $userInfo['mobile'] ? [$userInfo['mobile']] : '';
|
||||
$description = $params['of_title'] ? $params['of_title'] : '';
|
||||
if ($description && $params['of2_title']) {
|
||||
$description .= '-' . $params['of2_title'];
|
||||
}
|
||||
//企微备注操作
|
||||
$this->wx_qyapi->get_external_contact(['url' => 'remark', 'userid' => $userInfo['userid']
|
||||
, 'external_userid' => $userInfo['external_userid'], 'remark_mobiles' => $remark_mobiles, 'description' => $description]);
|
||||
$tags_name = $userInfo['tags_name'];
|
||||
$add_tag = $remove_tag = '';
|
||||
if ($params['taglList']) {
|
||||
foreach ($params['taglList'] as $key => $val) {
|
||||
foreach ($val['list'] as $key2 => $val2) {
|
||||
if ($val2['checked'] == 'true') {
|
||||
if (!$tags_name || !in_array($val2['name'], $tags_name)) {//未加标签,新增
|
||||
$add_tag[] = $val2['qy_id'];
|
||||
}
|
||||
} else {
|
||||
if ($tags_name && in_array($val2['name'], $tags_name)) {//删除标签
|
||||
$remove_tag[] = $val2['qy_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//企微标签操作
|
||||
if ($add_tag || $remove_tag) {
|
||||
$this->wx_qyapi->get_external_contact(['url' => 'mark_tag', 'userid' => $userInfo['userid'],
|
||||
'external_userid' => $userInfo['external_userid'], 'add_tag' => $add_tag, 'remove_tag' => $remove_tag]);
|
||||
}
|
||||
}
|
||||
$this->show_json(200, '操作成功');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user