userslog_426

This commit is contained in:
dengbw
2022-04-26 09:59:40 +08:00
parent aaf43c9bdf
commit e6b1e96c6c
4 changed files with 117 additions and 36 deletions
+91 -23
View File
@@ -16,8 +16,9 @@ class Temp extends HD_Controller
$this->log_file = 'temp.log';
}
/**
* Notes:更新顾问客户数
* Notes:更新顾问新增企微/删除企微
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_users_log
@@ -25,35 +26,102 @@ class Temp extends HD_Controller
*/
public function receiver_users_log()
{
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 200;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
$page = intval($param['page']);
!$page && $page = 0;
ob_start(); //打开缓冲区
$where = ["id>" => 0];
$res = $this->mdUsersLog->select($where, 'id ASC', $param['page'], $param['size'], 'id,customer_1,customer_2,customer_3
,customer_4,customer_5');
if (!$res) {
$user = [
0 => ['mobile' => '17346260816', 'userid' => 'LiLiXiang'], 1 => ['mobile' => '18150195895', 'userid' => 'ChenZongHui'],
2 => ['mobile' => '18950116819', 'userid' => 'JiangYaLi'], 3 => ['mobile' => '18965122277', 'userid' => 'DianCheDaRen'],
4 => ['mobile' => '13860199646', 'userid' => 'LinFan'], 5 => ['mobile' => '18659595528', 'userid' => 'ChenHuiCan01'],
6 => ['mobile' => '13507568055', 'userid' => '13507568055'], 7 => ['mobile' => '17606013180', 'userid' => 'LiuXinXin_2'],
8 => ['mobile' => '13380307317', 'userid' => 'caohui'], 9 => ['mobile' => '17359594819', 'userid' => 'HuJianPing'],
10 => ['mobile' => '15959209469', 'userid' => 'LiuChaHua'], 11 => ['mobile' => '18659197547', 'userid' => 'YuWei'],
12 => ['mobile' => '18559377877', 'userid' => 'ChenYuYou'], 13 => ['mobile' => '13599837805', 'userid' => 'ZengJiaMin'],
14 => ['mobile' => '18649670973', 'userid' => 'ZengLingYan'], 15 => ['mobile' => '15859720661', 'userid' => '15859720661'],
16 => ['mobile' => '13950003857', 'userid' => 'LiHuaiSong'], 17 => ['mobile' => '18950000118', 'userid' => 'LaiDaoAi'],
18 => ['mobile' => '18605086929', 'userid' => '18605086929'], 19 => ['mobile' => '13850083832', 'userid' => 'DuXiaoXia'],
20 => ['mobile' => '18559676954', 'userid' => 'ChenHuiMin'], 21 => ['mobile' => '13850726991', 'userid' => 'WuHaiLin'],
22 => ['mobile' => '15080308865', 'userid' => 'LinGuoPu'], 23 => ['mobile' => '17350035353', 'userid' => 'WeiJiaXing'],
24 => ['mobile' => '18018028742', 'userid' => 'WangZhiJie'], 25 => ['mobile' => '13074881868', 'userid' => 'ZhaoZhenRong'],
26 => ['mobile' => '13806009429', 'userid' => 'SuYaQin'], 27 => ['mobile' => '13860137801', 'userid' => 'LiTingTing'],
28 => ['mobile' => '18759985717', 'userid' => 'LiFengCan'], 29 => ['mobile' => '15980755194', 'userid' => 'ChenYingMing'],
30 => ['mobile' => '18876491999', 'userid' => 'huanghong'], 31 => ['mobile' => '18505912588', 'userid' => 'wangwenbin'],
32 => ['mobile' => '18906027570', 'userid' => 'LiJiaQunGongYongShouJi'], 33 => ['mobile' => '13559551217', 'userid' => 'LiMeiJin'],
34 => ['mobile' => '13313999284', 'userid' => 'lanpeifang'], 35 => ['mobile' => '13559080373', 'userid' => 'linxiaolong'],
36 => ['mobile' => '15859529108', 'userid' => 'hekaihong'], 37 => ['mobile' => '13559062229', 'userid' => 'ZhangQingYuan'],
38 => ['mobile' => '15259197710', 'userid' => 'LiJiaQun'], 39 => ['mobile' => '15880277181', 'userid' => 'ZhangShanBang'],
40 => ['mobile' => '13365014916', 'userid' => 'WuHuanZheng'], 41 => ['mobile' => '18650598580', 'userid' => 'XuHang'],
42 => ['mobile' => '13305996879', 'userid' => 'HuangJian'], 43 => ['mobile' => '13067246341', 'userid' => 'YuZhen'],
44 => ['mobile' => '18750080006', 'userid' => '18750080006'], 45 => ['mobile' => '15695928565', 'userid' => 'YouYongHuang'],
46 => ['mobile' => '18259235613', 'userid' => 'ShaoYunFei'], 47 => ['mobile' => '18650557687', 'userid' => 'ChenYingQin'],
48 => ['mobile' => '13599531683', 'userid' => 'LuoHuaiJie'], 49 => ['mobile' => '15960721797', 'userid' => 'ChenLingLing'],
50 => ['mobile' => '18506016272', 'userid' => 'WengQiZhang'], 51 => ['mobile' => '13616021231', 'userid' => 'LiuShengHua'],
52 => ['mobile' => '18250809990', 'userid' => 'LiuHaiQuan'], 53 => ['mobile' => '13860164563', 'userid' => 'DengBingWen'],
54 => ['mobile' => '18005933510', 'userid' => 'DongKaiJie'], 55 => ['mobile' => '18659299345', 'userid' => 'jimmy'],
56 => ['mobile' => '15659169988', 'userid' => 'HuangJunQiang'], 57 => ['mobile' => '13615020855', 'userid' => 'LaiLianYing'],
58 => ['mobile' => '13666060496', 'userid' => 'ZhangWei'], 59 => ['mobile' => '15106060016', 'userid' => 'WuDianZi'],
60 => ['mobile' => '15160770985', 'userid' => 'XuGuangYi'], 61 => ['mobile' => '13400600144', 'userid' => 'ZhouJinBin'],
62 => ['mobile' => '13950175671', 'userid' => 'ShaoBinHua'], 63 => ['mobile' => '18850511969', 'userid' => 'FuYangYi'],
64 => ['mobile' => '18106088956', 'userid' => 'LiZhengHui'], 65 => ['mobile' => '13275023326', 'userid' => 'YeJiaChen'],
66 => ['mobile' => '15659286291', 'userid' => 'YangYaQi'], 67 => ['mobile' => '13515074395', 'userid' => 'ChenMei'],
68 => ['mobile' => '18559672677', 'userid' => 'DianCheLiKe'], 69 => ['mobile' => '13665921959', 'userid' => 'ChenCuiYun'],
70 => ['mobile' => '15959013922', 'userid' => 'YuTing'], 71 => ['mobile' => '13906050306', 'userid' => 'ZhengYun']];
if (!$user[$page]) {
echo '<br>本次更新顾问客户数完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> ';
echo '<br><br>成功更新 <span style="color: red;">' . $param['page'] . '</span> ';
echo '<br><br><a href="/plan/temp/receiver_users_log">点击将再次更新顾问客户数>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$customers = $value['customer_1'] + $value['customer_2'] + $value['customer_3'] + $value['customer_4'] + $value['customer_5'];
$this->mdUsersLog->update(['customers' => $customers], ['id' => $value['id']]);
$log[] = ['id' => $value['id'], 'customers' => $customers];
$counts++;
$userid = $user[$page]['userid'];
$mobile = $user[$page]['mobile'];
$date = ['user' => $user[$page]];
if ($mobile) {
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
$this->load->model("biz/biz_model", 'mdBiz');
$re_use = $this->mdUsers->get(['mobile' => $mobile, 'group_id < 4' => null, 'status' => 1], 'id,biz_id,userid,mobile,uname');
$date['re_use'] = $re_use;
if ($re_use) {//找到狸车宝用户
if (!$re_use['userid']) {//userid与手机绑定关连
$this->mdUsers->update(['userid' => $userid], ['id' => $re_use['id']]);
}
$sale_id = $id = $re_use['id'];
$biz_id = intval($re_use['biz_id']);
$re_biz = $this->mdBiz->get(['id' => $biz_id]);
$city_id = intval($re_biz['city_id']);
$type = intval($re_biz['type']);
$this->load->library('wx_qyapi', ['app' => 'lichene']);
$param_qy = ['url' => 'get_user_behavior_data'];
$param_qy['userid'] = $userid;
$param_qy['start_time'] = 1648742400;//2022-04-01 00:00:00
$param_qy['end_time'] = 1650643199;//2022-04-22 00:00:00
$re_wx = $this->wx_qyapi->get_external_contact($param_qy);
$adds = $updates = 0;
if ($re_wx['errcode'] == 0) {
foreach ($re_wx['behavior_data'] as $key => $value) {
$log_date = date('Y-m-d', $value['stat_time']);
$qy_adds = intval($value['new_contact_cnt']);
$qy_dels = intval($value['negative_feedback_cnt']);
$re_log = $this->mdUsersLog->get(['log_date' => $log_date, 'sale_id' => $sale_id, 'biz_id' => $biz_id]);
if ($re_log) {
$ret = $this->mdUsersLog->update(['qy_adds' => $qy_adds, 'qy_dels' => $qy_dels], ['id' => $re_log['id']]);
$ret && $updates++;
} else {
$add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id,
'log_date' => $log_date, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'c_time' => $value['stat_time']];
$add_id = $this->mdUsersLog->add($add_item);
$add_id && $adds++;
}
}
}
$date['re_wx'] = $re_wx;
$date['adds'] = $adds;
$date['updates'] = $updates;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/receiver_users_log?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
echo json_encode($date, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/receiver_users_log?page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
+4 -2
View File
@@ -33,8 +33,10 @@ Class Lichene extends HD_Controller
$param = $this->input->get();
$this->load->library('wx_qyapi', ['app' => 'lichene']);
// $re_wx = $this->wx_qyapi->getSignPackage();
$re_wx = $this->wx_qyapi->get_external_contact($param);
echo json_encode($re_wx, JSON_UNESCAPED_UNICODE);
if ($param) {
$re_wx = $this->wx_qyapi->get_external_contact($param);
echo json_encode($re_wx, JSON_UNESCAPED_UNICODE);
}
}
/**
+18 -11
View File
@@ -58,13 +58,14 @@ class Customers extends Wxapp
$data = [
'id' => $row['id'],
'name' => $row['name'],
'mobile' => $this->get_mobile(['mobile' => $row['mobile'], 'of_id' => $row['of_id'],'of2_id'=>$row['of2_id']]),
'mobile' => $this->get_mobile(['mobile' => $row['mobile'], 'of_id' => $row['of_id'], 'of2_id' => $row['of2_id']]),
'complete_mobile' => $row['mobile'],
'tip' => $tip,
'is_top' => $row['is_top'],
'status' => $row['status'],
'other_data' => $other_data,
'is_weChat' => $row['unionid'] ? true : false,
'generate_order' => $this->myuid == $row['admin_id'] ? true : false,
'tags' => $tags
];
return $data;
@@ -87,7 +88,7 @@ class Customers extends Wxapp
$of_title = $row['of_id'] ? $this->get_cfTitle($row) : '';
$data['baseinfo'] = [
'name' => ['value' => $row['name'], 'cn' => '客户姓名'],
'mobile' => ['value' => $this->get_mobile(['mobile' => $row['mobile'], 'of_id' => $row['of_id'],'of2_id'=>$row['of2_id']]), 'cn' => '客户电话'],
'mobile' => ['value' => $this->get_mobile(['mobile' => $row['mobile'], 'of_id' => $row['of_id'], 'of2_id' => $row['of2_id']]), 'cn' => '客户电话'],
'of_id' => ['value' => $of_title, 'of_id' => intval($row['of_id']), 'of2_id' => intval($row['of2_id']), 'cn' => '线索来源'],
'buy_time' => ['value' => $row['buy_time'], 'cn' => '预计购车时间'],
];
@@ -317,7 +318,7 @@ class Customers extends Wxapp
}
}
//修改客户
//客户跟进
protected function put()
{
$uid = $this->session['uid'];
@@ -327,7 +328,10 @@ class Customers extends Wxapp
$t_num = $this->input_param('t_num');
$a_num = $this->input_param('a_num');
$is_top = $this->input_param('is_top');
$defeat_reason = $this->input_param('defeat_reason');
$defeat_reason = $this->input_param('defeat_reason');//申请战败内容
$content = trim($this->input_param('content'));//小记内容
$content_imgs = $this->input_param('imgs');//小记图片
$row = $this->customers_model->get(['id' => $id]);
if (!$row) {
@@ -376,6 +380,10 @@ class Customers extends Wxapp
$a_num && $up_data['a_num = a_num+1'] = null;
$t_num && $up_data['t_num = t_num+1'] = null;
$result = true;
$this->load->library('receiver/customers_entity');
if ($content) {//加小记
$result = $this->customers_entity->add_log_visit($id, $uid, $uname, $content, 0, 1, $content_imgs);
}
if ($up_data) {
$a_log = '';//到店
if ($status == 1 || $a_num) {
@@ -387,7 +395,6 @@ class Customers extends Wxapp
}
$result = $this->customers_model->update($up_data, ['id' => $id]);
if ($result) { //添加日志
$this->load->library('receiver/customers_entity');
if ($a_log) {//到店
$this->customers_entity->add_log($id, $uid, $uname, $a_log, 4);
}
@@ -403,9 +410,9 @@ class Customers extends Wxapp
}
}
if ($result) {
throw new Exception('修改成功', API_CODE_SUCCESS);
throw new Exception('操作成功', API_CODE_SUCCESS);
} else {
throw new Exception('修改失败', ERR_PARAMS_ERROR);
throw new Exception('失败', ERR_PARAMS_ERROR);
}
}
@@ -598,7 +605,7 @@ class Customers extends Wxapp
$lists[] = [
'id' => $val['id'],
'name' => $val['name'],
'mobile' => $this->get_mobile(['mobile' => $val['mobile'],'of_id' => $val['of_id'],'of2_id'=>$val['of2_id']]),
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
'complete_mobile' => $val['mobile'],
'is_top' => $val['is_top'],
'other_data' => $other_data,
@@ -702,7 +709,7 @@ class Customers extends Wxapp
$lists[] = [
'id' => $val['id'],
'name' => $val['name'],
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'],'of2_id'=>$val['of2_id']]),
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
'complete_mobile' => $val['mobile'],
'is_top' => $val['is_top'],
'other_data' => $other_data,
@@ -749,7 +756,7 @@ class Customers extends Wxapp
$lists[] = [
'id' => $val['id'],
'name' => $val['name'],
'mobile' => $this->get_mobile(['mobile' => $val['mobile'],'of_id' => $val['of_id'],'of2_id'=>$val['of2_id']]),
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
'reason' => $reason,
];
}
@@ -856,7 +863,7 @@ class Customers extends Wxapp
// } else {
// $mobile = mobile_asterisk($mobile);
// }
if($params['of2_id']==37 && $params['of_id']==3){ //客户来源:网络推广-狸车分配 隐藏手机号
if ($params['of2_id'] == 37 && $params['of_id'] == 3) { //客户来源:网络推广-狸车分配 隐藏手机号
$mobile = '****' . substr($mobile, -4);
}
return $mobile;
+4
View File
@@ -168,6 +168,10 @@ class Wx_qyapi
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remark?access_token={$access_token}";
$res = $this->ci->mycurl->httpPost($url, array('userid' => $param['userid'], 'external_userid' => $param['external_userid']
, 'remark_mobiles' => $param['remark_mobiles'], 'description' => $param['description']), 'is_json');
} else if ($param['url'] == 'get_user_behavior_data') {//联系客户统计 https://developer.work.weixin.qq.com/document/path/92132
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_user_behavior_data?access_token={$access_token}";
$params = ['userid' => $param['userid'], 'start_time' => $param['start_time'], 'end_time' => $param['end_time']];
$res = $this->ci->mycurl->httpPost($url, $params, 'is_json');
}
$data = trim($res, chr(239) . chr(187) . chr(191));
$result = json_decode($data, true);