customer_510
This commit is contained in:
@@ -48,6 +48,7 @@ class Customer extends HD_Controller
|
||||
!$params['level'] && $params['level'] = '';
|
||||
!$params['of_id'] && $params['of_id'] = '';
|
||||
!$params['of2_id'] && $params['of2_id'] = '';
|
||||
!$params['wxqy'] && $params['wxqy'] = '';
|
||||
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
|
||||
|
||||
@@ -74,6 +75,7 @@ class Customer extends HD_Controller
|
||||
}
|
||||
!$params['search_tp'] && $params['search_tp'] = 'mobile';
|
||||
strlen($params['status']) && $where["status"] = $params['status'];
|
||||
strlen($params['wxqy']) && $where["wxqy"] = $params['wxqy'];
|
||||
if ($params['qdjl_id']) {
|
||||
$where["biz_id in(select biz_id from lc_app_licheb_channel_biz where uid={$params['qdjl_id']})"] = null;
|
||||
}
|
||||
@@ -177,8 +179,9 @@ class Customer extends HD_Controller
|
||||
$count = $this->customers_model->count($where);
|
||||
$lists = [];
|
||||
$offlineSources = $this->customers_model->offlineSources();
|
||||
$wxqyAry = $this->customers_model->wxqyAry();
|
||||
if ($count) {
|
||||
$fileds = 'id,name,mobile,cf_title,cont_time,admin_id,status,biz_id,level,of_id,of2_id';
|
||||
$fileds = 'id,name,mobile,cf_title,cont_time,admin_id,status,biz_id,level,of_id,of2_id,wxqy';
|
||||
$rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds);
|
||||
//获取销售员
|
||||
$admin_id_arr = array_unique(array_column($rows, 'admin_id'));
|
||||
@@ -207,6 +210,7 @@ class Customer extends HD_Controller
|
||||
'of_title' => $of_title,
|
||||
'of2_id' => $val['of2_id'],
|
||||
'status_name' => $status_arr[$val['status']],
|
||||
'wxqy_name' => $wxqyAry[$val['wxqy']],
|
||||
'admin_name' => isset($admin_rows[$val['admin_id']]) ? $admin_rows[$val['admin_id']][0]['uname'] : '',
|
||||
'biz_name' => isset($biz_rows[$val['biz_id']]) ? $biz_rows[$val['biz_id']][0]['biz_name'] : '',
|
||||
'cont_time' => $val['cont_time'] != '0000-00-00 00:00:00' ? $val['cont_time'] : '',
|
||||
@@ -217,6 +221,7 @@ class Customer extends HD_Controller
|
||||
$qdjl_lists = $this->app_licheb_users_model->select(array('group_id' => 4, 'status' => 1, 'biz_id<>' => '0'), 'id desc', 0, 0, 'id,uname as name');
|
||||
$show_info['levelAry'] = $this->customers_model->get_sdata('level');
|
||||
$show_info['offlineSourcesAry'] = $offlineSources;
|
||||
$show_info['wxqyAry'] = $wxqyAry;
|
||||
$this->data['show_info'] = $show_info;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
|
||||
@@ -284,6 +289,7 @@ class Customer extends HD_Controller
|
||||
'name' => $row['name'],
|
||||
'mobile' => $mobile_sub,
|
||||
'of_title' => $of_title,
|
||||
'wxqy_name' => $this->customers_model->wxqyAry($row['wxqy']),
|
||||
'cf_user' => $cf_user,
|
||||
'c_time' => date('Y-m-d H:i:s', $row['c_time']),
|
||||
'status' => $row['status'],
|
||||
|
||||
@@ -59,10 +59,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="table-td"><span class="mr5">客户来源:</span>{{info.of_title}}</td>
|
||||
<td class="table-td"><span class="mr5">企微好友:</span>{{info.wxqy_name}}</td>
|
||||
<td class="table-td">
|
||||
<template v-if="info.cf_user"><span class="mr5">分销来源:</span>{{info.cf_user}}</template>
|
||||
</td>
|
||||
<td class="table-td"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
@@ -52,6 +52,15 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">企微好友:</label>
|
||||
<div class="am-para-inline w100">
|
||||
<select name="wxqy" v-model="params.wxqy">
|
||||
<option value=''>请选择</option>
|
||||
<option :value="i" v-for="(v,i) in show_info.wxqyAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 0px;"></div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">客户来源:</label>
|
||||
@@ -150,6 +159,7 @@
|
||||
<th width="10%"><span>所属门店</span></th>
|
||||
<th width="5%"><span>状态</span></th>
|
||||
<th width="5%"><span>销售员</span></th>
|
||||
<th width="5%"><span>企微好友</span></th>
|
||||
<th width="6%"><span>最后联系时间</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -164,10 +174,11 @@
|
||||
<td>{{v.biz_name}}</td>
|
||||
<td>{{v.status_name}}</td>
|
||||
<td>{{v.admin_name}}</td>
|
||||
<td>{{v.wxqy_name}}</td>
|
||||
<td>{{v.cont_time}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
<td colspan="10">
|
||||
<div class="row">
|
||||
<div class="col-md-4 align-l">
|
||||
</div>
|
||||
@@ -260,7 +271,7 @@
|
||||
lists: [],
|
||||
qdjl_lists: [],
|
||||
admins: {cityAry: [], countyAry: [], bizAry: [], list: []},
|
||||
show_info: {levelAry: [], offlineSourcesAry: []},
|
||||
show_info: {levelAry: [], offlineSourcesAry: [], wxqyAry: []},
|
||||
of2Ary: [],
|
||||
},
|
||||
mounted: function () {
|
||||
|
||||
@@ -16,6 +16,80 @@ class Temp extends HD_Controller
|
||||
$this->log_file = 'temp.log';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新战败客户到店
|
||||
* Created on: 2022/3/09 11:58
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_customers_wxqy
|
||||
* https://api.liche.cn/plan/temp/receiver_customers_wxqy
|
||||
*/
|
||||
public function receiver_customers_wxqy()
|
||||
{
|
||||
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
$param = $this->input->get();
|
||||
$param['page'] = intval($param['page']);
|
||||
$param['size'] = intval($param['size']);
|
||||
!$param['size'] && $param['size'] = 2;
|
||||
!$param['page'] && $param['page'] = 1;
|
||||
$counts = intval($param['counts']);
|
||||
ob_start(); //打开缓冲区
|
||||
$where = ["change_type<>" => 'edit_external_contact'];
|
||||
$res = $this->mdWechatqyLog->select($where, 'c_time ASC', $param['page'], $param['size']);
|
||||
if (!$res) {
|
||||
echo '<br>本次更新完成了:';
|
||||
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
|
||||
echo '<br><br><a href="/plan/temp/receiver_customers_wxqy">点击将再次更新>>></a>';
|
||||
exit;
|
||||
}
|
||||
$log = array();
|
||||
foreach ($res as $key => $value) {
|
||||
if ($value['userid'] && $value['external_userid']) {
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'user_get', 'userid' => $value['userid']));
|
||||
if ($re_wx['errcode'] == 0 && $re_wx['mobile']) {//获取企业成员手机
|
||||
$re_use = $this->mdUsers->get(array('mobile' => $re_wx['mobile']));
|
||||
$biz_id = intval($re_use['biz_id']);
|
||||
if ($biz_id) {
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $value['external_userid']));
|
||||
if ($re_wx['errcode'] == 0) {
|
||||
$follow_user = [];
|
||||
foreach ($re_wx['follow_user'] as $key => $val) {
|
||||
if ($val['userid'] == $value['userid']) {//找出当前企业员工
|
||||
$follow_user = $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$remark_mobiles = $follow_user['remark_mobiles'];//用户手机
|
||||
if ($remark_mobiles && $remark_mobiles != '[]' && is_array($remark_mobiles)) {
|
||||
$mobile = $remark_mobiles[0];//取第一个手机号
|
||||
if ($mobile) {
|
||||
if ($value['change_type'] == 'add_external_contact') {//新增
|
||||
$wxqy = 1;
|
||||
} else {//删除
|
||||
$wxqy = -1;
|
||||
}
|
||||
$ret = $this->mdCustomers->update(['wxqy' => $wxqy], ['mobile' => $mobile, 'biz_id' => $biz_id]);
|
||||
if ($ret == 1) {
|
||||
$log[] = ['mobile' => $mobile, 'biz_id' => $biz_id, 'wxqy' => $wxqy];
|
||||
$counts++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '<br>成功更新:';
|
||||
$log && print_r($log);
|
||||
echo '<br><br>数据库获取:';
|
||||
echo json_encode($res, JSON_UNESCAPED_UNICODE);
|
||||
header('refresh:3;url=/plan/temp/receiver_customers_wxqy?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
|
||||
ob_end_flush();//输出全部内容到浏览器
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新战败客户到店
|
||||
* Created on: 2022/3/09 11:58
|
||||
|
||||
@@ -82,21 +82,52 @@ Class Lichene extends HD_Controller
|
||||
if ($re_msg['ChangeType']) {
|
||||
$change_type = $this->mdWechatqyLog->change_type($re_msg['ChangeType']);
|
||||
$userid = $re_msg['UserID'];
|
||||
if ($change_type && $userid) {//只记录现有的
|
||||
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
|
||||
$re_use = $this->mdUsers->get(['userid' => $userid]);
|
||||
if (!$re_use) {//企业成员关连狸车宝用户
|
||||
$ExternalUserID = $re_msg['ExternalUserID'];
|
||||
if ($change_type) {//只记录现有的
|
||||
if ($userid) {//企业成员
|
||||
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'user_get', 'userid' => $userid));
|
||||
if ($re_wx['errcode'] == 0 && $re_wx['mobile']) {//获取企业成员手机
|
||||
$re_use = $this->mdUsers->get(array('mobile' => $re_wx['mobile']));
|
||||
if ($re_use) {//userid与手机绑定关连
|
||||
$this->mdUsers->update(['userid' => $userid], ['id' => $re_use['id']]);
|
||||
$re_use = $this->mdUsers->get(['userid' => $userid]);
|
||||
if (!$re_use) {//企业成员关连狸车宝用户
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'user_get', 'userid' => $userid));
|
||||
if ($re_wx['errcode'] == 0 && $re_wx['mobile']) {//获取企业成员手机
|
||||
$re_use = $this->mdUsers->get(array('mobile' => $re_wx['mobile']));
|
||||
if ($re_use) {//userid与手机绑定关连
|
||||
$this->mdUsers->update(['userid' => $userid], ['id' => $re_use['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$re_msg['log_id'] = $this->mdWechatqyLog->add(['external_userid' => $ExternalUserID, 'userid' => $userid,
|
||||
'change_type' => $re_msg['ChangeType'], 'remark' => $change_type, 'c_time' => $re_msg['CreateTime']]);
|
||||
$wxqy = 0;
|
||||
if ($re_msg['ChangeType'] == 'add_external_contact') {//新增
|
||||
$wxqy = 1;
|
||||
} 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 ($re_wx['errcode'] == 0) {
|
||||
$follow_user = [];
|
||||
foreach ($re_wx['follow_user'] as $key => $val) {
|
||||
if ($val['userid'] == $userid) {//找出当前企业员工
|
||||
$follow_user = $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']);
|
||||
if ($mobile && $biz_id) {
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$ret = $this->mdCustomers->update(['wxqy' => $wxqy], ['mobile' => $mobile, 'biz_id' => $biz_id]);
|
||||
$ret && $re_msg['wxqy'] = $wxqy . '_' . $mobile . '_' . $biz_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$re_msg['log_id'] = $this->mdWechatqyLog->add(['external_userid' => $re_msg['ExternalUserID'], 'userid' => $userid,
|
||||
'change_type' => $re_msg['ChangeType'], 'remark' => $change_type, 'c_time' => $re_msg['CreateTime']]);
|
||||
}
|
||||
}
|
||||
debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
|
||||
@@ -92,6 +92,23 @@ class Receiver_customers_model extends HD_Model
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:企微好友状态
|
||||
* Created on: 2022/5/10 10:00
|
||||
* Created by: dengbw
|
||||
* @param int $id
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function wxqyAry($id)
|
||||
{
|
||||
$arr = [0 => '未添加', 1 => '已添加', -1 => '删除'];
|
||||
if (strlen($id)) {
|
||||
return $arr[$id];
|
||||
} else {
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
||||
public function count_order($where)
|
||||
{
|
||||
return $this->select_order($where, '', '', '', '', 1);
|
||||
|
||||
@@ -224,7 +224,7 @@ class Persona extends CI_Controller
|
||||
if ($mobile && $biz_id) {//有手机号查找客户是否已存在
|
||||
$re_cus = $this->mdCustomers->get(['biz_id' => $biz_id, 'mobile' => $mobile, 'status<>' => -1]);
|
||||
if ($re_cus) {//已存客户绑定操作,不带入现有标签中
|
||||
$result = $this->mdCustomers->update(['unionid' => $userInfo['unionid']], ['id' => $re_cus['id']]);
|
||||
$result = $this->mdCustomers->update(['unionid' => $userInfo['unionid'], 'wxqy' => 1], ['id' => $re_cus['id']]);
|
||||
} else {//创建新客户
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]);
|
||||
@@ -240,6 +240,7 @@ class Persona extends CI_Controller
|
||||
'city_id' => $city_id,
|
||||
'county_id' => $county_id,
|
||||
'unionid' => $userInfo['unionid'],
|
||||
'wxqy' => 1,
|
||||
'of_id' => $params['of_id'],
|
||||
'of2_id' => $params['of2_id'],
|
||||
'cf_title' => '自有资源',
|
||||
|
||||
Reference in New Issue
Block a user