user_10117
This commit is contained in:
@@ -655,11 +655,27 @@ class CusorderV2 extends Wxapp
|
||||
$order_s_time = $this->input_param('order_s_time');
|
||||
$order_e_time = $this->input_param('order_e_time');
|
||||
$admin_ids = $this->input_param('admin_ids');//多选销售人员
|
||||
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
|
||||
$where = ['status!='=>2];
|
||||
$tab_id = intval($this->input_param('visit_tab_id'));
|
||||
if ($tab_id) {//数据看版数据
|
||||
if ($tab_id == 2) {//今日
|
||||
$s_c_time = date('Y-m-01', strtotime(date("Y-m-d"))) . ' 00:00:00';
|
||||
$e_c_time = date('Y-m-d', strtotime("$s_c_time +1 month -1 day")) . ' 23:59:59';
|
||||
} else {//本月
|
||||
$s_c_time = date('Y-m-d') . ' 00:00:00';
|
||||
$e_c_time = date('Y-m-d') . ' 23:59:59';
|
||||
}
|
||||
if ($status == 6) {
|
||||
$status = '';
|
||||
$where = ['order_time>=' => $s_c_time, 'order_time<=' => $e_c_time];
|
||||
} else if ($status == 8) {
|
||||
$status = 2;
|
||||
$where = ['refund_time>=' => $s_c_time, 'refund_time<=' => $e_c_time];
|
||||
}
|
||||
} else {
|
||||
$where = ['status!='=>2];
|
||||
}
|
||||
$admin_ids && $where["admin_id in ({$admin_ids})"] = null;
|
||||
if ($group_id == 1) {
|
||||
$where['admin_id'] = $uid;//销售
|
||||
|
||||
@@ -543,8 +543,8 @@ class Customers extends Wxapp
|
||||
private function lists()
|
||||
{
|
||||
$visit = $this->input_param('visit');
|
||||
if ($visit) {//待回访客户
|
||||
return $this->visit_lists($this->input_param());
|
||||
if ($visit) {
|
||||
return $this->visit_lists($this->input_param(), $visit);
|
||||
}
|
||||
$uid = $this->session['uid'];
|
||||
$group_id = $this->session['group_id'];
|
||||
@@ -649,67 +649,7 @@ class Customers extends Wxapp
|
||||
$fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,if_defeat
|
||||
,of_id,of2_id,wxqy,status,biz_id,cs_biz_id,county_id';
|
||||
$rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds);
|
||||
$admins = $map_county = [];
|
||||
//所在地区
|
||||
$str_county_ids = implode(',', array_unique(array_column($rows, 'county_id')));
|
||||
if ($str_county_ids) {
|
||||
$map_county = $this->mdArea->map('county_id', 'city_name,county_name', ["county_id in({$str_county_ids})" => null]);
|
||||
}
|
||||
//获取管理员
|
||||
$admin_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
|
||||
if ($admin_ids) {
|
||||
$admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname');
|
||||
}
|
||||
$allot = $this->get_allot();
|
||||
$status_name = $this->customers_model->get_status();
|
||||
foreach ($rows as $key => $val) {
|
||||
if ($map_county[$val['county_id']]) {
|
||||
$other_data['所在地区'] = "{$map_county[$val['county_id']]['city_name']}-{$map_county[$val['county_id']]['county_name']}";
|
||||
}
|
||||
if ($biz_type != 5) {
|
||||
$other_data['客户来源'] = $this->get_cfTitle($val);
|
||||
}
|
||||
$other_data['建卡时间'] = 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']));
|
||||
if ($group_id == 1) {
|
||||
$where_visit = ['c_id' => $val['id'], 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']];
|
||||
} else {
|
||||
$where_visit = ['c_id' => $val['id'], 'biz_id' => $val['biz_id'], 'sales_id' => $val['admin_id']];
|
||||
}
|
||||
$visit_time = $this->get_visit_time($where_visit);
|
||||
$visit_time && $other_data['计划回访时间'] = $visit_time;
|
||||
$other_data['销售顾问'] = isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '';
|
||||
$tags = [$val['level'] . '级用户'];
|
||||
$defeat = $orders_pay = '';
|
||||
if ($val['if_defeat'] == 1) {
|
||||
$defeat = '战败申请中';
|
||||
} else if ($val['if_defeat'] == 2) {
|
||||
$defeat = '再战';
|
||||
}
|
||||
//查找订单未支付
|
||||
if ($status == 0 || $status == 1) {
|
||||
$orders_count = $this->mdOrders->count(['status' => 0, 'order_time' => '0000-00-00 00:00:00', 'customer_id' => $val['id']]);
|
||||
$orders_count && $orders_pay = '订单未支付';
|
||||
}
|
||||
$tip = $status_name[$val['status']] ? $status_name[$val['status']] : '';
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
|
||||
'complete_mobile' => $val['mobile'],
|
||||
'is_top' => $val['is_top'],
|
||||
'other_data' => $other_data,
|
||||
'tags' => $tags,
|
||||
'defeat' => $defeat,
|
||||
'orders_pay' => $orders_pay,
|
||||
'group_id' => $group_id,
|
||||
'is_weChat' => $val['wxqy'] == 1 ? true : false,
|
||||
'allot' => $allot,
|
||||
'tip' => $tip,
|
||||
'level' => $val['level'],
|
||||
'reassign' => $val['cs_biz_id'] > 0 ? '他店改派' : '',
|
||||
];
|
||||
}
|
||||
$lists = $this->listCustomerField(['rows' => $rows, 'biz_type' => $biz_type, 'group_id' => $group_id]);
|
||||
}
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
@@ -718,6 +658,79 @@ class Customers extends Wxapp
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:客户列表字段
|
||||
* Created on: 2022/10/14 16:03
|
||||
* Created by: dengbw
|
||||
* @param array $param
|
||||
* @return array
|
||||
*/
|
||||
private function listCustomerField($param = [])
|
||||
{
|
||||
$lists = $admins = $map_county = [];
|
||||
//所在地区
|
||||
$str_county_ids = implode(',', array_unique(array_column($param['rows'], 'county_id')));
|
||||
if ($str_county_ids) {
|
||||
$map_county = $this->mdArea->map('county_id', 'city_name,county_name', ["county_id in({$str_county_ids})" => null]);
|
||||
}
|
||||
//获取管理员
|
||||
$admin_ids = implode(',', array_unique(array_column($param['rows'], 'admin_id')));
|
||||
if ($admin_ids) {
|
||||
$admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname');
|
||||
}
|
||||
$allot = $this->get_allot();
|
||||
$status_name = $this->customers_model->get_status();
|
||||
foreach ($param['rows'] as $key => $val) {
|
||||
if ($map_county[$val['county_id']]) {
|
||||
$other_data['所在地区'] = "{$map_county[$val['county_id']]['city_name']}-{$map_county[$val['county_id']]['county_name']}";
|
||||
}
|
||||
if ($param['biz_type'] != 5) {
|
||||
$other_data['客户来源'] = $this->get_cfTitle($val);
|
||||
}
|
||||
$other_data['建卡时间'] = 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']));
|
||||
if ($param['group_id'] == 1) {
|
||||
$where_visit = ['c_id' => $val['id'], 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']];
|
||||
} else {
|
||||
$where_visit = ['c_id' => $val['id'], 'biz_id' => $val['biz_id'], 'sales_id' => $val['admin_id']];
|
||||
}
|
||||
$visit_time = $this->get_visit_time($where_visit);
|
||||
$visit_time && $other_data['计划回访时间'] = $visit_time;
|
||||
$other_data['销售顾问'] = isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '';
|
||||
$tags = [$val['level'] . '级用户'];
|
||||
$defeat = $orders_pay = '';
|
||||
if ($val['if_defeat'] == 1) {
|
||||
$defeat = '战败申请中';
|
||||
} else if ($val['if_defeat'] == 2) {
|
||||
$defeat = '再战';
|
||||
}
|
||||
//查找订单未支付
|
||||
if ($val['status'] == 0 || $val['status'] == 1) {
|
||||
$orders_count = $this->mdOrders->count(['status' => 0, 'order_time' => '0000-00-00 00:00:00', 'customer_id' => $val['id']]);
|
||||
$orders_count && $orders_pay = '订单未支付';
|
||||
}
|
||||
$tip = $status_name[$val['status']] ? $status_name[$val['status']] : '';
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
|
||||
'complete_mobile' => $val['mobile'],
|
||||
'is_top' => $val['is_top'],
|
||||
'other_data' => $other_data,
|
||||
'tags' => $tags,
|
||||
'defeat' => $defeat,
|
||||
'orders_pay' => $orders_pay,
|
||||
'group_id' => $param['group_id'],
|
||||
'is_weChat' => $val['wxqy'] == 1 ? true : false,
|
||||
'allot' => $allot,
|
||||
'tip' => $tip,
|
||||
'level' => $val['level'],
|
||||
'reassign' => $val['cs_biz_id'] > 0 ? '他店改派' : '',
|
||||
];
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
//派单给店员
|
||||
protected function put_admins()
|
||||
{
|
||||
@@ -842,94 +855,152 @@ class Customers extends Wxapp
|
||||
$tabs = [];
|
||||
if ($status == 1) {//跟进客户
|
||||
$tabs = [['name' => '本日新增跟进', 'id' => 1], ['name' => '逾期未跟进', 'id' => 3]];
|
||||
} else if ($status == 3) {
|
||||
$tabs = [['name' => '今日', 'id' => 1], ['name' => '本月线索', 'id' => 2]];
|
||||
} else if ($status == 4) {
|
||||
$tabs = [['name' => '今日', 'id' => 1], ['name' => '本月企v', 'id' => 2]];
|
||||
} else if ($status == 5) {
|
||||
$tabs = [['name' => '今日', 'id' => 1], ['name' => '本月到店', 'id' => 2]];
|
||||
} else if ($status == 6) {
|
||||
$tabs = [['name' => '今日', 'id' => 1], ['name' => '本月订单', 'id' => 2]];
|
||||
} else if ($status == 7) {
|
||||
$tabs = [['name' => '今日', 'id' => 1], ['name' => '本月战败', 'id' => 2]];
|
||||
} else if ($status == 8) {
|
||||
$tabs = [['name' => '今日', 'id' => 1], ['name' => '本月退订', 'id' => 2]];
|
||||
}
|
||||
return ['list' => $tabs];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:客户回访记录列表
|
||||
* Created on: 2021/10/21 14:27
|
||||
* Created on: 2022/10/14 14:40
|
||||
* Created by: dengbw
|
||||
* @param array $params
|
||||
* @param int $visit
|
||||
* @return array
|
||||
*/
|
||||
private function visit_lists($params = [])
|
||||
private function visit_lists($params = [], $visit = 1)
|
||||
{
|
||||
$group_id = $this->session['group_id'];
|
||||
$biz_type = $this->get_biz('type');
|
||||
$page = intval($params['page']);
|
||||
$size = intval($params['size']);
|
||||
$status = intval($params['status']);
|
||||
$tab_id = intval($params['visit_tab_id']);
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
$t_day = date('Y-m-d');
|
||||
$where = array('a.biz_id' => $this->biz_id, 'a.cs_biz_id<>' => -1, 'a.status in(0,1)' => null, 'b.t_day' => $t_day);
|
||||
$params['level'] && $where['a.level'] = $params['level'];//等级
|
||||
if ($status == 2) {//已跟进
|
||||
$where['b.status'] = 2;
|
||||
} else {
|
||||
if ($tab_id) {
|
||||
$where['b.status'] = $tab_id;
|
||||
$count = 0;
|
||||
$lists = $where = $rows = [];
|
||||
if ($visit == 1) {//客户回访记录
|
||||
$status = intval($params['status']);
|
||||
$t_day = date('Y-m-d');
|
||||
$where = array('a.biz_id' => $this->biz_id, 'a.cs_biz_id<>' => -1, 'a.status in(0,1)' => null, 'b.t_day' => $t_day);
|
||||
$params['level'] && $where['a.level'] = $params['level'];//等级
|
||||
if ($status == 2) {//已跟进
|
||||
$where['b.status'] = 2;
|
||||
} else {
|
||||
$where['b.status<>'] = 2;
|
||||
if ($tab_id) {
|
||||
$where['b.status'] = $tab_id;
|
||||
} else {
|
||||
$where['b.status<>'] = 2;
|
||||
}
|
||||
}
|
||||
$group_id == 1 && $where['a.admin_id'] = $this->myuid;
|
||||
$count = $this->mdCustomerVisitData->count_visit($where);
|
||||
} else {//数据看板 数据列表
|
||||
if ($tab_id == 2) {//今日
|
||||
$s_c_time = date('Y-m-01', strtotime(date("Y-m-d"))) . ' 00:00:00';
|
||||
$e_c_time = date('Y-m-d', strtotime("$s_c_time +1 month -1 day")) . ' 23:59:59';
|
||||
} else {//本月
|
||||
$s_c_time = date('Y-m-d') . ' 00:00:00';
|
||||
$e_c_time = date('Y-m-d') . ' 23:59:59';
|
||||
}
|
||||
if ($visit == 3) {//今日/本月线索
|
||||
$where = ['biz_id' => $this->biz_id, 'cs_biz_id<>' => -1, 'status>=' => 0, 'c_time>=' => strtotime($s_c_time)
|
||||
, 'c_time<=' => strtotime($e_c_time)];
|
||||
$group_id == 1 && $where['admin_id'] = $this->myuid;
|
||||
$count = $this->customers_model->count($where);
|
||||
} else if ($visit == 4) {//今日/本月企v
|
||||
$where = ['change_type' => 'add_external_contact', 'c_time>=' => strtotime($s_c_time), 'c_time<=' => strtotime($e_c_time)];
|
||||
if ($biz_type == 5) {//异业店
|
||||
$this->load->model('app/app_different_qy_log_model', 'mdWechatLog');
|
||||
$this->load->model('app/app_different_qy_model', 'mdWechat');
|
||||
} else {
|
||||
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatLog');
|
||||
$this->load->model('app/app_lichene_qy_model', 'mdWechat');
|
||||
}
|
||||
if ($group_id == 1) {
|
||||
$where['userid'] = $this->session['userid'] ? $this->session['userid'] : '-1';
|
||||
} else {
|
||||
$res_user = $this->app_user_model->select(['biz_id' => $this->biz_id, 'group_id <' => 4, 'status' => 1, 'userid<>' => ''], 'id asc', 0, 0, 'userid');
|
||||
if ($res_user) {
|
||||
$str_userids = implode("','", array_column($res_user, 'userid'));
|
||||
$where["userid in('{$str_userids}')"] = null;
|
||||
} else {
|
||||
$where["userid"] = '-1';
|
||||
}
|
||||
}
|
||||
$count = $this->mdWechatLog->count($where, 'distinct(external_userid)');
|
||||
} else if ($visit == 5 || $visit == 7) {//今日/本月到店/战败
|
||||
$oplogs_type = $visit == 7 ? 7 : 4;//4到店7战败
|
||||
$s_c_time = strtotime($s_c_time);
|
||||
$e_c_time = strtotime($e_c_time);
|
||||
$where = ['biz_id' => $this->biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1];
|
||||
if ($group_id == 1) {
|
||||
$where['admin_id'] = $this->myuid;
|
||||
$where["id in(select customer_id from lc_receiver_customer_oplogs where type={$oplogs_type} and c_time>={$s_c_time} and c_time<={$e_c_time} and uid={$this->myuid})"] = null;
|
||||
} else {
|
||||
$where["id in(select customer_id from lc_receiver_customer_oplogs where type={$oplogs_type} and c_time>={$s_c_time} and c_time<={$e_c_time})"] = null;
|
||||
}
|
||||
$count = $this->customers_model->count($where);
|
||||
}
|
||||
}
|
||||
$group_id == 1 && $where['a.admin_id'] = $this->session['uid'];
|
||||
$count = $this->mdCustomerVisitData->count_visit($where);
|
||||
$lists = [];
|
||||
if ($count) {
|
||||
$fileds = 'a.id,a.name,a.admin_id,a.mobile,a.level,a.is_top,a.cont_time,a.c_time,a.if_defeat,a.cf_title
|
||||
$fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,if_defeat
|
||||
,of_id,of2_id,wxqy,status,biz_id,cs_biz_id,county_id';
|
||||
if ($visit == 1) {
|
||||
$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.biz_id,a.county_id';
|
||||
$rows = $this->mdCustomerVisitData->select_visit($where, 'a.id desc', $page, $size, $fileds);
|
||||
$admins = $map_county = [];
|
||||
$str_county_ids = implode(',', array_unique(array_column($rows, 'county_id')));
|
||||
if ($str_county_ids) {
|
||||
$map_county = $this->mdArea->map('county_id', 'city_name,county_name', ["county_id in({$str_county_ids})" => null]);
|
||||
}
|
||||
//获取管理员
|
||||
$admin_arr = array_unique(array_column($rows, 'admin_id'));
|
||||
if ($admin_arr) {
|
||||
$admin_ids = implode(',', $admin_arr);
|
||||
$admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname');
|
||||
}
|
||||
$status_name = $this->customers_model->get_status();
|
||||
foreach ($rows as $key => $val) {
|
||||
if ($map_county[$val['county_id']]) {
|
||||
$other_data['所在地区'] = "{$map_county[$val['county_id']]['city_name']}-{$map_county[$val['county_id']]['county_name']}";
|
||||
$rows = $this->mdCustomerVisitData->select_visit($where, 'a.id desc', $page, $size, $fileds);
|
||||
$lists = $this->listCustomerField(['rows' => $rows, 'biz_type' => $biz_type, 'group_id' => $group_id]);
|
||||
} else if ($visit == 4) {
|
||||
$fileds = 'distinct(external_userid) as external_userid,userid,c_time';
|
||||
$rows = $this->mdWechatLog->select($where, 'c_time desc', $page, $size, $fileds);
|
||||
foreach ($rows as $k => $v) {
|
||||
$mobile = $nickname = $avatar = '';
|
||||
$re_item = [];
|
||||
if ($v['external_userid']) {//查找企微用户
|
||||
$where_wec = ['external_userid' => $v['external_userid']];
|
||||
$v['userid'] && $where_wec['userid'] = $v['userid'];
|
||||
$res_wec = $this->mdWechat->get($where_wec);
|
||||
if ($res_wec) {
|
||||
$mobile = $res_wec['mobile'];
|
||||
$nickname = $res_wec['name'];
|
||||
$avatar = $res_wec['avatar'];
|
||||
}
|
||||
}
|
||||
if ($mobile) {//查找关连客户
|
||||
$where = ['mobile' => $mobile, 'cs_biz_id<>' => -1, 'status>=' => 0];
|
||||
$this->biz_id && $where['biz_id'] = $this->biz_id;
|
||||
$res_cus = $this->customers_model->get($where);
|
||||
if ($res_cus) {
|
||||
$rows = [$res_cus];
|
||||
$re = $this->listCustomerField(['rows' => $rows, 'biz_type' => $biz_type, 'group_id' => $group_id]);
|
||||
count($re) && $re_item = $re[0];
|
||||
}
|
||||
}
|
||||
if (!$re_item) {//未关连到客户
|
||||
$other_data['通过时间'] = date('Y-m-d', $v['c_time']);
|
||||
if ($v['userid']) {//查找销售顾问
|
||||
$res_user = $this->app_user_model->get(['userid' => $v['userid']]);
|
||||
$res_user && $other_data['销售顾问'] = $res_user['uname'] ? $res_user['uname'] : $res_user['nickname'];
|
||||
}
|
||||
$re_item = ['nickname' => $nickname, 'avatar' => $avatar, 'other_data' => $other_data];
|
||||
}
|
||||
$lists[] = $re_item;
|
||||
}
|
||||
if ($biz_type != 5) {
|
||||
$other_data['客户来源'] = $this->get_cfTitle($val);
|
||||
}
|
||||
$other_data['建卡时间'] = 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']));
|
||||
if ($group_id == 1) {
|
||||
$where_visit = ['c_id' => $val['id'], 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']];
|
||||
} else {
|
||||
$where_visit = ['c_id' => $val['id'], 'biz_id' => $val['biz_id'], 'sales_id' => $val['admin_id']];
|
||||
}
|
||||
$visit_time = $this->get_visit_time($where_visit);
|
||||
$visit_time && $other_data['计划回访时间'] = $visit_time;
|
||||
$other_data['销售顾问'] = isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '';
|
||||
$tags = [$val['level'] . '级用户'];
|
||||
$defeat = '';
|
||||
if ($val['if_defeat'] == 1) {
|
||||
$defeat = '战败申请中';
|
||||
} else if ($val['if_defeat'] == 2) {
|
||||
$defeat = '再战';
|
||||
}
|
||||
$tip = $status_name[$val['status']] ? $status_name[$val['status']] : '';
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
|
||||
'complete_mobile' => $val['mobile'],
|
||||
'is_top' => $val['is_top'],
|
||||
'other_data' => $other_data,
|
||||
'tags' => $tags,
|
||||
'defeat' => $defeat,
|
||||
'tip' => $tip,
|
||||
];
|
||||
} else {
|
||||
$rows = $this->customers_model->select($where, 'c_time desc', $page, $size, $fileds);
|
||||
$lists = $this->listCustomerField(['rows' => $rows, 'biz_type' => $biz_type, 'group_id' => $group_id]);
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
|
||||
@@ -333,37 +333,60 @@ class User extends Wxapp
|
||||
$where_today_qy = ['change_type' => 'add_external_contact', 'c_time>=' => strtotime($s_today), 'c_time<=' => strtotime($e_today)];
|
||||
$where_month_qy = ['change_type' => 'add_external_contact', 'c_time>=' => strtotime($s_month), 'c_time<=' => strtotime($e_month)];
|
||||
//到店
|
||||
$where_today_dd = ['type' => 4, 'c_time>=' => strtotime($s_today), 'c_time<=' => strtotime($e_today)];
|
||||
$where_month_dd = ['type' => 4, 'c_time>=' => strtotime($s_month), 'c_time<=' => strtotime($e_month)];
|
||||
$where_today_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=4 and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null];
|
||||
$where_month_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=4 and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null];
|
||||
//订单
|
||||
$where_today_order = ['biz_id' => $biz_id, 'status>=' => 0, 'order_time>=' => $s_today, 'order_time<=' => $e_today];
|
||||
$where_month_order = ['biz_id' => $biz_id, 'status>=' => 0, 'order_time>=' => $s_month, 'order_time<=' => $e_month];
|
||||
$where_today_order = ['status>=' => 0, 'order_time>=' => $s_today, 'order_time<=' => $e_today];
|
||||
$where_month_order = ['status>=' => 0, 'order_time>=' => $s_month, 'order_time<=' => $e_month];
|
||||
//战败
|
||||
$where_today_defeat = ['type' => 7, 'c_time>=' => strtotime($s_today), 'c_time<=' => strtotime($e_today)];
|
||||
$where_month_defeat = ['type' => 7, 'c_time>=' => strtotime($s_month), 'c_time<=' => strtotime($e_month)];
|
||||
$where_today_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=7 and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null];
|
||||
$where_month_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=7 and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null];
|
||||
//退订
|
||||
$where_today_refund = ['biz_id' => $biz_id, 'status' => 2, 'refund_time>=' => $s_today, 'refund_time<=' => $e_today];
|
||||
$where_month_refund = ['biz_id' => $biz_id, 'status' => 2, 'refund_time>=' => $s_month, 'refund_time<=' => $e_month];
|
||||
$where_customer_id = "customer_id in(select id from lc_receiver_customers where biz_id={$biz_id} and cs_biz_id!=-1)";
|
||||
$where_today_refund = ['status' => 2, 'refund_time>=' => $s_today, 'refund_time<=' => $e_today];
|
||||
$where_month_refund = ['status' => 2, 'refund_time>=' => $s_month, 'refund_time<=' => $e_month];
|
||||
if ($group_id == 1) {
|
||||
$where_today_xs['admin_id'] = $uid;
|
||||
$where_month_xs['admin_id'] = $uid;
|
||||
$where_today_dd['uid'] = $uid;
|
||||
$where_month_dd['uid'] = $uid;
|
||||
$where_today_order['sale_id'] = $uid;
|
||||
$where_month_order['sale_id'] = $uid;
|
||||
$where_today_defeat['uid'] = $uid;
|
||||
$where_month_defeat['uid'] = $uid;
|
||||
$where_today_refund['sale_id'] = $uid;
|
||||
$where_month_refund['sale_id'] = $uid;
|
||||
$where_customer_id = "customer_id in(select id from lc_receiver_customers where admin_id={$uid} and biz_id={$biz_id} and cs_biz_id!=-1)";
|
||||
$where_today_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=4 and uid={$uid} and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null];
|
||||
$where_month_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=4 and uid={$uid} and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null];
|
||||
$where_today_order['admin_id'] = $uid;
|
||||
$where_month_order['admin_id'] = $uid;
|
||||
$where_today_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=7 and uid={$uid} and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null];
|
||||
$where_month_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1,
|
||||
"id in(select customer_id from lc_receiver_customer_oplogs where type=7 and uid={$uid} and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null];
|
||||
$where_today_refund['admin_id'] = $uid;
|
||||
$where_month_refund['admin_id'] = $uid;
|
||||
if ($this->session['userid']) {
|
||||
$where_today_qy['userid'] = $this->session['userid'];
|
||||
$where_month_qy['userid'] = $this->session['userid'];
|
||||
} else {
|
||||
$where_today_qy = '';
|
||||
}
|
||||
} else {
|
||||
} else if ($group_id == 2 || $group_id == 3) {//店长/老板
|
||||
$where_today_order["(biz_id = {$biz_id} OR admin_id = {$uid})"] = null;
|
||||
$where_month_order["(biz_id = {$biz_id} OR admin_id = {$uid})"] = null;
|
||||
$where_today_refund["(biz_id = {$biz_id} OR admin_id = {$uid})"] = null;
|
||||
$where_month_refund["(biz_id = {$biz_id} OR admin_id = {$uid})"] = null;
|
||||
} else if ($group_id == 4) {
|
||||
$where_today_order['biz_id'] = $biz_id;
|
||||
$where_month_order['biz_id'] = $biz_id;
|
||||
$where_today_refund['biz_id'] = $biz_id;
|
||||
$where_month_refund['biz_id'] = $biz_id;
|
||||
if ($biz_id != 1) {//渠道经理过滤
|
||||
$where_today_order['brand_id<>'] = 3;
|
||||
$where_month_order['brand_id<>'] = 3;
|
||||
$where_today_refund['brand_id<>'] = 3;
|
||||
$where_month_refund['brand_id<>'] = 3;
|
||||
}
|
||||
}
|
||||
if ($group_id != 1) {
|
||||
$res_user = $this->app_user_model->select(['biz_id' => $biz_id, 'group_id <' => 4, 'status' => 1, 'userid<>' => ''], 'id asc', 0, 0, 'userid');
|
||||
if ($res_user) {
|
||||
$str_userids = implode("','", array_column($res_user, 'userid'));
|
||||
@@ -386,21 +409,18 @@ class User extends Wxapp
|
||||
$month_qy = $this->mdWechatqyLog->count($where_month_qy, 'distinct(external_userid)');
|
||||
}
|
||||
}
|
||||
$where_today_dd[$where_customer_id] = null;
|
||||
$where_month_dd[$where_customer_id] = null;
|
||||
$where_today_defeat[$where_customer_id] = null;
|
||||
$where_month_defeat[$where_customer_id] = null;
|
||||
$statistics = [
|
||||
['today' => ['title' => '今日', 'value' => $this->customers_model->count($where_today_xs)]
|
||||
['today' => ['title' => '今日', 'value' => $this->customers_model->count($where_today_xs), 'url' => '/pages/customer/filterList/index?status=3&visit=3&title=线索']
|
||||
, 'month' => ['title' => '本月线索', 'value' => $this->customers_model->count($where_month_xs)]],
|
||||
['today' => ['title' => '今日', 'value' => $today_qy], 'month' => ['title' => '本月企v', 'value' => $month_qy]],
|
||||
['today' => ['title' => '今日', 'value' => $this->mdCustomerOpLogs->count($where_today_dd)]
|
||||
, 'month' => ['title' => '本月到店', 'value' => $this->mdCustomerOpLogs->count($where_month_dd)]],
|
||||
['today' => ['title' => '今日', 'value' => $this->receiver_orders_v2_model->count($where_today_order)]
|
||||
['today' => ['title' => '今日', 'value' => $today_qy, 'url' => '/pages/customer/filterList/index?status=4&visit=4&title=企v']
|
||||
, 'month' => ['title' => '本月企v', 'value' => $month_qy]],
|
||||
['today' => ['title' => '今日', 'value' => $this->customers_model->count($where_today_dd), 'url' => '/pages/customer/filterList/index?status=5&visit=5&title=到店']
|
||||
, 'month' => ['title' => '本月到店', 'value' => $this->customers_model->count($where_month_dd)]],
|
||||
['today' => ['title' => '今日', 'value' => $this->receiver_orders_v2_model->count($where_today_order), 'url' => '/pages/order/filterList/index2?status=6&visit=6&title=订单']
|
||||
, 'month' => ['title' => '本月订单', 'value' => $this->receiver_orders_v2_model->count($where_month_order)]],
|
||||
['today' => ['title' => '今日', 'value' => $this->mdCustomerOpLogs->count($where_today_defeat)]
|
||||
, 'month' => ['title' => '本月战败', 'value' => $this->mdCustomerOpLogs->count($where_month_defeat)]],
|
||||
['today' => ['title' => '今日', 'value' => $this->receiver_orders_v2_model->count($where_today_refund)]
|
||||
['today' => ['title' => '今日', 'value' => $this->customers_model->count($where_today_defeat), 'url' => '/pages/customer/filterList/index?status=7&visit=7&title=战败']
|
||||
, 'month' => ['title' => '本月战败', 'value' => $this->customers_model->count($where_month_defeat)]],
|
||||
['today' => ['title' => '今日', 'value' => $this->receiver_orders_v2_model->count($where_today_refund), 'url' => '/pages/order/filterList/index2?status=8&visit=8&title=退订']
|
||||
, 'month' => ['title' => '本月退订', 'value' => $this->receiver_orders_v2_model->count($where_month_refund)]]
|
||||
];
|
||||
$data = [
|
||||
|
||||
Reference in New Issue
Block a user