customers_527
This commit is contained in:
@@ -405,6 +405,7 @@ class Store extends HD_Controller
|
||||
public function batch()
|
||||
{
|
||||
$field = $this->input->post('field');
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
|
||||
if ($field === 'ifcheck') {
|
||||
$status = intval($this->input->post('value'));
|
||||
$ids = $this->input->post('id');
|
||||
@@ -412,7 +413,9 @@ class Store extends HD_Controller
|
||||
if (!$ids || count($ids) < 1) {
|
||||
$this->show_json(0, '请选择要操作的选项');
|
||||
}
|
||||
$where = array('id in(' . implode(',', $ids) . ')' => null);
|
||||
$ids_str = implode(',', $ids);
|
||||
$where = ["id in({$ids_str})" => null];
|
||||
$this->mdUsers->update(['status' => $status], ["biz_id in({$ids_str})" => null, 'group_id < 4' => null]);//更新用户下架
|
||||
} else {
|
||||
$id = intval($this->input->post('id'));
|
||||
$status = intval($this->input->post('value'));
|
||||
@@ -420,6 +423,7 @@ class Store extends HD_Controller
|
||||
$this->show_json(0, '参数错误');
|
||||
}
|
||||
$where['id'] = $id;
|
||||
$this->mdUsers->update(['status' => $status], ['biz_id' => $id, 'group_id < 4' => null]);//更新用户下架
|
||||
}
|
||||
$data['status'] = $status;
|
||||
$this->biz_model->update($data, $where);
|
||||
|
||||
@@ -120,7 +120,6 @@ class Licheb extends HD_Controller
|
||||
$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'));
|
||||
@@ -139,26 +138,20 @@ class Licheb extends HD_Controller
|
||||
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]));
|
||||
$u_follows = $this->mdCustomers->count(["cont_time = '0000-00-00 00:00:00'" => null,
|
||||
'admin_id' => $sales_id, 'biz_id' => $biz_id, 'status in(0,1)' => null]);
|
||||
$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, 'u_follows' => $u_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);
|
||||
}
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,66 +219,64 @@ class Licheb extends HD_Controller
|
||||
foreach ($res as $key => $value) {
|
||||
$sale_id = $id = $value['id'];
|
||||
$biz_id = intval($value['biz_id']);
|
||||
if ($map_biz[$biz_id]['status'] == 1) {//判断门店状态
|
||||
$re_log = $this->mdUsersLog->get(['log_date' => $log_date, 'sale_id' => $sale_id, 'biz_id' => $biz_id]);
|
||||
if (!$re_log) {//判断当天是否已加入
|
||||
$s_time = strtotime($log_date . ' 00:00:00');
|
||||
$e_time = strtotime($log_date . ' 23:59:59');
|
||||
$city_id = intval($map_biz[$biz_id]['city_id']);
|
||||
$type = intval($map_biz[$biz_id]['type']);
|
||||
$c_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'log' => '客户到店', 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)');
|
||||
$a_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]
|
||||
);
|
||||
$t_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 5, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]
|
||||
);
|
||||
$follows = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type in(0,1,2)' => null, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)'
|
||||
);
|
||||
$defeats = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 7, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]
|
||||
);
|
||||
$orders = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0,
|
||||
'order_time>=' => "{$log_date} 00:00:00", 'order_time<=' => "{$log_date} 23:59:59"]
|
||||
);
|
||||
$bills = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0,
|
||||
'bill_time>=' => "{$log_date} 00:00:00", 'bill_time<=' => "{$log_date} 23:59:59"]
|
||||
);
|
||||
$qy_adds = $qy_dels = $customers = 0;
|
||||
if ($value['userid']) {
|
||||
$qy_adds = $this->mdWechatqyLog->count(['userid' => $value['userid'], 'change_type' => 'add_external_contact'
|
||||
, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
$qy_dels = $this->mdWechatqyLog->count(['userid' => $value['userid'], "change_type in('del_external_contact','del_follow_user')" => null
|
||||
, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
}
|
||||
$add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id, 'c_num' => $c_num
|
||||
, 'a_num' => $a_num, 't_num' => $t_num, 'orders' => $orders, 'bills' => $bills, 'follows' => $follows, 'defeats' => $defeats
|
||||
, 'log_date' => $log_date, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'c_time' => time()];
|
||||
$customer_json = '';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$customer_num1 = $this->mdCustomers->count(['of_id' => $key1, 'admin_id' => $sale_id
|
||||
, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
if ($customer_num1) {//一级
|
||||
$customers += $customer_num1;
|
||||
$add_item["customer_{$key1}"] = $customer_num1;
|
||||
$list = '';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$customer_num2 = $this->mdCustomers->count(['of_id' => $key1, 'of2_id' => $key2, 'admin_id' => $sale_id
|
||||
, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
if ($customer_num2) {//二级
|
||||
$list[$key2] = ['name' => $value2, 'num' => $customer_num2];
|
||||
}
|
||||
}
|
||||
$customer_json[$key1] = ['name' => $value1['name'], 'num' => $customer_num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
$customer_json && $add_item['customer_json'] = json_encode($customer_json, JSON_UNESCAPED_UNICODE);
|
||||
$add_item['customers'] = $customers;
|
||||
$add_id = $this->mdUsersLog->add($add_item);
|
||||
$add_id && $log[] = array('id' => $sale_id, 'addDate' => $add_item);
|
||||
$re_log = $this->mdUsersLog->get(['log_date' => $log_date, 'sale_id' => $sale_id, 'biz_id' => $biz_id]);
|
||||
if (!$re_log) {//判断当天是否已加入
|
||||
$s_time = strtotime($log_date . ' 00:00:00');
|
||||
$e_time = strtotime($log_date . ' 23:59:59');
|
||||
$city_id = intval($map_biz[$biz_id]['city_id']);
|
||||
$type = intval($map_biz[$biz_id]['type']);
|
||||
$c_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'log' => '客户到店', 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)');
|
||||
$a_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]
|
||||
);
|
||||
$t_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 5, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]
|
||||
);
|
||||
$follows = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type in(0,1,2)' => null, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)'
|
||||
);
|
||||
$defeats = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 7, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
|
||||
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]
|
||||
);
|
||||
$orders = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0,
|
||||
'order_time>=' => "{$log_date} 00:00:00", 'order_time<=' => "{$log_date} 23:59:59"]
|
||||
);
|
||||
$bills = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0,
|
||||
'bill_time>=' => "{$log_date} 00:00:00", 'bill_time<=' => "{$log_date} 23:59:59"]
|
||||
);
|
||||
$qy_adds = $qy_dels = $customers = 0;
|
||||
if ($value['userid']) {
|
||||
$qy_adds = $this->mdWechatqyLog->count(['userid' => $value['userid'], 'change_type' => 'add_external_contact'
|
||||
, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
$qy_dels = $this->mdWechatqyLog->count(['userid' => $value['userid'], "change_type in('del_external_contact','del_follow_user')" => null
|
||||
, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
}
|
||||
$add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id, 'c_num' => $c_num
|
||||
, 'a_num' => $a_num, 't_num' => $t_num, 'orders' => $orders, 'bills' => $bills, 'follows' => $follows, 'defeats' => $defeats
|
||||
, 'log_date' => $log_date, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'c_time' => time()];
|
||||
$customer_json = '';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$customer_num1 = $this->mdCustomers->count(['of_id' => $key1, 'admin_id' => $sale_id
|
||||
, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
if ($customer_num1) {//一级
|
||||
$customers += $customer_num1;
|
||||
$add_item["customer_{$key1}"] = $customer_num1;
|
||||
$list = '';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$customer_num2 = $this->mdCustomers->count(['of_id' => $key1, 'of2_id' => $key2, 'admin_id' => $sale_id
|
||||
, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
if ($customer_num2) {//二级
|
||||
$list[$key2] = ['name' => $value2, 'num' => $customer_num2];
|
||||
}
|
||||
}
|
||||
$customer_json[$key1] = ['name' => $value1['name'], 'num' => $customer_num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
$customer_json && $add_item['customer_json'] = json_encode($customer_json, JSON_UNESCAPED_UNICODE);
|
||||
$add_item['customers'] = $customers;
|
||||
$add_id = $this->mdUsersLog->add($add_item);
|
||||
$add_id && $log[] = array('id' => $sale_id, 'addDate' => $add_item);
|
||||
}
|
||||
}
|
||||
$redis->save($redisKey, $id, 24 * 3600);//保存最后id
|
||||
|
||||
@@ -16,6 +16,48 @@ class Temp extends HD_Controller
|
||||
$this->log_file = 'temp.log';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新下架门店人员
|
||||
* Created on: 2022/5/27 11:58
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/temp/biz_users
|
||||
* https://api.liche.cn/plan/temp/biz_users
|
||||
*/
|
||||
public function biz_users()
|
||||
{
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
|
||||
$param = $this->input->get();
|
||||
$param['page'] = intval($param['page']);
|
||||
$param['size'] = intval($param['size']);
|
||||
!$param['size'] && $param['size'] = 100;
|
||||
!$param['page'] && $param['page'] = 1;
|
||||
$counts = intval($param['counts']);
|
||||
ob_start(); //打开缓冲区
|
||||
$where = ["status<>" => 1];
|
||||
$res = $this->mdBiz->select($where, 'id ASC', $param['page'], $param['size'], 'id,status');
|
||||
if (!$res) {
|
||||
echo '<br>本次更新完成了:';
|
||||
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
|
||||
echo '<br><br><a href="/plan/temp/biz_users">点击将再次更新>>></a>';
|
||||
exit;
|
||||
}
|
||||
$log = array();
|
||||
foreach ($res as $key => $value) {
|
||||
$ret = $this->mdUsers->update(['status' => $value['status']], ['biz_id' => $value['id'], 'group_id < 4' => null]);//更新用户下架
|
||||
if ($ret == 1) {
|
||||
$log[] = ['id' => $value['id']];
|
||||
$counts++;
|
||||
}
|
||||
}
|
||||
echo '<br>成功更新:';
|
||||
$log && print_r($log);
|
||||
echo '<br><br>数据库获取:';
|
||||
echo json_encode($res, JSON_UNESCAPED_UNICODE);
|
||||
header('refresh:3;url=/plan/temp/biz_users?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
|
||||
ob_end_flush();//输出全部内容到浏览器
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新战败客户到店
|
||||
* Created on: 2022/3/09 11:58
|
||||
@@ -46,7 +88,7 @@ class Temp extends HD_Controller
|
||||
$brand_ids = $value['brand_ids'];
|
||||
if ($brand_ids) {
|
||||
if (!strstr($brand_ids, '0,')) {
|
||||
$brand_ids = '0,'.$brand_ids;
|
||||
$brand_ids = '0,' . $brand_ids;
|
||||
$ret = $this->mdTemplate->update(['brand_ids' => $brand_ids], ['id' => $value['id']]);
|
||||
if ($ret == 1) {
|
||||
$log[] = ['id' => $value['id'], 'brand_ids' => $brand_ids];
|
||||
|
||||
@@ -736,7 +736,7 @@ class Customers extends Wxapp
|
||||
$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.status';
|
||||
,a.of_id,a.of2_id,a.status,a.visit_time';
|
||||
$rows = $this->mdCustomerVisitData->select_visit($where, 'a.id desc', $page, $size, $fileds);
|
||||
//获取管理员
|
||||
$admin_arr = array_unique(array_column($rows, 'admin_id'));
|
||||
@@ -752,6 +752,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 = '';
|
||||
|
||||
@@ -226,14 +226,6 @@ class User extends Wxapp
|
||||
$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_data_model', 'mdCustomerVisitData');
|
||||
$where = [
|
||||
"cont_time = '0000-00-00 00:00:00'" => null,
|
||||
'biz_id' => $biz_id,
|
||||
'status in(0,1)' => null
|
||||
];
|
||||
$group_id == 1 && $where['admin_id'] = $uid;
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$wl_count = $this->customers_model->count($where);
|
||||
$where = [
|
||||
'status>' => -1,
|
||||
'is_top' => 1,
|
||||
@@ -349,8 +341,9 @@ class User extends Wxapp
|
||||
, ['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级今日已跟进']]],
|
||||
];
|
||||
$wl_num = $this->mdCustomerVisitData->count_visit($where_v);
|
||||
$data = [
|
||||
'wl_count' => ['title' => '录入未跟进(人)', 'num' => $wl_count, 'url' => '/pages/customer/filterList/index?iscall=0&title=录入未跟进'],
|
||||
'wl_count' => ['title' => '待跟进客户(人)', 'num' => $wl_num, 'url' => '/pages/customer/filterList/index?status=1&visit=1&title=待跟进客户'],
|
||||
'gz_count' => ['title' => '特别关注客户(人)', 'num' => $gz_count, 'url' => '/pages/customer/filterList/index?istop=1&title=特别关注客户'],
|
||||
'sign_count' => $sign_count,
|
||||
'loan_count' => $loan_count,
|
||||
|
||||
Reference in New Issue
Block a user