visit_526

This commit is contained in:
dengbw
2022-05-26 14:52:52 +08:00
committed by lccsw
parent 064683372a
commit e36666c03f
9 changed files with 443 additions and 90 deletions
+5 -2
View File
@@ -653,14 +653,17 @@ class Goods extends HD_Controller
}
if (!$re_i) {
$brand_id = $objWorksheet->getCell('A' . $_row)->getValue(); //品牌id
$re_b = $this->mdAutoBrand->get(array('name' => $brand_id));
$brand_id = $re_b ? $re_b['id'] : 0;
if (!$brand_id && !$vin) {
continue;
}
$s_id = $objWorksheet->getCell('B' . $_row)->getValue(); //车系id
$v_id = $objWorksheet->getCell('C' . $_row)->getValue(); //车型id
$cor_id = $objWorksheet->getCell('D' . $_row)->getValue(); //车身颜色id
$incor_id = $objWorksheet->getCell('E' . $_row)->getValue(); //内饰颜色id
$addr_name = $objWorksheet->getCell('G' . $_row)->getValue(); //存放地
$company_name = $objWorksheet->getCell('H' . $_row)->getValue(); //归属公司
$re_b = $this->mdAutoBrand->get(array('name' => $brand_id));
$brand_id = $re_b ? $re_b['id'] : 0;
$re_s = $this->mdAutoSeries->get(array('brand_id' => $brand_id, 'name' => $s_id));
$s_id = $re_s ? $re_s['id'] : 0;
$re_a1 = $this->mdAutoAttr->get(array('s_id' => $s_id, 'type' => 1, 'title' => $v_id));
+221 -57
View File
@@ -15,7 +15,224 @@ class Licheb extends HD_Controller
parent::__construct();
$this->log_file = 'licheb.log';
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
}
/**
* Notes:更新客户回访记录
* Created on: 2022/05/24 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/visit_data?sd=1
* https://api.liche.cn/plan/licheb/visit_data
*/
public function visit_data()
{
$params = $this->input->get();
$hour = date('H.i');
if (($hour > 00.00 && $hour < 03.00) || $params['sd']) {
if ($params['sd']) {
echo "开始执行客户回访[{$hour}]<br>";
}
} else {
echo '[00.00-03.00]执客户回访[' . $hour . ']<br>';
return;
}
$this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData');
$time = strtotime("-1 day");//昨天此时的时间戳
$size = 200;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$t_day = date('Y-m-d', $time);
$redisKey = 'app_licheb_visit_data_id_' . $t_day;
if ($rds) {
$redis->delete($redisKey);
}
$id = $redis->get($redisKey);
!$id && $id = 0;
$log = [];
$where = ['id >' => $id, 'status<>' => 2, 't_day' => $t_day];
$res = $this->mdCustomerVisitData->select($where, 'id asc', 1, $size, 'id,c_id,biz_id,sales_id,level');
if (!$res) {
echo '执行到当前客户回访id' . $id . '暂无数据';
return;
}
$this->load->model('receiver/receiver_customers_visit_sales_model', 'mdCustomerVisitSales');
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomerOpLogs');
$s_time = strtotime($t_day . ' 00:00:00');
$e_time = strtotime($t_day . ' 23:59:59');
$today = date('Y-m-d');//明天
foreach ($res as $key => $value) {
$re_opl = $this->mdCustomerOpLogs->get(['customer_id' => $value['c_id'], 'uid' => $value['sales_id']
, 'type in(0,1,2)' => null, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
if ($re_opl) {//2已跟进
$this->mdCustomerVisitData->update(['status' => 2], ['id' => $value['id']]);
} else {
$ret = $this->mdCustomerVisitData->update(['status' => 3], ['id' => $value['id']]);
if ($ret) {
$where_vis = ['c_id' => $value['c_id'], 'sales_id' => $value['sales_id'], 't_day' => $today];
$re_vis = $this->mdCustomerVisitData->get($where_vis);
if (!$re_vis) {//新增明天延期数据
$where_vis['biz_id'] = $value['biz_id'];
$where_vis['status'] = 3;
$where_vis['level'] = $value['level'];
$where_vis['c_time'] = time();
$id = $this->mdCustomerVisitData->add($where_vis);
if ($id) {//更新回访时间
$this->mdCustomers->mdCustomers->update(['visit_time' => $today], ['id' => $value['c_id']]);
$params['sd'] && $log[] = $where_vis;
}
}
}
}
}
$redis->save($redisKey, $id, 24 * 3600);//保存最后id
if ($params['sd']) {
echo '<br>执行到当前客户回访id' . $redis->get($redisKey);
echo ' 日期:' . $t_day;
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
}
}
/**
* Notes:客户回访顾问统计
* Created on: 2022/05/24 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/visit_sales?sd=1
* https://api.liche.cn/plan/licheb/visit_sales
*/
public function visit_sales()
{
$params = $this->input->get();
$hour = date('H.i');
if (($hour > 00.00 && $hour < 03.00) || $params['sd']) {
if ($params['sd']) {
echo "开始执行库顾问日志[{$hour}]<br>";
}
} else {
echo '[00.00-03.00]执行顾问日志[' . $hour . ']<br>';
return;
}
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData');
$this->load->model('receiver/receiver_customers_visit_sales_model', 'mdCustomerVisitSales');
$this->load->model("biz/biz_model", 'mdBiz');
$time = strtotime("-1 day");//昨天此时的时间戳
$size = 200;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$t_day = date('Y-m-d', $time);
$redisKey = 'app_licheb_visit_sales_id_' . $t_day;
if ($rds) {
$redis->delete($redisKey);
}
$id = $redis->get($redisKey);
!$id && $id = 0;
$log = [];
$where = ['id >' => $id, 'group_id < 4' => null, 'status' => 1];
$res = $this->mdUsers->select($where, 'id asc', 1, $size, 'id,biz_id,userid');
if (!$res) {
echo '执行到当前顾问id' . $id . '暂无数据';
return;
}
$str_biz_ids = implode(',', array_unique(array_column($res, 'biz_id')));
$map_biz = $this->mdBiz->map('id', 'city_id,type,status', ["id in({$str_biz_ids})" => null]);
foreach ($res as $key => $value) {
$sales_id = $id = $value['id'];
$biz_id = intval($value['biz_id']);
if ($map_biz[$biz_id]['status'] == 1) {//判断门店状态
$where_sal = ['t_day' => $t_day, 'sales_id' => $sales_id, 'biz_id' => $biz_id];
$re_sal = $this->mdCustomerVisitSales->get($where_sal);
if (!$re_sal) {//判断当天是否已加入
$t_follows = $this->mdCustomerVisitData->count(array_merge($where_sal, ['status' => 1]));
$h_follows = $this->mdCustomerVisitData->count(array_merge($where_sal, ['status' => 2]));
$w_follows = $this->mdCustomerVisitData->count(array_merge($where_sal, ['status' => 3]));
$add_item = ['t_day' => $t_day, 'sales_id' => $sales_id, 'biz_id' => $biz_id, 't_follows' => $t_follows
, 'h_follows' => $h_follows, 'w_follows' => $w_follows, 'c_time' => time()];
$add_id = $this->mdCustomerVisitSales->add($add_item);
if ($add_id && $params['sd']) {
$log[] = array('id' => $sales_id, 'add_item' => $add_item);
}
}
}
}
$redis->save($redisKey, $id, 24 * 3600);//保存最后id
if ($params['sd']) {
echo '<br>执行到当前顾问id' . $redis->get($redisKey);
echo ' 日期:' . $t_day;
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
}
}
/**
* Notes:给销售发送待回访短信
* Created on: 2021/10/19 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/visit_sales_sms?sd=1
* https://api.liche.cn/plan/licheb/visit_sales_sms
*/
public function visit_sales_sms()
{
$params = $this->input->get();
$hour = date('H.i');
if (($hour > 09.00 && $hour < 10.00) || $params['sd']) {
if ($params['sd']) {
echo "开始执行发短信给销售[{$hour}]<br>";
}
} else {
echo '[09.00-10.00]点过才会开始执行发短信给销售[' . $hour . ']<br>';
return;
}
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$t_day = date('Y-m-d');
$redisKey = 'visit_sales_sms_id_' . $t_day;
if ($rds) {
$redis->delete($redisKey);
}
$id = $redis->get($redisKey);
!$id && $id = 0;
$log = array();
$this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData');
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$where = array('id >' => $id, 'status' => 1, 'group_id' => 1);
$res_u = $this->mdUsers->select($where, 'id asc', 1, $size, 'id,biz_id,mobile');
if (!$res_u) {
echo '执行到当前销售id' . $id . '暂无数据';
return;
}
foreach ($res_u as $key => $value) {
$id = $value['id'];
$biz_id = $value['biz_id'];
$where_v = ['a.biz_id' => $biz_id, 'a.status<>' => 2, 'b.t_day' => $t_day, 'b.sales_id' => $id, 'b.status<>' => 2];
$visit_count = $this->mdCustomerVisitData->count_visit($where_v);
if ($visit_count) {//发送短信
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_242696263', 'param' => ['count' => $visit_count]));
$log[] = array('id' => $id, 'mobile' => $value['mobile'], 'count' => $visit_count);
}
}
$redis->save($redisKey, $id, 24 * 3600);//保存最后销售id
if ($params['sd']) {
echo '<br>执行到当前销售id' . $redis->get($redisKey);
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res_u, JSON_UNESCAPED_UNICODE);
}
}
/**
@@ -144,62 +361,6 @@ class Licheb extends HD_Controller
}
}
/**
* Notes:给销售发送待回访短信
* Created on: 2021/10/19 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/visit_sales_sms
* https://api.liche.cn/plan/licheb/visit_sales_sms
*/
public function visit_sales_sms()
{
$params = $this->input->get();
$hour = date('H');
if ($hour != '09' && !$params['sd']) {
echo '[9]点过后才会开始执行发短信给销售[' . $hour . ']';
return;
}
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'visit_sales_sms_id';
$day = date('Y-m-d');
$re_v = $this->mdCustomersVisit->get(array('day' => $day));//查找当天是否有数据
if (!$re_v || $rds) {
$redis->delete($redisKey);
}
$id = $redis->get($redisKey);
!$id && $id = 0;
$log = array();
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$where = array('id >' => $id, 'status' => 1, 'group_id' => 1);
$res_u = $this->mdUsers->select($where, 'id asc', 1, $size, 'id,biz_id,mobile');
if (!$res_u) {
echo '执行到当前销售id' . $id . '暂无数据';
return;
}
foreach ($res_u as $key => $value) {
$id = $value['id'];
$biz_id = $value['biz_id'];
$where_v = array("a.biz_id in ($biz_id)" => null, 'a.status<>' => 2, 'a.admin_id' => $id, 'b.contact' => 1, 'b.status' => 1, 'b.day=' => $day);
$visit_count = $this->mdCustomersVisit->count_visit($where_v);
if ($visit_count) {//发送短信
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_226985259', 'param' => ['count' => $visit_count]));
$log[] = array('id' => $id, 'mobile' => $value['mobile'], 'count' => $visit_count);
}
}
$redis->save($redisKey, $id);//保存最后销售id
if ($params['sd']) {
echo '<br>执行到当前销售id' . $redis->get($redisKey);
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res_u, JSON_UNESCAPED_UNICODE);
}
}
/**
* Notes:给店长发送待分配短信
@@ -216,6 +377,7 @@ class Licheb extends HD_Controller
echo '[9]点过后才会开始执行发短信给销售[' . $hour . ']';
return;
}
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
@@ -274,6 +436,7 @@ class Licheb extends HD_Controller
echo '[0]点过后才会开始执行客户待回访[' . $hour . ']';
return;
}
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
@@ -362,6 +525,7 @@ class Licheb extends HD_Controller
echo '[23]点过后才会更新客户等级[' . $hour . ']';
return;
}
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
+5 -4
View File
@@ -29,10 +29,11 @@ class Plan extends CI_Controller
//$plan[] = array('url' => base_url(array('plan', 'bobing', 'lottery')), 'interval' => 30);//博饼每日中奖
//$plan[] = array('url' => base_url(array('plan', 'bobing', 'mj')), 'interval' => 30);//马甲跑总分数
//$plan[] = array('url' => base_url(array('plan', 'bobing', 'mj_day')), 'interval' => 30);//马甲跑今日分数
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_visit')), 'interval' => 1);//增加客户待回访
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_level')), 'interval' => 1);//更新客户等级
$plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales_sms')), 'interval' => 1);//给销售发送待回访短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 1);//给店长发送待分配短信
//$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_visit')), 'interval' => 1);//增加客户待回访
//$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_level')), 'interval' => 1);//更新客户等级
$plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_data')), 'interval' => 3);//更新客户回访记录
$plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales')), 'interval' => 3);//客户回访顾问统计
$plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales_sms')), 'interval' => 3);//给销售发送待回访短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 1);//给店长发送待分配短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志
+102 -7
View File
@@ -54,6 +54,7 @@ class Customers extends Wxapp
'建卡时间' => date('Y-m-d', $row['c_time']),
];
$row['cont_time'] != '0000-00-00 00:00:00' && $other_data['最近联系'] = date('Y-m-d', strtotime($row['cont_time']));
$row['visit_time'] != '0000-00-00' && $other_data['计划回访时间'] = $row['visit_time'];
$other_data['销售顾问'] = isset($admin) ? $admin['uname'] : '';
$data = [
'id' => $row['id'],
@@ -322,6 +323,7 @@ class Customers extends Wxapp
//客户跟进
protected function put()
{
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$uid = $this->session['uid'];
$uname = $this->session['uname'];
$id = $this->input_param('id');
@@ -331,10 +333,10 @@ class Customers extends Wxapp
$is_top = $this->input_param('is_top');
$defeat_reason = $this->input_param('defeat_reason');//申请战败内容
$level = $this->input_param('level');//客户等级
$content = trim($this->input_param('content'));//小记内容
$content_imgs = $this->input_param('imgs');//小记图片
$follow_channel = $this->input_param('follow_channel');//跟进渠道
$visit_time = $this->input_param('visit_time');//计划回访时间
$row = $this->customers_model->get(['id' => $id]);
if (!$row) {
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
@@ -369,8 +371,8 @@ class Customers extends Wxapp
if ($status == 1 && $status != $row['status']) {//到店客户和数据库不同到店加1
$a_num = 1;
}
$day = date('Y-m-d');
if ($a_num || $t_num) {
$day = date('Y-m-d');
if ($a_num) {//判断今日是否到店
$re = $this->customer_oplogs_model->get(['customer_id' => $id, 'type' => 4,
'c_time >=' => strtotime($day . ' 00:00:00'), 'c_time <=' => strtotime($day . ' 23:59:59')]);
@@ -384,6 +386,7 @@ class Customers extends Wxapp
}
$a_num && $up_data['a_num = a_num+1'] = null;
$t_num && $up_data['t_num = t_num+1'] = null;
$visit_time && $up_data['visit_time'] = $visit_time;
$level != $row['level'] && $up_data['level'] = $level;//更改客户等级
$log_4 = '';//到店
if ($a_num) {
@@ -419,6 +422,17 @@ class Customers extends Wxapp
}
}
if ($content) {//加小记
$follow_channel && $content = "跟进渠道($follow_channel)" . $content;
if ($visit_time) {
$content .= '。计划回访时间:' . $visit_time;
$where_vis = ['c_id' => $id, 'biz_id' => $biz_id, 'sales_id' => $uid, 't_day' => $visit_time, 'level' => $level];
$this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData');
$re_vis = $this->mdCustomerVisitData->get($where_vis);
if (!$re_vis) {
$where_vis['c_time'] = time();
$this->mdCustomerVisitData->add($where_vis);
}
}
$result = $this->customers_entity->add_log_visit($id, $uid, $uname, $content, 0, 1, $content_imgs);
}
if ($result) {
@@ -451,6 +465,7 @@ class Customers extends Wxapp
{
$level = $this->customers_model->get_sdata('level');
$cfrom = $this->customers_model->get_sdata();
$follow_channel = $this->customers_model->get_sdata('follow_channel');
$buy_time = $this->customers_model->get_sdata('btime');
$show_btime = [];
foreach ($buy_time as $key => $val) {
@@ -459,7 +474,8 @@ class Customers extends Wxapp
$data = [
'level' => $level,
'cfrom' => $cfrom,
'buy_time' => $show_btime
'buy_time' => $show_btime,
'follow_channel' => $follow_channel
];
return $data;
}
@@ -522,6 +538,8 @@ class Customers extends Wxapp
$a_id = intval($this->input_param('a_id'));//私域通活动id
$of_id = intval($this->input_param('of_id'));//线下来源一级
$of2_id = intval($this->input_param('of2_id'));//线下来源二级
$s_visit_time = $this->input_param('s_visit_time');//回访开始时间
$e_visit_time = $this->input_param('e_visit_time');//回访结束时间
!$page && $page = 1;
!$size && $size = 10;
@@ -561,6 +579,10 @@ class Customers extends Wxapp
$where['c_time >='] = strtotime($s_time);
$where['c_time <='] = strtotime(date('Y-m-d 23:59:59', strtotime($e_time)));
}
if ($s_visit_time && $e_visit_time) {
$where['visit_time >='] = $s_visit_time;
$where['visit_time <='] = $e_visit_time;
}
if (strlen($iscall)) {
if ($iscall) {
$where['cont_time!='] = '0000-00-00 00:00:00';
@@ -584,7 +606,7 @@ class Customers extends Wxapp
$lists = [];
if ($count) {
$fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,if_defeat
,of_id,of2_id,unionid';
,of_id,of2_id,unionid,visit_time';
$rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds);
//获取管理员
$admin_arr = array_unique(array_column($rows, 'admin_id'));
@@ -604,6 +626,7 @@ class Customers extends Wxapp
'建卡时间' => date('Y-m-d', $val['c_time']),
];
$val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time']));
$val['visit_time'] != '0000-00-00' && $other_data['计划回访时间'] = $val['visit_time'];
$other_data['销售顾问'] = isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '';
$tags = [$val['level'] . '级用户'];
$defeat = $orders_pay = '';
@@ -678,13 +701,85 @@ class Customers extends Wxapp
}
/**
* Notes:待回访客户列表
* Notes:客户回访记录列表
* Created on: 2021/10/21 14:27
* Created by: dengbw
* @param array $params
* @return array
*/
private function visit_lists($params = array())
private function visit_lists($params = [])
{
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$group_id = $this->session['group_id'];
$this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData');
$page = intval($params['page']);
$size = intval($params['size']);
$status = intval($params['status']);
!$page && $page = 1;
!$size && $size = 10;
$t_day = date('Y-m-d');
$where = array('a.biz_id' => $biz_id, 'a.status<>' => 2, 'b.t_day' => $t_day);
$params['level'] && $where['a.level'] = $params['level'];//等级
if ($status == 2) {//已跟进
$where['b.status'] = 2;
} else {
$where['b.status<>'] = 2;
}
$group_id == 1 && $where['a.admin_id'] = $this->session['uid'];
$count = $this->mdCustomerVisitData->count_visit($where);
$lists = [];
if ($count) {
$fileds = 'a.id,a.name,a.admin_id,a.mobile,a.level,a.is_top,a.cont_time,a.c_time,a.if_defeat,a.cf_title,a.of_id,a.of2_id
,a.of2_id';
$rows = $this->mdCustomerVisitData->select_visit($where, 'a.id desc', $page, $size, $fileds);
//获取管理员
$admin_arr = array_unique(array_column($rows, 'admin_id'));
$admins = [];
if ($admin_arr) {
$admin_ids = implode(',', $admin_arr);
$admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname');
}
foreach ($rows as $key => $val) {
$other_data = [
'客户来源' => $this->get_cfTitle($val),
'建卡时间' => date('Y-m-d', $val['c_time']),
];
$val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time']));
$other_data['销售顾问'] = isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '';
$tags = [$val['level'] . '级用户'];
$defeat = '';
if ($val['if_defeat'] == 1) {
$defeat = '战败申请中';
} else if ($val['if_defeat'] == 2) {
$defeat = '再战';
}
$lists[] = [
'id' => $val['id'],
'name' => $val['name'],
'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,
'tags' => $tags,
'defeat' => $defeat
];
}
}
$data = [
'list' => $lists,
'total' => $count
];
return $data;
}
/**
* Notes:待回访客户列表(已废除)
* Created on: 2021/10/21 14:27
* Created by: dengbw
* @param array $params
* @return array
*/
private function visit_lists_temp($params = array())
{
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$group_id = $this->session['group_id'];
+30 -9
View File
@@ -225,7 +225,7 @@ class User extends Wxapp
$this->load->model('receiver/order/receiver_orders_model', 'orders_model');
$this->load->model('receiver/order/receiver_orders_v2_model');
$this->load->model('receiver/order/receiver_order_signs_model', 'order_signs_model');
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
$this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData');
$where = [
"cont_time = '0000-00-00 00:00:00'" => null,
'biz_id' => $biz_id,
@@ -258,13 +258,8 @@ class User extends Wxapp
$loan_count = $this->orders_model->count($where);
//客户代办事项
$where_v = array('a.biz_id' => $biz_id, 'a.status<>' => 2,'b.contact' => 1, 'b.status' => 1);
$group_id == 1 && $where_v['a.admin_id'] = $uid;
$visit_count = $this->mdCustomersVisit->count_visit($where_v);
if ($group_id == 1) {
$customer_op_list = [
['title' => '待回访客户(人)', 'icon' => 'icon-dengji', 'total' => $visit_count, 'page' => '/pages/customer/filterList/index?visit=1&title=待回访客户'],
];
$customer_op_list = [];
} else {
//未派单客户
$where = ['admin_id' => 0, 'biz_id' => $biz_id, 'status>=' => 0];
@@ -275,7 +270,6 @@ class User extends Wxapp
$defeat_count = $this->customers_model->count(array('biz_id' => $biz_id, 'if_defeat' => 1, 'status>' => -1));
$customer_op_list = [
['title' => '待分配客户(人)', 'icon' => 'icon-daifenpei', 'total' => $unuse_count, 'page' => '/pages/customer/allot/index'],
['title' => '待回访客户(人)', 'icon' => 'icon-statistics-custom-4', 'total' => $visit_count, 'page' => '/pages/customer/filterList/index?visit=1&title=待回访客户'],
['title' => '战败申请(人)', 'icon' => 'icon-statistics-custom-5', 'total' => $defeat_count, 'page' => '/pages/customer/optDefeat/index'],
];
}
@@ -328,7 +322,33 @@ class User extends Wxapp
['title' => '发票开具', 'icon' => 'icon-kaipiao1', 'total' => $kp_total, 'page' => '/pages/order/filterList/index2?type=kp&title=发票开具'],
['title' => '交付确认', 'icon' => 'icon-jiaofu', 'total' => $ck_total, 'page' => '/pages/order/filterList/index2?type=jf&title=交付确认'],
];
$where_v = ['a.biz_id' => $biz_id, 'a.status<>' => 2, 'b.t_day' => date('Y-m-d')];
$where_c = ['biz_id' => $biz_id];
$group_id == 4 && $where_c['brand_id!='] = 3;
if ($group_id == 1) {
$where_v['b.sales_id'] = $uid;
$where_c['admin_id'] = $uid;
}
$h_num = $this->customers_model->count(array_merge($where_c, ['level' => 'H']));
$h_num_1 = $this->mdCustomerVisitData->count_visit(array_merge($where_v, ['a.level' => 'H', 'b.status<>' => 2]));
$h_num_2 = $this->mdCustomerVisitData->count_visit(array_merge($where_v, ['a.level' => 'H', 'b.status' => 2]));
$a_num = $this->customers_model->count(array_merge($where_c, ['level' => 'A']));
$a_num_1 = $this->mdCustomerVisitData->count_visit(array_merge($where_v, ['a.level' => 'A', 'b.status<>' => 2]));
$a_num_2 = $this->mdCustomerVisitData->count_visit(array_merge($where_v, ['a.level' => 'A', 'b.status' => 2]));
$b_num = $this->customers_model->count(array_merge($where_c, ['level' => 'B']));
$b_num_1 = $this->mdCustomerVisitData->count_visit(array_merge($where_v, ['a.level' => 'B', 'b.status<>' => 2]));
$b_num_2 = $this->mdCustomerVisitData->count_visit(array_merge($where_v, ['a.level' => 'B', 'b.status' => 2]));
$levelSt = [
['title' => 'H级客户', 'list' => [['title' => '总数', 'num' => $h_num, 'url' => ''], ['title' => '今日需跟进 >', 'num' => $h_num_1
, 'url' => '/pages/customer/filterList/index?level=H&status=1&visit=1&title=H级今日需跟进']
, ['title' => '今日已跟进 >', 'num' => $h_num_2, 'url' => '/pages/customer/filterList/index?level=H&status=2&visit=1&title=H级今日已跟进']]],
['title' => 'A级客户', 'list' => [['title' => '总数', 'num' => $a_num, 'url' => ''], ['title' => '今日需跟进 >', 'num' => $a_num_1
, 'url' => '/pages/customer/filterList/index?level=A&status=1&visit=1&title=A级今日需跟进']
, ['title' => '今日已跟进 >', 'num' => $a_num_2, 'url' => '/pages/customer/filterList/index?level=A&status=2&visit=1&title=A级今日已跟进']]],
['title' => 'B级客户', 'list' => [['title' => '总数', 'num' => $b_num, 'url' => ''], ['title' => '今日需跟进 >', 'num' => $b_num_1
, 'url' => '/pages/customer/filterList/index?level=B&status=1&visit=1&title=B级今日需跟进']
, ['title' => '今日已跟进 >', 'num' => $b_num_2, 'url' => '/pages/customer/filterList/index?level=A&status=2&visit=1&title=A级今日已跟进']]],
];
$data = [
'wl_count' => $wl_count,
'gz_count' => $gz_count,
@@ -336,6 +356,7 @@ class User extends Wxapp
'loan_count' => $loan_count,
'deallist' => $deallist,
'customer_op_list' => $customer_op_list,
'levelSt' => $levelSt,
];
return $data;
}
+6 -6
View File
@@ -64,32 +64,32 @@ class Biz extends Wxapp
$lists = [
[
'brand_id' => 1, 'cms_id' => 0, 'sort' => 0,
'title' => '东风 EX1 Pro', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '50700 ~ 57700'],
'title' => '东风 EX1 Pro', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '52700 ~ 59700'],
'img' => 'https://img.liche.cn/EX1.png'
],
[
'brand_id' => 4, 'cms_id' => 0, 'sort' => 0,
'title' => '哪吒V', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '68900 ~ 77900'],
'title' => '哪吒V', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '74900 ~ 93900'],
'img' => 'https://img.liche.cn/NZV.png'
],
[
'brand_id' => 4, 'cms_id' => 0, 'sort' => 0,
'title' => '哪吒U', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '105800 ~ 167800'],
'title' => '哪吒U', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '117800 ~ 179800'],
'img' => 'https://img.liche.cn/NZU.png'
],
[
'brand_id' => 5, 'cms_id' => 0, 'sort' => 0,
'title' => '零跑T03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '60800 ~ 84900'],
'title' => '零跑T03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '68900 ~ 85900'],
'img' => 'https://img.liche.cn/T03.png'
],
[
'brand_id' => 5, 'cms_id' => 0, 'sort' => 0,
'title' => '零跑C11', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '159800 ~ 214800'],
'title' => '零跑C11', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '179800 ~ 229800'],
'img' => 'https://img.liche.cn/C11.png'
],
[
'brand_id' => 7, 'cms_id' => 0, 'sort' => 0,
'title' => '合创Z03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '132800 ~ 168800'],
'title' => '合创Z03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '132800 ~ 178800'],
'img' => 'https://img.liche.cn/HCZ03.png'
],
];
@@ -16,7 +16,7 @@ class Customers_entity
}
/**
* Notes:添加日志/更新客户已回访
* Notes:添加日志/更新客户已跟进
* Created on: 2021/11/2 14:10
* Created by: dengbw
* @param $customer_id
@@ -35,10 +35,9 @@ class Customers_entity
if ($content) {
$result = $this->add_log($customer_id, $uid, $uname, $content, $type, $cf_platform, $imgs);
}
if ($visit && ($result || !$content)) {//更新客户已回访
$this->ci->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
$result = $this->ci->mdCustomersVisit->update(array('contact' => 2, 'status' => 2)
, array('c_id' => $customer_id, 'contact' => 1, 'status' => 1));
if ($visit && ($result || !$content)) {//更新客户已跟进
$this->ci->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData');
$result = $this->ci->mdCustomerVisitData->update(['status' => 2], ['c_id' => $customer_id, 'sales_id' => $uid, 't_day' => date('Y-m-d')]);
}
return $result;
}
@@ -0,0 +1,51 @@
<?php
/**
* Notes:客户回访记录
* Created on: 2022/05/23 17:15
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Receiver_customers_visit_data_model extends HD_Model
{
private $table_name = 'lc_receiver_customer_visit_data';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
//关联客户待回访
public function count_visit($where)
{
return $this->select_visit($where, '', '', '', '', 1);
}
public function select_visit($where = array(), $order = '', $page = 0, $page_size = 20, $fileds = '', $count = 0)
{
!$fileds && $fileds = 'a.*';
$this->db->select($fileds);
$this->db->from('lc_receiver_customers as a');
$this->db->join('lc_receiver_customer_visit_data as b', 'b.c_id = a.id', 'left');
if ($where) {
$this->db->where($where);
}
if ($count) {
return $this->db->count_all_results();
}
if ($order) {
$this->db->order_by($order);
}
if ($page) {
$offset = ($page - 1) * $page_size;
$limit = $page_size;
} else {
$offset = null;
$limit = null;
}
$this->db->limit($limit, $offset);
return $this->db->get()->result_array();
}
}
@@ -0,0 +1,19 @@
<?php
/**
* Notes:客户回访顾问统计
* Created on: 2022/05/23 17:15
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Receiver_customers_visit_sales_model extends HD_Model
{
private $table_name = 'lc_receiver_customer_visit_sales';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}