userslog_712
This commit is contained in:
@@ -20,7 +20,7 @@ class Main extends HD_Controller
|
||||
$this->load->model('app/material/Material_biz_model', 'mdMaterialBiz');
|
||||
$this->load->model('topics/topics_model', 'mdTopics');
|
||||
$this->load->model('live/Live_polyv_session_model', 'mdPolyvSession');
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$this->load->model('app/licheb/app_licheb_bizs_log_model', 'mdBizsLog');
|
||||
$this->load->model('app/licheb/syt_live_model', 'mdSytLive');
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ class Main extends HD_Controller
|
||||
array('name' => '查看详情', 'url' => '/live/polyv'),
|
||||
),
|
||||
);
|
||||
$value = $this->mdUsersLog->count();
|
||||
$value = $this->mdBizsLog->count();
|
||||
$list[] = array(
|
||||
'title' => '顾问日志',
|
||||
'title' => '门店日志',
|
||||
'value' => $value,
|
||||
'btns' => array(
|
||||
array('name' => '查看详情', 'url' => 'app/licheb/userslog'),
|
||||
|
||||
@@ -15,6 +15,7 @@ class Userslog extends HD_Controller
|
||||
parent::__construct();
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$this->load->model('app/licheb/app_licheb_bizs_log_model', 'mdBizsLog');
|
||||
$this->load->model('receiver/receiver_customers_visit_sales_model', 'mdCustomerVisitSales');
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
@@ -27,6 +28,17 @@ class Userslog extends HD_Controller
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
$params['size'] = $params['size'] ? intval($params['size']) : 20;
|
||||
$data = $this->dataBizSelect($params);
|
||||
$data['typeAry'] = $this->mdBiz->type_ary();
|
||||
$this->data = $data;
|
||||
$this->show_view('app/licheb/userslog/lists', true);
|
||||
}
|
||||
|
||||
public function lists_users()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
@@ -36,21 +48,17 @@ class Userslog extends HD_Controller
|
||||
$view = 'app/licheb/userslog/lists_visit';
|
||||
$data = $this->visitSelect($params);
|
||||
} else {
|
||||
$view = 'app/licheb/userslog/lists';
|
||||
$data = $this->dataSelect($params);
|
||||
$view = 'app/licheb/userslog/lists_users';
|
||||
$data = $this->dataUsersSelect($params);
|
||||
}
|
||||
$data['typeAry'] = $this->mdBiz->type_ary();
|
||||
$data['tabAry'] = $this->tabAry;
|
||||
$this->data = $data;
|
||||
$this->show_view($view, true);
|
||||
}
|
||||
|
||||
private function dataSelect($params)
|
||||
private function dataBizSelect($params)
|
||||
{
|
||||
$lists = $where = [];
|
||||
if ($params['uname']) {
|
||||
$where["sale_id in(select id from lc_app_licheb_users where uname like '%{$params['uname']}%')"] = null;
|
||||
}
|
||||
if ($params['biz_id']) {
|
||||
$where['biz_id'] = $params['biz_id'];
|
||||
} else if ($params['city_id']) {
|
||||
@@ -79,57 +87,168 @@ class Userslog extends HD_Controller
|
||||
$time[0] && $where["log_date>="] = $time[0];
|
||||
$time[1] && $where["log_date<="] = $time[1];
|
||||
}
|
||||
$total = $this->mdBizsLog->count($where);
|
||||
if ($total) {
|
||||
$res = $this->mdBizsLog->select($where, "id desc", $params['page'], $params['size']);
|
||||
if ($res) {
|
||||
$str_ids = implode(',', array_unique(array_column($res, 'biz_id')));
|
||||
$map_biz = $this->mdBiz->map('id', 'biz_name', ["id in ({$str_ids})" => null]);
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
foreach ($res as $v) {
|
||||
$biz_name = $biz_type = $customer_info = $c_num_info = $order_info = '';
|
||||
$customers = $c_num = $orders = 0;
|
||||
$map_biz[$v['biz_id']] && $biz_name = $params['size'] == 10000 ? $map_biz[$v['biz_id']] : "<a href=\"javascript:void(0);\"
|
||||
data-open=\"/app/licheb/userslog/lists_users?tab=1&biz_id={$v['biz_id']}&time={$v['log_date']} ~ {$v['log_date']}\">
|
||||
{$map_biz[$v['biz_id']]}</a>";
|
||||
$temp = ['biz_name' => $biz_name, 'defeats' => $v['defeats']
|
||||
, 't_num' => $v['t_num'], 'orders' => $v['orders']
|
||||
, 'bills' => $v['bills'], 'reassigns' => $v['reassigns'], 'receives' => $v['receives']
|
||||
, 'qy_adds' => $v['qy_adds'], 'log_date' => $v['log_date']];
|
||||
$customer_json = $v['customer_json'] ? json_decode($v['customer_json'], true) : [];
|
||||
$c_num_json = $v['customer_json'] ? json_decode($v['c_num_json'], true) : [];
|
||||
$order_json = $v['customer_json'] ? json_decode($v['order_json'], true) : [];
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$nums = intval($v['customer_' . $key1]);
|
||||
$nums_c_num = intval($v['c_num_' . $key1]);
|
||||
$nums_orders = intval($v['order_' . $key1]);
|
||||
if ($nums) {
|
||||
$customers += $nums;
|
||||
if ($params['size'] != 10000) {
|
||||
if ($customer_info) {
|
||||
$customer_info = $customer_info . '+' . $value1['name'] . '(' . $nums . ')';
|
||||
} else {
|
||||
$customer_info = $value1['name'] . '(' . $nums . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nums_c_num) {
|
||||
$c_num += $nums_c_num;
|
||||
if ($params['size'] != 10000) {
|
||||
if ($c_num_info) {
|
||||
$c_num_info = $c_num_info . '+' . $value1['name'] . '(' . $nums_c_num . ')';
|
||||
} else {
|
||||
$c_num_info = $value1['name'] . '(' . $nums_c_num . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nums_orders) {
|
||||
$orders += $nums_orders;
|
||||
if ($params['size'] != 10000) {
|
||||
if ($order_info) {
|
||||
$order_info = $order_info . '+' . $value1['name'] . '(' . $nums_orders . ')';
|
||||
} else {
|
||||
$order_info = $value1['name'] . '(' . $nums_orders . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($params['size'] == 10000) {//导出使用
|
||||
$temp['customer_' . $key1] = $nums;
|
||||
$temp['c_num_' . $key1] = $nums_c_num;
|
||||
$temp['order_' . $key1] = $nums_orders;
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$temp['customer_' . $key2] = intval($customer_json[$key1]['list'][$key2]['num']);
|
||||
$temp['c_num_' . $key2] = intval($c_num_json[$key1]['list'][$key2]['num']);
|
||||
$temp['order_' . $key2] = intval($order_json[$key1]['list'][$key2]['num']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$customer_info && $customers = $customers . '=' . $customer_info;
|
||||
$c_num_info && $c_num = $c_num . '=' . $c_num_info;
|
||||
$order_info && $orders = $orders . '=' . $order_info;
|
||||
$temp['customers'] = $customers;
|
||||
$temp['c_num'] = $c_num;
|
||||
$temp['orders'] = $orders;
|
||||
$lists[] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($params['size'] != 10000) {
|
||||
$sum = $this->mdUsersLog->sum('customers', $where);
|
||||
$menus[] = ['title' => "客户数", 'value' => intval($sum['customers']), 'tag' => '人'];
|
||||
$sum_c = $this->mdUsersLog->sum('c_num', $where);
|
||||
$menus[] = ['title' => "进店人数", 'value' => intval($sum_c['c_num']), 'tag' => '人'];
|
||||
$sum = $this->mdUsersLog->sum('orders', $where);
|
||||
$menus[] = ['title' => "订单数", 'value' => intval($sum['orders']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('t_num', $where);
|
||||
$menus[] = ['title' => "试驾数", 'value' => intval($sum['t_num']), 'tag' => '次'];
|
||||
$sum = $this->mdUsersLog->sum('defeats', $where);
|
||||
$menus[] = ['title' => "战败数", 'value' => intval($sum['defeats']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('bills', $where);
|
||||
$menus[] = ['title' => "开票数", 'value' => intval($sum['bills']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('qy_adds', $where);
|
||||
$menus[] = ['title' => "企微数", 'value' => intval($sum['qy_adds']), 'tag' => '人'];
|
||||
$sum = $this->mdUsersLog->sum('reassigns', $where);
|
||||
$menus[] = ['title' => "改派数", 'value' => intval($sum['reassigns']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('receives', $where);
|
||||
$menus[] = ['title' => "接收数", 'value' => intval($sum['receives']), 'tag' => '个'];
|
||||
$data['menus'] = $menus;
|
||||
}
|
||||
$data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total);
|
||||
$data['lists'] = $lists;
|
||||
$data['params'] = $params;
|
||||
$data['_title'] = "门店日志";
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function dataUsersSelect($params)
|
||||
{
|
||||
$_title = '顾问日志';
|
||||
$lists = $where = [];
|
||||
if ($params['uname']) {
|
||||
$where["sale_id in(select id from lc_app_licheb_users where uname like '%{$params['uname']}%')"] = null;
|
||||
}
|
||||
if ($params['biz_id']) {
|
||||
$where['biz_id'] = $params['biz_id'];
|
||||
$re_biz = $this->mdBiz->get(['id' => $params['biz_id']]);
|
||||
$re_biz && $_title = $re_biz['biz_name'] . '_顾问日志';
|
||||
}
|
||||
if ($params['time']) {
|
||||
$time = explode(' ~ ', $params['time']);
|
||||
$time[0] && $where["log_date>="] = $time[0];
|
||||
$time[1] && $where["log_date<="] = $time[1];
|
||||
}
|
||||
$total = $this->mdUsersLog->count($where);
|
||||
if ($total) {
|
||||
$res = $this->mdUsersLog->select($where, "id desc", $params['page'], $params['size']);
|
||||
$sale_ids = $biz_ids = [];
|
||||
$res = $this->mdUsersLog->select($where, "log_date desc,id desc", $params['page'], $params['size']);
|
||||
$sale_ids = [];
|
||||
foreach ($res as $v) {
|
||||
$v['sale_id'] && !in_array($v['sale_id'], $sale_ids) && $sale_ids[] = $v['sale_id'];
|
||||
$v['biz_id'] && !in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
|
||||
}
|
||||
$map_sale = $map_biz = $map_city = [];
|
||||
$map_sale = [];
|
||||
if ($sale_ids) {
|
||||
$str_ids = implode(',', $sale_ids);
|
||||
$map_sale = $this->mdUsers->map('id', 'uname', ["id in ({$str_ids})" => null]);
|
||||
}
|
||||
if ($biz_ids) {
|
||||
$str_ids = implode(',', $biz_ids);
|
||||
$map_biz = $this->mdBiz->map('id', 'biz_name,type', ["id in ({$str_ids})" => null]);
|
||||
}
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$typeAry = $this->mdBiz->type_ary();
|
||||
foreach ($res as $v) {
|
||||
$uname = $biz_name = $biz_type = $customers_info = '';
|
||||
$customers = 0;
|
||||
$map_sale[$v['sale_id']] && $uname = $map_sale[$v['sale_id']];
|
||||
$map_biz[$v['biz_id']]['biz_name'] && $biz_name = $map_biz[$v['biz_id']]['biz_name'];
|
||||
$map_biz[$v['biz_id']]['type'] && $biz_type = $typeAry[$map_biz[$v['biz_id']]['type']];
|
||||
$temp = ['uname' => $uname, 'biz_type' => $biz_type, 'biz_name' => $biz_name, 'defeats' => $v['defeats']
|
||||
, 'c_num' => $v['c_num'], 'a_num' => $v['a_num'], 't_num' => $v['t_num'], 'orders' => $v['orders']
|
||||
, 'bills' => $v['bills'], 'follows' => $v['follows'], 'reassigns' => $v['reassigns'], 'receives' => $v['receives']
|
||||
$uname = $map_sale[$v['sale_id']] ? $map_sale[$v['sale_id']] : '';
|
||||
$temp = ['uname' => $uname, 't_num' => $v['t_num'], 'defeats' => $v['defeats'], 'bills' => $v['bills']
|
||||
, 'qy_adds' => $v['qy_adds'], 'qy_dels' => $v['qy_dels'], 'log_date' => $v['log_date']];
|
||||
$customer_json = $v['customer_json'] ? json_decode($v['customer_json'], true) : [];
|
||||
$c_num_json = $v['customer_json'] ? json_decode($v['c_num_json'], true) : [];
|
||||
$order_json = $v['customer_json'] ? json_decode($v['order_json'], true) : [];
|
||||
$customers = $c_num = $orders = 0;
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$nums = intval($v['customer_' . $key1]);
|
||||
$nums_c_num = intval($v['c_num_' . $key1]);
|
||||
$nums_orders = intval($v['order_' . $key1]);
|
||||
$nums && $customers += $nums;
|
||||
$nums_c_num && $c_num += $nums_c_num;
|
||||
$nums_orders && $orders += $nums_orders;
|
||||
if ($params['size'] == 10000) {//导出使用
|
||||
$temp['customer_' . $key1] = $nums;
|
||||
$temp['c_num_' . $key1] = $nums_c_num;
|
||||
$temp['order_' . $key1] = $nums_orders;
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$temp['customer_' . $key2] = intval($customer_json[$key1]['list'][$key2]['num']);
|
||||
$temp['c_num_' . $key2] = intval($c_num_json[$key1]['list'][$key2]['num']);
|
||||
$temp['order_' . $key2] = intval($order_json[$key1]['list'][$key2]['num']);
|
||||
}
|
||||
}
|
||||
if ($nums) {
|
||||
$customers += $nums;
|
||||
// if ($params['size'] != 10000) {
|
||||
// if ($customers_info) {
|
||||
// $customers_info = $customers_info . '+' . $value1['name'] . '(' . $nums . ')';
|
||||
// } else {
|
||||
// $customers_info = $value1['name'] . '(' . $nums . ')';
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
//$customers_info && $customers = $customers . '=' . $customers_info;
|
||||
$temp['customers'] = $customers;
|
||||
$temp['c_num'] = $c_num;
|
||||
$temp['orders'] = $orders;
|
||||
$lists[] = $temp;
|
||||
}
|
||||
}
|
||||
@@ -137,22 +256,15 @@ class Userslog extends HD_Controller
|
||||
$sum = $this->mdUsersLog->sum('customers', $where);
|
||||
$menus[] = ['title' => "客户数", 'value' => intval($sum['customers']), 'tag' => '人'];
|
||||
$sum_c = $this->mdUsersLog->sum('c_num', $where);
|
||||
$sum = $this->mdUsersLog->sum('a_num', $where);
|
||||
$menus[] = ['title' => "进店人数/次数", 'value' => intval($sum_c['c_num']) . '人 / ' . intval($sum['a_num']), 'tag' => '次'];
|
||||
$sum = $this->mdUsersLog->sum('t_num', $where);
|
||||
$menus[] = ['title' => "试驾数", 'value' => intval($sum['t_num']), 'tag' => '次'];
|
||||
$sum = $this->mdUsersLog->sum('follows', $where);
|
||||
$menus[] = ['title' => "跟进数", 'value' => intval($sum['follows']), 'tag' => '个'];
|
||||
$menus[] = ['title' => "进店人数", 'value' => intval($sum_c['c_num']), 'tag' => '人'];
|
||||
$sum = $this->mdUsersLog->sum('orders', $where);
|
||||
$menus[] = ['title' => "订单数", 'value' => intval($sum['orders']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('t_num', $where);
|
||||
$menus[] = ['title' => "试驾数", 'value' => intval($sum['t_num']), 'tag' => '次'];
|
||||
$sum = $this->mdUsersLog->sum('defeats', $where);
|
||||
$menus[] = ['title' => "战败数", 'value' => intval($sum['defeats']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('bills', $where);
|
||||
$menus[] = ['title' => "开票数", 'value' => intval($sum['bills']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('reassigns', $where);
|
||||
$menus[] = ['title' => "改派数", 'value' => intval($sum['reassigns']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('receives', $where);
|
||||
$menus[] = ['title' => "接收数", 'value' => intval($sum['receives']), 'tag' => '个'];
|
||||
$sum = $this->mdUsersLog->sum('qy_adds', $where);
|
||||
$menus[] = ['title' => "新增企微", 'value' => intval($sum['qy_adds']), 'tag' => '人'];
|
||||
$sum = $this->mdUsersLog->sum('qy_dels', $where);
|
||||
@@ -162,35 +274,21 @@ class Userslog extends HD_Controller
|
||||
$data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total);
|
||||
$data['lists'] = $lists;
|
||||
$data['params'] = $params;
|
||||
$data['_title'] = "顾问日志";
|
||||
$data['_title'] = $_title;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function visitSelect($params)
|
||||
{
|
||||
$_title = '顾问日志';
|
||||
$lists = $where = [];
|
||||
if ($params['uname']) {
|
||||
$where["sales_id in(select id from lc_app_licheb_users where uname like '%{$params['uname']}%')"] = null;
|
||||
}
|
||||
if ($params['biz_id']) {
|
||||
$where['biz_id'] = $params['biz_id'];
|
||||
} else if ($params['city_id'] || $params['type']) {
|
||||
$where_biz['status'] = 1;
|
||||
$params['type'] && $where_biz['type'] = $params['type'];
|
||||
$params['city_id'] && $where_biz['city_id'] = $params['city_id'];
|
||||
$params['county_id'] && $where_biz['county_id'] = $params['county_id'];
|
||||
$res_biz = $this->mdBiz->select($where_biz, 'id desc', 0, 0, 'id');
|
||||
if ($res_biz) {
|
||||
$str_ids = implode(',', array_column($res_biz, 'id'));
|
||||
$where["biz_id in ({$str_ids})"] = null;
|
||||
} else {
|
||||
$where['biz_id'] = -2;
|
||||
}
|
||||
} else {
|
||||
$params['city_id'] = '';
|
||||
$params['county_id'] = '';
|
||||
$params['biz_id'] = '';
|
||||
$params['type'] = '';
|
||||
$re_biz = $this->mdBiz->get(['id' => $params['biz_id']]);
|
||||
$re_biz && $_title = $re_biz['biz_name'] . '_顾问日志';
|
||||
}
|
||||
if ($params['time']) {
|
||||
$time = explode(' ~ ', $params['time']);
|
||||
@@ -199,27 +297,21 @@ class Userslog extends HD_Controller
|
||||
}
|
||||
$total = $this->mdCustomerVisitSales->count($where);
|
||||
if ($total) {
|
||||
$res = $this->mdCustomerVisitSales->select($where, "id desc", $params['page'], $params['size']);
|
||||
$sales_ids = $biz_ids = [];
|
||||
$res = $this->mdCustomerVisitSales->select($where, "t_day desc,id desc", $params['page'], $params['size']);
|
||||
$sales_ids = [];
|
||||
foreach ($res as $v) {
|
||||
$v['sales_id'] && !in_array($v['sales_id'], $sales_ids) && $sales_ids[] = $v['sales_id'];
|
||||
$v['biz_id'] && !in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
|
||||
}
|
||||
$map_sale = $map_biz = $map_city = [];
|
||||
$map_sale = [];
|
||||
if ($sales_ids) {
|
||||
$str_ids = implode(',', $sales_ids);
|
||||
$map_sale = $this->mdUsers->map('id', 'uname', ["id in ({$str_ids})" => null]);
|
||||
}
|
||||
if ($biz_ids) {
|
||||
$str_ids = implode(',', $biz_ids);
|
||||
$map_biz = $this->mdBiz->map('id', 'biz_name,type', ["id in ({$str_ids})" => null]);
|
||||
}
|
||||
foreach ($res as $v) {
|
||||
$uname = $biz_name = '';
|
||||
$uname = '';
|
||||
$map_sale[$v['sales_id']] && $uname = $map_sale[$v['sales_id']];
|
||||
$map_biz[$v['biz_id']]['biz_name'] && $biz_name = $map_biz[$v['biz_id']]['biz_name'];
|
||||
$follows = $v['t_follows'] + $v['h_follows'] + $v['w_follows'];
|
||||
$temp = ['uname' => $uname, 'biz_name' => $biz_name, 'follows' => $follows, 't_follows' => $v['t_follows']
|
||||
$temp = ['uname' => $uname, 'follows' => $follows, 't_follows' => $v['t_follows']
|
||||
, 'h_follows' => $v['h_follows'], 'w_follows' => $v['w_follows'], 't_day' => $v['t_day']];
|
||||
$lists[] = $temp;
|
||||
}
|
||||
@@ -238,7 +330,7 @@ class Userslog extends HD_Controller
|
||||
$data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total);
|
||||
$data['lists'] = $lists;
|
||||
$data['params'] = $params;
|
||||
$data['_title'] = "顾问日志";
|
||||
$data['_title'] = $_title;
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -268,35 +360,76 @@ class Userslog extends HD_Controller
|
||||
$params = $this->input->get();
|
||||
$params['page'] = 1;
|
||||
$params['size'] = 10000;
|
||||
$data = $indexs = array();
|
||||
if ($params['tab'] == 2) {
|
||||
$res = $this->visitSelect($params);
|
||||
$indexs = ['biz_name' => '门店', 'uname' => '顾问', 'follows' => '计划跟进数', 'h_follows' => '已跟进数'
|
||||
, 't_follows' => '今日新增未跟进数', 'w_follows' => '逾期未跟进数', 't_day' => '日期'];
|
||||
} else {
|
||||
$res = $this->dataSelect($params);
|
||||
$data = $indexs = [];
|
||||
if ($params['tab'] == 1) {//客户统计
|
||||
$res = $this->dataUsersSelect($params);
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$indexs = ['biz_name' => '门店', 'uname' => '顾问', 'customers' => '客户数'];
|
||||
$indexs = ['uname' => '顾问', 'customers' => '客户数︾'];
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['customer_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['customer_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['c_num'] = '进店人数';
|
||||
$indexs['a_num'] = '进店次数';
|
||||
$indexs['c_num'] = '进店人数︾';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['c_num_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['c_num_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['orders'] = '订单数︾';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['order_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['order_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['t_num'] = '试驾数';
|
||||
$indexs['follows'] = '跟进数';
|
||||
$indexs['orders'] = '订单数';
|
||||
$indexs['defeats'] = '战败数';
|
||||
$indexs['bills'] = '开票数';
|
||||
$indexs['reassigns'] = '改派数';
|
||||
$indexs['receives'] = '接收数';
|
||||
$indexs['qy_adds'] = '新增企微';
|
||||
$indexs['qy_dels'] = '删除企微';
|
||||
$indexs['log_date'] = '日期';
|
||||
$fileName = $res['_title'] . '_' . $this->tabAry[$params['tab']];
|
||||
} else if ($params['tab'] == 2) {//回访统计
|
||||
$res = $this->visitSelect($params);
|
||||
$indexs = ['biz_name' => '门店', 'uname' => '顾问', 'follows' => '计划跟进数', 'h_follows' => '已跟进数'
|
||||
, 't_follows' => '今日新增未跟进数', 'w_follows' => '逾期未跟进数', 't_day' => '日期'];
|
||||
$fileName = $res['_title'] . '_' . $this->tabAry[$params['tab']];
|
||||
} else {
|
||||
$res = $this->dataBizSelect($params);
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$indexs = ['biz_name' => '门店', 'customers' => '客户数︾'];
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['customer_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['customer_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['c_num'] = '进店人数︾';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['c_num_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['c_num_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['orders'] = '订单数︾';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['order_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['order_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['t_num'] = '试驾数';
|
||||
$indexs['defeats'] = '战败数';
|
||||
$indexs['bills'] = '开票数';
|
||||
$indexs['qy_adds'] = '企微数';
|
||||
$indexs['reassigns'] = '改派数';
|
||||
$indexs['receives'] = '接收数';
|
||||
$indexs['log_date'] = '日期';
|
||||
$fileName = $res['_title'];
|
||||
}
|
||||
$fileName = $res['_title'] . '_' . $this->tabAry[$params['tab']];
|
||||
foreach ($res['lists'] as $key => $value) {
|
||||
$data[] = $value;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;margin-bottom: 20px;">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<? foreach ($tabAry as $key => $val) { ?>
|
||||
<li role="presentation"
|
||||
class="<?= strlen($params['tab']) && $params['tab'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);" data-open="/app/licheb/userslog?tab=<?= $key ?>">
|
||||
<?= $val ?>
|
||||
</a>
|
||||
</li>
|
||||
<? } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<? foreach ($menus as $key => $value) { ?>
|
||||
@@ -22,14 +10,7 @@
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="app/licheb/userslog">
|
||||
<input type="hidden" name="tab" v-model="params.tab"/>
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">顾问名字:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="uname" placeholder="顾问名字关键字" v-model="params.uname"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">门店:</label>
|
||||
<div class="am-para-inline w120">
|
||||
@@ -101,18 +82,15 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="17%"><span>门店</span></th>
|
||||
<th width="10%"><span>顾问</span></th>
|
||||
<th width="9%"><span>客户数</span></th>
|
||||
<th width="12%"><span>进店人数/次数</span></th>
|
||||
<th width="15%"><span>客户数</span></th>
|
||||
<th width="15%"><span>进店人数</span></th>
|
||||
<th width="15%"><span>订单数</span></th>
|
||||
<th width="9%"><span>试驾数</span></th>
|
||||
<th width="9%"><span>跟进数</span></th>
|
||||
<th width="9%"><span>订单数</span></th>
|
||||
<th width="9%"><span>战败数</span></th>
|
||||
<th width="9%"><span>开票数</span></th>
|
||||
<th width="9%"><span>企微数</span></th>
|
||||
<th width="9%"><span>改派数</span></th>
|
||||
<th width="9%"><span>接收数</span></th>
|
||||
<th width="9%"><span>新增企微</span></th>
|
||||
<th width="9%"><span>删除企微</span></th>
|
||||
<th width="10%"><span>日期</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -121,18 +99,15 @@
|
||||
foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['biz_name'] ?></td>
|
||||
<td><?= $v['uname'] ?></td>
|
||||
<td><?= $v['customers'] ?></td>
|
||||
<td><?= $v['c_num'] ?>/<?= $v['a_num'] ?></td>
|
||||
<td><?= $v['t_num'] ?></td>
|
||||
<td><?= $v['follows'] ?></td>
|
||||
<td><?= $v['c_num'] ?></td>
|
||||
<td><?= $v['orders'] ?></td>
|
||||
<td><?= $v['t_num'] ?></td>
|
||||
<td><?= $v['defeats'] ?></td>
|
||||
<td><?= $v['bills'] ?></td>
|
||||
<td><?= $v['qy_adds'] ?></td>
|
||||
<td><?= $v['reassigns'] ?></td>
|
||||
<td><?= $v['receives'] ?></td>
|
||||
<td><?= $v['qy_adds'] ?></td>
|
||||
<td><?= $v['qy_dels'] ?></td>
|
||||
<td><?= $v['log_date'] ?></td>
|
||||
</tr>
|
||||
<? }
|
||||
@@ -216,12 +191,11 @@
|
||||
set_county: function () {
|
||||
var that = this;
|
||||
that.bizAry = [];
|
||||
that.params.biz_id = that.params.addr_id = '';
|
||||
that.params.biz_id = '';
|
||||
},
|
||||
reset: function () {
|
||||
var that = this;
|
||||
that.params.city_id = '';
|
||||
that.params.uname = '';
|
||||
that.params.type = '';
|
||||
$('#id-time').val('');
|
||||
}
|
||||
@@ -257,7 +231,7 @@
|
||||
var that = this;
|
||||
if (nv == '') {
|
||||
that.bizAry = [];
|
||||
that.params.biz_id = that.params.addr_id = '';
|
||||
that.params.biz_id = '';
|
||||
} else {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;margin-bottom: 20px;">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<? foreach ($tabAry as $key => $val) { ?>
|
||||
<li role="presentation"
|
||||
class="<?= strlen($params['tab']) && $params['tab'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);"
|
||||
data-open="/app/licheb/userslog/lists_users?tab=<?= $key ?>&biz_id=<?= $params['biz_id'] ?>&time=<?= $params['time'] ?>">
|
||||
<?= $val ?>
|
||||
</a>
|
||||
</li>
|
||||
<? } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<? foreach ($menus as $key => $value) { ?>
|
||||
<td class="my-panel text-center">
|
||||
<?= $value['title'] ?><br><?= $value['value'] ?><?= $value['tag'] ?>
|
||||
</td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="app/licheb/userslog/lists_users">
|
||||
<input type="hidden" name="tab" v-model="params.tab"/>
|
||||
<input type="hidden" name="biz_id" v-model="params.biz_id"/>
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">顾问名字:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="uname" placeholder="顾问名字关键字" v-model="params.uname"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">日期:</label>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w200">
|
||||
<input id="id-time" name="time" type="text" value="<?= $params['time'] ?>"
|
||||
placeholder="开始时间 ~ 结束时间" autocomplete="off"/>
|
||||
</div>
|
||||
<div class="am-para-inline" style="padding-top: 5px;">
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday"
|
||||
data-source="id-time">昨日</a>
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="weeks"
|
||||
data-source="id-time">本周</a>
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="month"
|
||||
data-source="id-time">本月</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml30">
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd">
|
||||
<div class="fl"></div>
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%"><span>顾问</span></th>
|
||||
<th width="9%"><span>客户数</span></th>
|
||||
<th width="9%"><span>进店人数</span></th>
|
||||
<th width="9%"><span>订单数</span></th>
|
||||
<th width="9%"><span>试驾数</span></th>
|
||||
<th width="9%"><span>战败数</span></th>
|
||||
<th width="9%"><span>开票数</span></th>
|
||||
<th width="9%"><span>新增企微</span></th>
|
||||
<th width="9%"><span>删除企微</span></th>
|
||||
<th width="10%"><span>日期</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ($lists) {
|
||||
foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['uname'] ?></td>
|
||||
<td><?= $v['customers'] ?></td>
|
||||
<td><?= $v['c_num'] ?></td>
|
||||
<td><?= $v['orders'] ?></td>
|
||||
<td><?= $v['t_num'] ?></td>
|
||||
<td><?= $v['defeats'] ?></td>
|
||||
<td><?= $v['bills'] ?></td>
|
||||
<td><?= $v['qy_adds'] ?></td>
|
||||
<td><?= $v['qy_dels'] ?></td>
|
||||
<td><?= $v['log_date'] ?></td>
|
||||
</tr>
|
||||
<? }
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="hander am-form">
|
||||
</div>
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require(['laydate', 'autocomplete'], function (laydate) {
|
||||
laydate.render({
|
||||
elem: '#id-time', range: '~'
|
||||
});
|
||||
$('.id-day-btn').click(function () {
|
||||
var type = $(this).data('date'), date = '', nowDate = new Date();
|
||||
var source_id = $(this).data('source') || 'id-time';
|
||||
var beginDate = '';
|
||||
var endDate = '';
|
||||
switch (type) {
|
||||
case 'yesterday':
|
||||
beginDate = endDate = (new Date(nowDate.getTime() - 86400000)).Format('yyyy-MM-dd');
|
||||
break;
|
||||
case 'weeks':
|
||||
nowDate.setDate(nowDate.getDate() - nowDate.getDay() + 1);
|
||||
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
|
||||
nowDate.setDate(nowDate.getDate() + 6);
|
||||
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
|
||||
break;
|
||||
case 'month':
|
||||
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-01";
|
||||
var day = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, 0);
|
||||
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + day.getDate();
|
||||
break;
|
||||
}
|
||||
date = beginDate + ' ~ ' + endDate;
|
||||
$('#' + source_id).val(date);
|
||||
});
|
||||
});
|
||||
$(function () {
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params: {},
|
||||
},
|
||||
mounted: function () {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
},
|
||||
methods: {
|
||||
reset: function () {
|
||||
var that = this;
|
||||
that.params.uname = '';
|
||||
$('#id-time').val('');
|
||||
}
|
||||
},
|
||||
watch: {}
|
||||
});
|
||||
<?php page_script($pager) ?>
|
||||
$('#export').click(function () {
|
||||
var count = <?=$pager['totle']?>;
|
||||
if (count > 10000) {
|
||||
layer.msg('单次导出数据不能超过10000');
|
||||
return false;
|
||||
}
|
||||
var href = $.menu.parseUri(window.location.href);
|
||||
var arr = href.split('?');
|
||||
href = '/app/licheb/userslog/export?' + arr[1];
|
||||
window.location.href = href;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.my-panel {
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.my-panel span {
|
||||
font-size: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -3,7 +3,8 @@
|
||||
<? foreach ($tabAry as $key => $val) { ?>
|
||||
<li role="presentation"
|
||||
class="<?= strlen($params['tab']) && $params['tab'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);" data-open="/app/licheb/userslog?tab=<?= $key ?>">
|
||||
<a href="javascript:void (0);"
|
||||
data-open="/app/licheb/userslog/lists_users?tab=<?= $key ?>&biz_id=<?= $params['biz_id'] ?>&time=<?= $params['time'] ?>">
|
||||
<?= $val ?>
|
||||
</a>
|
||||
</li>
|
||||
@@ -23,6 +24,7 @@
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="app/licheb/userslog">
|
||||
<input type="hidden" name="tab" v-model="params.tab"/>
|
||||
<input type="hidden" name="biz_id" v-model="params.biz_id"/>
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">顾问名字:</label>
|
||||
@@ -30,40 +32,6 @@
|
||||
<input type="text" name="uname" placeholder="顾问名字关键字" v-model="params.uname"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">门店:</label>
|
||||
<div class="am-para-inline w120">
|
||||
<select title="类型" name="type" v-model="params.type">
|
||||
<option value="">选择类型</option>
|
||||
<option :value="i" v-for="(v,i) in typeAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w120">
|
||||
<select title="城市" name="city_id" v-model="params.city_id">
|
||||
<option value="">选择城市</option>
|
||||
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w120">
|
||||
<select title="行政区" name="county_id" v-model="params.county_id" @change="set_county">
|
||||
<option value="">选择行政区</option>
|
||||
<option :value="v.id" v-for="(v,i) in countyAry">{{v.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w200">
|
||||
<select title="门店" name="biz_id" v-model="params.biz_id">
|
||||
<option value="">选择门店</option>
|
||||
<option :value="v.id" v-for="(v,i) in bizAry">{{v.title}}</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 w80">日期:</label>
|
||||
<div class="am-form-group fl">
|
||||
@@ -100,7 +68,6 @@
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="17%"><span>门店</span></th>
|
||||
<th width="10%"><span>顾问</span></th>
|
||||
<th width="10%"><span>计划跟进数</span></th>
|
||||
<th width="10%"><span>已跟进数</span></th>
|
||||
@@ -113,7 +80,6 @@
|
||||
<? if ($lists) {
|
||||
foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['biz_name'] ?></td>
|
||||
<td><?= $v['uname'] ?></td>
|
||||
<td><?= $v['follows'] ?></td>
|
||||
<td><?= $v['h_follows'] ?></td>
|
||||
@@ -169,110 +135,19 @@
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params: {},
|
||||
typeAry: [],//城市
|
||||
cityAry: [],//城市
|
||||
countyAry: [],//行政区
|
||||
bizAry: [],//门店
|
||||
},
|
||||
mounted: function () {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.typeAry = <?=json_encode($typeAry)?>;
|
||||
vm.init_citys();
|
||||
},
|
||||
methods: {
|
||||
init_citys: function () {
|
||||
var vm = this;
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/common/area',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: '350',
|
||||
key: 'city',
|
||||
type: 1
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.code == 1) {
|
||||
vm.cityAry = response.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
set_county: function () {
|
||||
var that = this;
|
||||
that.bizAry = [];
|
||||
that.params.biz_id = that.params.addr_id = '';
|
||||
},
|
||||
reset: function () {
|
||||
var that = this;
|
||||
that.params.city_id = '';
|
||||
that.params.uname = '';
|
||||
that.params.type = '';
|
||||
$('#id-time').val('');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'params.city_id': function (nv, ov) {
|
||||
var that = this;
|
||||
if (nv == '') {
|
||||
that.countyAry = [];
|
||||
that.params.county_id = '';
|
||||
} else {
|
||||
if (nv.substring(0, 4) != that.params.county_id.substring(0, 4)) {
|
||||
that.params.county_id = '';
|
||||
}
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/common/area',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: nv,
|
||||
key: 'county',
|
||||
type: 1
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.code == 1) {
|
||||
that.countyAry = response.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'params.county_id': function (nv, ov) {
|
||||
var that = this;
|
||||
if (nv == '') {
|
||||
that.bizAry = [];
|
||||
that.params.biz_id = that.params.addr_id = '';
|
||||
} else {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/biz/store/store/json_lists',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
city_id: that.params.city_id,
|
||||
county_id: that.params.county_id,
|
||||
status: 1
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.code == 1) {
|
||||
that.bizAry = response.data.list;
|
||||
var biz_id = '';
|
||||
if (that.params.biz_id > 0 || that.params.biz_id == -1) {
|
||||
for (var i in that.bizAry) {
|
||||
if (that.params.biz_id == that.bizAry[i].id) {
|
||||
biz_id = that.params.biz_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
that.params.biz_id = biz_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
watch: {}
|
||||
});
|
||||
<?php page_script($pager) ?>
|
||||
$('#export').click(function () {
|
||||
@@ -297,4 +172,4 @@
|
||||
.my-panel span {
|
||||
font-size: 20px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
+318
-135
@@ -17,6 +17,324 @@ class Licheb extends HD_Controller
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:顾问日志
|
||||
* Created on: 2021/10/19 17:15
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/licheb/users_log?sd=1
|
||||
* https://api.liche.cn/plan/licheb/users_log
|
||||
*/
|
||||
public function users_log()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$hour = date('H.i');
|
||||
if (($hour > 00.00 && $hour < 03.00) || $params['sd']) {
|
||||
if ($params['sd']) {
|
||||
echo "开始执行库顾问日志[{$hour}]";
|
||||
}
|
||||
} else {
|
||||
echo '[00.00-03.00]执行顾问日志[' . $hour . ']';
|
||||
return;
|
||||
}
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$time = strtotime("-1 day");//昨天此时的时间戳
|
||||
$size = 200;//每次最多处理多少条
|
||||
$rds = intval($this->input->get('rds'));
|
||||
$redis = &load_cache('redis');
|
||||
$log_date = date('Y-m-d', $time);
|
||||
$redisKey = 'app_licheb_users_log_id_' . $log_date;
|
||||
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;
|
||||
}
|
||||
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomerOpLogs');
|
||||
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrdersV2');
|
||||
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
|
||||
$this->load->model('app/app_different_qy_log_model', 'mdDifferentQyLog');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$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) {
|
||||
$sale_id = $id = $value['id'];
|
||||
$biz_id = intval($value['biz_id']);
|
||||
if ($biz_id == 1 || $biz_id == 110) {//门店用户不写入
|
||||
continue;
|
||||
}
|
||||
$re_log = $this->mdUsersLog->get(['log_date' => $log_date, 'sale_id' => $sale_id, 'biz_id' => $biz_id]);
|
||||
if ($re_log) {//判断当天是否已加入
|
||||
continue;
|
||||
}
|
||||
$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']);
|
||||
$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} and cs_biz_id!=-1)" => 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} and cs_biz_id!=-1)" => 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} and cs_biz_id!=-1)" => 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} and cs_biz_id!=-1)" => null]
|
||||
);
|
||||
$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 = $c_num = $orders = 0;
|
||||
if ($value['userid']) {
|
||||
$qy_where = ['userid' => $value['userid'], 'c_time>=' => $s_time, 'c_time<=' => $e_time];
|
||||
if ($type == 5) {//异业店
|
||||
$qy_adds = $this->mdDifferentQyLog->count(array_merge($qy_where, ['change_type' => 'add_external_contact']));
|
||||
$qy_dels = $this->mdDifferentQyLog->count(array_merge($qy_where, ["change_type in('del_external_contact','del_follow_user')" => null]));
|
||||
} else {
|
||||
$qy_adds = $this->mdWechatqyLog->count(array_merge($qy_where, ['change_type' => 'add_external_contact']));
|
||||
$qy_dels = $this->mdWechatqyLog->count(array_merge($qy_where, ["change_type in('del_external_contact','del_follow_user')" => null]));
|
||||
}
|
||||
}
|
||||
//改派数
|
||||
$reassigns = $this->mdCustomers->count(['admin_id' => $sale_id, 'cs_biz_id' => -1, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
//接收数
|
||||
$receives = $this->mdCustomers->count(['admin_id' => $sale_id, 'cs_biz_id>' => 0, 'status>=' => 0, '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, 'reassigns' => $reassigns, 'receives' => $receives, 'c_time' => time()];
|
||||
$customer_json = $c_num_json = $order_json = '';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
//客户数
|
||||
$customer_num1 = $this->mdCustomers->count(['of_id' => $key1, 'admin_id' => $sale_id, 'cs_biz_id<>' => -1
|
||||
, '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, 'cs_biz_id<>' => -1]);
|
||||
if ($customer_num2) {//二级
|
||||
$list[$key2] = ['name' => $value2, 'num' => $customer_num2];
|
||||
}
|
||||
}
|
||||
$customer_json[$key1] = ['name' => $value1['name'], 'num' => $customer_num1, 'list' => $list];
|
||||
}
|
||||
//进店人数
|
||||
$c_num1 = $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 of_id={$key1} and admin_id={$sale_id}
|
||||
and biz_id={$biz_id} and cs_biz_id!=-1)" => null], 'distinct(customer_id)');
|
||||
if ($c_num1) {//一级
|
||||
$c_num += $c_num1;
|
||||
$add_item["c_num_{$key1}"] = $c_num1;
|
||||
$list = '';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$c_num2 = $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 of_id={$key1} and of2_id={$key2}
|
||||
and admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null], 'distinct(customer_id)');
|
||||
if ($c_num2) {//二级
|
||||
$list[$key2] = ['name' => $value2, 'num' => $c_num2];
|
||||
}
|
||||
}
|
||||
$c_num_json[$key1] = ['name' => $value1['name'], 'num' => $c_num1, 'list' => $list];
|
||||
}
|
||||
//订单数
|
||||
$orders1 = $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",
|
||||
"customer_id in(select id from lc_receiver_customers where of_id={$key1} and admin_id={$sale_id}
|
||||
and biz_id={$biz_id} and cs_biz_id!=-1)" => null]);
|
||||
if ($orders1) {//一级
|
||||
$orders += $orders1;
|
||||
$add_item["order_{$key1}"] = $orders1;
|
||||
$list = '';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$orders2 = $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",
|
||||
"customer_id in(select id from lc_receiver_customers where of_id={$key1} and of2_id={$key2}
|
||||
and admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null]);
|
||||
if ($orders2) {//二级
|
||||
$list[$key2] = ['name' => $value2, 'num' => $orders2];
|
||||
}
|
||||
}
|
||||
$order_json[$key1] = ['name' => $value1['name'], 'num' => $orders1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
$customer_json && $add_item['customer_json'] = json_encode($customer_json, JSON_UNESCAPED_UNICODE);
|
||||
$c_num_json && $add_item['c_num_json'] = json_encode($c_num_json, JSON_UNESCAPED_UNICODE);
|
||||
$order_json && $add_item['order_json'] = json_encode($order_json, JSON_UNESCAPED_UNICODE);
|
||||
$add_item['customers'] = $customers;
|
||||
$add_item['c_num'] = $c_num;
|
||||
$add_item['orders'] = $orders;
|
||||
$add_id = $this->mdUsersLog->add($add_item);
|
||||
$add_id && $log[] = array('id' => $sale_id, 'addDate' => $add_item);
|
||||
}
|
||||
$redis->save($redisKey, $id, 24 * 3600);//保存最后id
|
||||
if ($params['sd']) {
|
||||
echo '<br>执行到当前顾问id:' . $redis->get($redisKey);
|
||||
echo ' 日期:' . $log_date;
|
||||
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/7/11 17:15
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/licheb/bizs_log?sd=1
|
||||
* https://api.liche.cn/plan/licheb/bizs_log
|
||||
*/
|
||||
public function bizs_log()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$hour = date('H.i');
|
||||
if (($hour > 03.00 && $hour < 05.00) || $params['sd']) {
|
||||
if ($params['sd']) {
|
||||
echo "开始执行库门店日志[{$hour}]";
|
||||
}
|
||||
} else {
|
||||
echo '[00.00-03.00]执行门店日志[' . $hour . ']';
|
||||
return;
|
||||
}
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$time = strtotime("-1 day");//昨天此时的时间戳
|
||||
$size = 200;//每次最多处理多少条
|
||||
$rds = intval($this->input->get('rds'));
|
||||
$redis = &load_cache('redis');
|
||||
$log_date = date('Y-m-d', $time);
|
||||
$redisKey = 'app_licheb_bizs_log_id_' . $log_date;
|
||||
if ($rds) {
|
||||
$redis->delete($redisKey);
|
||||
}
|
||||
$id = $redis->get($redisKey);
|
||||
!$id && $id = 0;
|
||||
$log = [];
|
||||
$where = ['id >' => $id, 'status' => 1];
|
||||
$res = $this->mdBiz->select($where, 'id asc', 1, $size, 'id,type,city_id');
|
||||
if (!$res) {
|
||||
echo '执行到当前门店id:' . $id . '暂无数据';
|
||||
return;
|
||||
}
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$this->load->model('app/licheb/app_licheb_bizs_log_model', 'mdBizsLog');
|
||||
foreach ($res as $key => $value) {
|
||||
$biz_id = $id = $value['id'];
|
||||
if ($biz_id == 1 || $biz_id == 110) {//门店不写入
|
||||
continue;
|
||||
}
|
||||
$a_num = $t_num = $bills = $follows = $defeats = $qy_adds = $qy_dels = $reassigns = $receives = 0;
|
||||
$c_num = $orders = $customers = 0;
|
||||
$c_num_ary = $order_ary = $customer_ary = [];
|
||||
$c_num_json = $order_json = $customer_json = '';
|
||||
$re = $this->mdBizsLog->get(['biz_id' => $biz_id, 'log_date' => $log_date]);
|
||||
if ($re) {
|
||||
continue;
|
||||
}
|
||||
$res2 = $this->mdUsersLog->select(['biz_id' => $biz_id, 'log_date' => $log_date], 'id asc');
|
||||
foreach ($res2 as $key2 => $value2) {
|
||||
$c_num += $value2['c_num'];
|
||||
$orders += $value2['orders'];
|
||||
$customers += $value2['customers'];
|
||||
$a_num += $value2['a_num'];
|
||||
$t_num += $value2['t_num'];
|
||||
$bills += $value2['bills'];
|
||||
$follows += $value2['follows'];
|
||||
$defeats += $value2['defeats'];
|
||||
$qy_adds += $value2['qy_adds'];
|
||||
$qy_dels += $value2['qy_dels'];
|
||||
$reassigns += $value2['reassigns'];
|
||||
$receives += $value2['receives'];
|
||||
//一级统计
|
||||
for ($ii = 1; $ii < 5; ++$ii) {
|
||||
$c_num_ary[$ii] += $value2['c_num_' . $ii];
|
||||
$order_ary[$ii] += $value2['order_' . $ii];
|
||||
$customer_ary[$ii] += $value2['customer_' . $ii];
|
||||
}
|
||||
//详情统计
|
||||
if ($value2['c_num_json']) {
|
||||
$c_num_json_u = json_decode($value2['c_num_json'], true);
|
||||
foreach ($c_num_json_u as $k1 => $v1) {
|
||||
$list = '';
|
||||
foreach ($v1['list'] as $k2 => $v2) {
|
||||
$num2 = intval($c_num_json[$k1]['list'][$k2]['num']) + $v2['num'];
|
||||
//二级
|
||||
$num2 && $list[$k2] = ['name' => $v2['name'], 'num' => $num2];
|
||||
}
|
||||
$num1 = intval($c_num_json[$k1]['num']) + $v1['num'];
|
||||
$c_num_json[$k1] = ['name' => $v1['name'], 'num' => $num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
if ($value2['order_json']) {
|
||||
$order_json_u = json_decode($value2['order_json'], true);
|
||||
foreach ($order_json_u as $k1 => $v1) {
|
||||
$list = '';
|
||||
foreach ($v1['list'] as $k2 => $v2) {
|
||||
$num2 = intval($order_json[$k1]['list'][$k2]['num']) + $v2['num'];
|
||||
//二级
|
||||
$num2 && $list[$k2] = ['name' => $v2['name'], 'num' => $num2];
|
||||
}
|
||||
$num1 = intval($order_json[$k1]['num']) + $v1['num'];
|
||||
$order_json[$k1] = ['name' => $v1['name'], 'num' => $num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
if ($value2['customer_json']) {
|
||||
$customer_json_u = json_decode($value2['customer_json'], true);
|
||||
foreach ($customer_json_u as $k1 => $v1) {
|
||||
$list = '';
|
||||
foreach ($v1['list'] as $k2 => $v2) {
|
||||
$num2 = intval($customer_json[$k1]['list'][$k2]['num']) + $v2['num'];
|
||||
//二级
|
||||
$num2 && $list[$k2] = ['name' => $v2['name'], 'num' => $num2];
|
||||
}
|
||||
$num1 = intval($customer_json[$k1]['num']) + $v1['num'];
|
||||
$customer_json[$k1] = ['name' => $v1['name'], 'num' => $num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
}
|
||||
$add_item = ['biz_id' => $biz_id, 'type' => $value['type'], 'city_id' => $value['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, 'reassigns' => $reassigns, 'receives' => $receives, 'c_time' => time()];
|
||||
for ($ii = 1; $ii < 5; ++$ii) {
|
||||
$add_item['c_num_' . $ii] = intval($c_num_ary[$ii]);
|
||||
$add_item['order_' . $ii] = intval($order_ary[$ii]);
|
||||
$add_item['customer_' . $ii] = intval($customer_ary[$ii]);
|
||||
}
|
||||
$c_num_json && $add_item['c_num_json'] = json_encode($c_num_json, JSON_UNESCAPED_UNICODE);
|
||||
$order_json && $add_item['order_json'] = json_encode($order_json, JSON_UNESCAPED_UNICODE);
|
||||
$customer_json && $add_item['customer_json'] = json_encode($customer_json, JSON_UNESCAPED_UNICODE);
|
||||
$add_id = $this->mdBizsLog->add($add_item);
|
||||
if ($add_id) {
|
||||
$log[] = ['id' => $add_id, 'biz_id' => $biz_id, 'mobile' => $log_date];
|
||||
}
|
||||
}
|
||||
$redis->save($redisKey, $id, 24 * 3600);//保存最后id
|
||||
if ($params['sd']) {
|
||||
echo '<br>执行到当前门店id:' . $redis->get($redisKey);
|
||||
echo ' 日期:' . $log_date;
|
||||
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
|
||||
@@ -176,141 +494,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/users_log?sd=1
|
||||
* https://api.liche.cn/plan/licheb/users_log
|
||||
*/
|
||||
public function users_log()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$hour = date('H.i');
|
||||
if (($hour > 00.00 && $hour < 03.00) || $params['sd']) {
|
||||
if ($params['sd']) {
|
||||
echo "开始执行库顾问日志[{$hour}]";
|
||||
}
|
||||
} else {
|
||||
echo '[00.00-03.00]执行顾问日志[' . $hour . ']';
|
||||
return;
|
||||
}
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$time = strtotime("-1 day");//昨天此时的时间戳
|
||||
$size = 200;//每次最多处理多少条
|
||||
$rds = intval($this->input->get('rds'));
|
||||
$redis = &load_cache('redis');
|
||||
$log_date = date('Y-m-d', $time);
|
||||
$redisKey = 'app_licheb_users_log_id_' . $log_date;
|
||||
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;
|
||||
}
|
||||
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomerOpLogs');
|
||||
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrdersV2');
|
||||
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
|
||||
$this->load->model('app/app_different_qy_log_model', 'mdDifferentQyLog');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$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) {
|
||||
$sale_id = $id = $value['id'];
|
||||
$biz_id = intval($value['biz_id']);
|
||||
if ($biz_id == 1 || $biz_id == 110) {//门店用户不写入
|
||||
continue;
|
||||
}
|
||||
$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} and cs_biz_id!=-1)" => 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} and cs_biz_id!=-1)" => 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} and cs_biz_id!=-1)" => 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} and cs_biz_id!=-1)" => 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} and cs_biz_id!=-1)" => 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_where = ['userid' => $value['userid'], 'c_time>=' => $s_time, 'c_time<=' => $e_time];
|
||||
if ($type == 5) {//异业店
|
||||
$qy_adds = $this->mdDifferentQyLog->count(array_merge($qy_where, ['change_type' => 'add_external_contact']));
|
||||
$qy_dels = $this->mdDifferentQyLog->count(array_merge($qy_where, ["change_type in('del_external_contact','del_follow_user')" => null]));
|
||||
} else {
|
||||
$qy_adds = $this->mdWechatqyLog->count(array_merge($qy_where, ['change_type' => 'add_external_contact']));
|
||||
$qy_dels = $this->mdWechatqyLog->count(array_merge($qy_where, ["change_type in('del_external_contact','del_follow_user')" => null]));
|
||||
}
|
||||
}
|
||||
//改派数
|
||||
$reassigns = $this->mdCustomers->count(['admin_id' => $sale_id, 'cs_biz_id' => -1, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
|
||||
//接收数
|
||||
$receives = $this->mdCustomers->count(['admin_id' => $sale_id, 'cs_biz_id>' => 0, 'status>=' => 0, '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, 'reassigns' => $reassigns, 'receives' => $receives, 'c_time' => time()];
|
||||
$customer_json = '';
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$customer_num1 = $this->mdCustomers->count(['of_id' => $key1, 'admin_id' => $sale_id, 'cs_biz_id<>' => -1
|
||||
, '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, 'cs_biz_id<>' => -1]);
|
||||
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
|
||||
if ($params['sd']) {
|
||||
echo '<br>执行到当前顾问id:' . $redis->get($redisKey);
|
||||
echo ' 日期:' . $log_date;
|
||||
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
|
||||
|
||||
@@ -36,6 +36,7 @@ class Plan extends CI_Controller
|
||||
$plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales_sms')), 'interval' => 2);//给销售发送待回访短信
|
||||
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 2);//给店长发送待分配短信
|
||||
$plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志
|
||||
$plan[] = array('url' => base_url(array('plan', 'licheb', 'bizs_log')), 'interval' => 2);//门店日志
|
||||
|
||||
$plan[] = array('url' => base_url(array('plan', 'liche', 'add_owners')), 'interval' => 5);//新增车主
|
||||
$plan[] = array('url' => base_url(array('plan', 'liche', 'owners_wxqy')), 'interval' => 60);//更新车主企业微信
|
||||
|
||||
+217
-109
@@ -16,6 +16,223 @@ class Temp extends HD_Controller
|
||||
$this->log_file = 'temp.log';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新顾问日志
|
||||
* Created on: 2022/7/11 11:58
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_users_log
|
||||
* https://api.liche.cn/plan/temp/receiver_users_log
|
||||
*/
|
||||
public function receiver_users_log()
|
||||
{
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomerOpLogs');
|
||||
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrdersV2');
|
||||
$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']);
|
||||
ob_start(); //打开缓冲区
|
||||
$where = ['c_num>0 or orders>0' => null];
|
||||
$res = $this->mdUsersLog->select($where, 'id asc', $param['page'], $param['size'], 'id,sale_id,biz_id,log_date');
|
||||
if (!$res) {
|
||||
echo '<br>本次更新完成了:';
|
||||
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
|
||||
echo '<br><br><a href="/plan/temp/receiver_users_log">点击将再次更新>>></a>';
|
||||
exit;
|
||||
}
|
||||
$log = array();
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
foreach ($res as $key => $value) {
|
||||
$sale_id = $value['sale_id'];
|
||||
$biz_id = $value['biz_id'];
|
||||
$log_date = $value['log_date'];
|
||||
$s_time = strtotime($log_date . ' 00:00:00');
|
||||
$e_time = strtotime($log_date . ' 23:59:59');
|
||||
$c_num_json = $order_json = '';
|
||||
$update_item = [];
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
//进店人数
|
||||
$c_num1 = $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 of_id={$key1} and admin_id={$sale_id}
|
||||
and biz_id={$biz_id} and cs_biz_id!=-1)" => null], 'distinct(customer_id)');
|
||||
if ($c_num1) {//一级
|
||||
$update_item["c_num_{$key1}"] = $c_num1;
|
||||
$list = '';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$c_num2 = $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 of_id={$key1} and of2_id={$key2}
|
||||
and admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null], 'distinct(customer_id)');
|
||||
if ($c_num2) {//二级
|
||||
$list[$key2] = ['name' => $value2, 'num' => $c_num2];
|
||||
}
|
||||
}
|
||||
$c_num_json[$key1] = ['name' => $value1['name'], 'num' => $c_num1, 'list' => $list];
|
||||
}
|
||||
//订单数
|
||||
$orders1 = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0,
|
||||
'order_time>=' => "{$value['log_date']} 00:00:00", 'order_time<=' => "{$value['log_date']} 23:59:59",
|
||||
"customer_id in(select id from lc_receiver_customers where of_id={$key1} and admin_id={$sale_id}
|
||||
and biz_id={$biz_id} and cs_biz_id!=-1)" => null]);
|
||||
if ($orders1) {//一级
|
||||
$update_item["order_{$key1}"] = $orders1;
|
||||
$list = '';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$orders2 = $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",
|
||||
"customer_id in(select id from lc_receiver_customers where of_id={$key1} and of2_id={$key2}
|
||||
and admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null]);
|
||||
if ($orders2) {//二级
|
||||
$list[$key2] = ['name' => $value2, 'num' => $orders2];
|
||||
}
|
||||
}
|
||||
$order_json[$key1] = ['name' => $value1['name'], 'num' => $orders1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
$c_num_json && $update_item['c_num_json'] = json_encode($c_num_json, JSON_UNESCAPED_UNICODE);
|
||||
$order_json && $update_item['order_json'] = json_encode($order_json, JSON_UNESCAPED_UNICODE);
|
||||
if ($update_item) {
|
||||
$this->mdUsersLog->update($update_item, ['id' => $value['id']]);
|
||||
$log[] = ['id' => $value['id'], 'biz_id' => $value['biz_id'], 'log_date' => $value['log_date']];
|
||||
$counts++;
|
||||
}
|
||||
}
|
||||
echo '<br>成功更新:';
|
||||
if ($log) {
|
||||
echo json_encode($log, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
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));
|
||||
ob_end_flush();//输出全部内容到浏览器
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新门店日志
|
||||
* Created on: 2022/3/09 11:58
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_bizs_log
|
||||
* https://api.liche.cn/plan/temp/receiver_bizs_log
|
||||
*/
|
||||
public function receiver_bizs_log()
|
||||
{
|
||||
$param = $this->input->get();
|
||||
$page = intval($param['page']);
|
||||
!$page && $page = 0;
|
||||
ob_start(); //打开缓冲区
|
||||
$log_date = date("Y-m-d", strtotime("+{$page} day", strtotime("2022-04-15")));
|
||||
echo "log_date={$log_date}<br>";
|
||||
if ($log_date >= date("Y-m-d")) {
|
||||
echo '<br>本次更新门店日志完成了:';
|
||||
echo '<br><br>成功更新 <span style="color: red;">' . $param['page'] . '</span> 次';
|
||||
echo '<br><br><a href="/plan/temp/receiver_bizs_log">点击将再次更新门店日志>>></a>';
|
||||
exit;
|
||||
}
|
||||
$log = [];
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$this->load->model('app/licheb/app_licheb_bizs_log_model', 'mdBizsLog');
|
||||
$res = $this->mdBiz->select(['status' => 1], 'id asc', 0, 0, 'id,type,city_id');
|
||||
foreach ($res as $key => $value) {
|
||||
$biz_id = $value['id'];
|
||||
$a_num = $t_num = $bills = $follows = $defeats = $qy_adds = $qy_dels = $reassigns = $receives = 0;
|
||||
$c_num = $orders = $customers = 0;
|
||||
$c_num_ary = $order_ary = $customer_ary = [];
|
||||
$c_num_json = $order_json = $customer_json = '';
|
||||
$re = $this->mdBizsLog->get(['biz_id' => $biz_id, 'log_date' => $log_date]);
|
||||
if ($re) {
|
||||
continue;
|
||||
}
|
||||
$res2 = $this->mdUsersLog->select(['biz_id' => $biz_id, 'log_date' => $log_date], 'id asc');
|
||||
foreach ($res2 as $key2 => $value2) {
|
||||
$c_num += $value2['c_num'];
|
||||
$orders += $value2['orders'];
|
||||
$customers += $value2['customers'];
|
||||
$a_num += $value2['a_num'];
|
||||
$t_num += $value2['t_num'];
|
||||
$bills += $value2['bills'];
|
||||
$follows += $value2['follows'];
|
||||
$defeats += $value2['defeats'];
|
||||
$qy_adds += $value2['qy_adds'];
|
||||
$qy_dels += $value2['qy_dels'];
|
||||
$reassigns += $value2['reassigns'];
|
||||
$receives += $value2['receives'];
|
||||
//一级统计
|
||||
for ($ii = 1; $ii < 5; ++$ii) {
|
||||
$c_num_ary[$ii] += $value2['c_num_' . $ii];
|
||||
$order_ary[$ii] += $value2['order_' . $ii];
|
||||
$customer_ary[$ii] += $value2['customer_' . $ii];
|
||||
}
|
||||
//详情统计
|
||||
if ($value2['c_num_json']) {
|
||||
$c_num_json_u = json_decode($value2['c_num_json'], true);
|
||||
foreach ($c_num_json_u as $k1 => $v1) {
|
||||
$list = '';
|
||||
foreach ($v1['list'] as $k2 => $v2) {
|
||||
$num2 = intval($c_num_json[$k1]['list'][$k2]['num']) + $v2['num'];
|
||||
//二级
|
||||
$num2 && $list[$k2] = ['name' => $v2['name'], 'num' => $num2];
|
||||
}
|
||||
$num1 = intval($c_num_json[$k1]['num']) + $v1['num'];
|
||||
$c_num_json[$k1] = ['name' => $v1['name'], 'num' => $num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
if ($value2['order_json']) {
|
||||
$order_json_u = json_decode($value2['order_json'], true);
|
||||
foreach ($order_json_u as $k1 => $v1) {
|
||||
$list = '';
|
||||
foreach ($v1['list'] as $k2 => $v2) {
|
||||
$num2 = intval($order_json[$k1]['list'][$k2]['num']) + $v2['num'];
|
||||
//二级
|
||||
$num2 && $list[$k2] = ['name' => $v2['name'], 'num' => $num2];
|
||||
}
|
||||
$num1 = intval($order_json[$k1]['num']) + $v1['num'];
|
||||
$order_json[$k1] = ['name' => $v1['name'], 'num' => $num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
if ($value2['customer_json']) {
|
||||
$customer_json_u = json_decode($value2['customer_json'], true);
|
||||
foreach ($customer_json_u as $k1 => $v1) {
|
||||
$list = '';
|
||||
foreach ($v1['list'] as $k2 => $v2) {
|
||||
$num2 = intval($customer_json[$k1]['list'][$k2]['num']) + $v2['num'];
|
||||
//二级
|
||||
$num2 && $list[$k2] = ['name' => $v2['name'], 'num' => $num2];
|
||||
}
|
||||
$num1 = intval($customer_json[$k1]['num']) + $v1['num'];
|
||||
$customer_json[$k1] = ['name' => $v1['name'], 'num' => $num1, 'list' => $list];
|
||||
}
|
||||
}
|
||||
}
|
||||
$add_item = ['biz_id' => $biz_id, 'type' => $value['type'], 'city_id' => $value['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, 'reassigns' => $reassigns, 'receives' => $receives, 'c_time' => time()];
|
||||
for ($ii = 1; $ii < 5; ++$ii) {
|
||||
$add_item['c_num_' . $ii] = intval($c_num_ary[$ii]);
|
||||
$add_item['order_' . $ii] = intval($order_ary[$ii]);
|
||||
$add_item['customer_' . $ii] = intval($customer_ary[$ii]);
|
||||
}
|
||||
$c_num_json && $add_item['c_num_json'] = json_encode($c_num_json, JSON_UNESCAPED_UNICODE);
|
||||
$order_json && $add_item['order_json'] = json_encode($order_json, JSON_UNESCAPED_UNICODE);
|
||||
$customer_json && $add_item['customer_json'] = json_encode($customer_json, JSON_UNESCAPED_UNICODE);
|
||||
$id = $this->mdBizsLog->add($add_item);
|
||||
if ($id) {
|
||||
$log[] = ['id' => $id, 'biz_id' => $biz_id, 'mobile' => $log_date];
|
||||
}
|
||||
}
|
||||
echo '<br>成功新增:';
|
||||
if ($log) {
|
||||
echo json_encode($log, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
echo '<br><br>数据库获取:';
|
||||
echo json_encode($res, JSON_UNESCAPED_UNICODE);
|
||||
header('refresh:3;url=/plan/temp/receiver_bizs_log?page=' . ($param['page'] + 1));
|
||||
ob_end_flush();//输出全部内容到浏览器
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:车主企业微信/城市
|
||||
* Created on: 2022/6/21 11:58
|
||||
@@ -433,115 +650,6 @@ class Temp extends HD_Controller
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:更新顾问新增企微/删除企微
|
||||
* Created on: 2022/3/09 11:58
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_users_log
|
||||
* https://api.liche.cn/plan/temp/receiver_users_log
|
||||
*/
|
||||
public function receiver_users_log()
|
||||
{
|
||||
$param = $this->input->get();
|
||||
$page = intval($param['page']);
|
||||
!$page && $page = 0;
|
||||
ob_start(); //打开缓冲区
|
||||
$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;">' . $param['page'] . '</span> 人';
|
||||
echo '<br><br><a href="/plan/temp/receiver_users_log">点击将再次更新顾问客户数>>></a>';
|
||||
exit;
|
||||
}
|
||||
$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 json_encode($date, JSON_UNESCAPED_UNICODE);
|
||||
header('refresh:3;url=/plan/temp/receiver_users_log?page=' . ($param['page'] + 1));
|
||||
ob_end_flush();//输出全部内容到浏览器
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:更新车辆调拨状态
|
||||
* Created on: 2022/2/28 17:15
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Notes:狸车宝门店_日志
|
||||
* Created on: 2022/7/08 12:45
|
||||
* Created by: dengbw
|
||||
*/
|
||||
class App_licheb_bizs_log_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_app_licheb_bizs_log';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user