215 lines
9.2 KiB
PHP
215 lines
9.2 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
require_once 'Base.php';
|
|
|
|
class Home extends Base
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('receiver/receiver_customers_model', 'customers_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('app/licheb/app_licheb_users_model', 'app_user_model');
|
|
$this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model');
|
|
$this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
|
|
$this->load->model('receiver/receiver_yx_model');
|
|
$this->load->model('receiver/receiver_xz_model');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$tabList = [];
|
|
$rows = $this->customers_model->get_status();
|
|
if ($rows) {
|
|
foreach ($rows as $key => $val) {
|
|
if ($key != -1) {
|
|
$tabList[] = ['type' => $key, 'title' => $val];
|
|
}
|
|
}
|
|
}
|
|
$this->data['tabList'] = $tabList;
|
|
$this->data['_title'] = '我的推广';
|
|
$this->show_view('h5/paic/home/enroll');
|
|
}
|
|
|
|
public function getLists()
|
|
{
|
|
$page = intval($this->input->get('page'));
|
|
$status = $this->input->get('status');
|
|
$s_time = $this->input->get('s_time');
|
|
$e_time = $this->input->get('e_time');
|
|
!$page && $page = 1;
|
|
$size = 20;
|
|
$lists = [];
|
|
$where = [
|
|
'cf_pid' => $this->uid,
|
|
'status>=' => 0
|
|
];
|
|
strlen($status) && $where['status'] = $status;
|
|
if ($s_time && $e_time) {
|
|
$where["p_time>='{$s_time} 00:00:00'"] = null;
|
|
$where["p_time<='{$e_time} 23:59:59'"] = null;
|
|
}
|
|
$total = $this->customers_model->count($where);
|
|
if ($total) {
|
|
$fileds = 'id,rid,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,cont_time,c_time,p_time,if_defeat
|
|
,of_id,of2_id,wxqy,status,biz_id,county_id,cid,brand_id,series_id';
|
|
$rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds);
|
|
//获取管理员
|
|
$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');
|
|
}
|
|
foreach ($rows as $key => $val) {
|
|
$brand_name = '';
|
|
if ($val['brand_id']) {
|
|
$brand_row = $this->auto_brand_model->get(['id' => intval($val['brand_id'])]);
|
|
$brand_name = $brand_row['name'] ? $brand_row['name'] : '';
|
|
}
|
|
if ($val['series_id']) {
|
|
$series_row = $this->auto_series_model->get(['id' => intval($val['series_id'])]);
|
|
$series_name = $series_row['name'] ? $series_row['name'] : '';
|
|
$series_name && $brand_name .= '-' . $series_name;
|
|
}
|
|
$other_data['关注车型'] = $brand_name ?: '';
|
|
// $other_data['客户来源'] = $this->get_cfTitle($val);
|
|
$other_data['建档时间'] = date('Y-m-d', strtotime($val['p_time']));
|
|
$other_data['车管家'] = isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '';
|
|
$tmp = [
|
|
'id' => $val['id'],
|
|
'cid' => $val['cid'],
|
|
'name' => $val['name'],
|
|
'mobile' => $val['mobile'],
|
|
'time' => date('Y-m-d', strtotime($val['p_time'])),
|
|
'other_data' => $other_data,
|
|
];
|
|
$lists[] = $tmp;
|
|
}
|
|
}
|
|
$data['list'] = $lists;
|
|
$data['total'] = $total;
|
|
$this->success($data);
|
|
}
|
|
|
|
public function detail()
|
|
{
|
|
$id = $this->input->get('id');
|
|
$where = [
|
|
'id' => $id,
|
|
'cf_pid' => $this->uid,
|
|
];
|
|
$row = $this->customers_model->get($where);
|
|
if (!$row) {
|
|
throw new Exception('数据不存在');
|
|
}
|
|
$admin = $this->app_user_model->get(['id' => $row['admin_id']], 'id,uname');
|
|
$tags = [$row['level'] . '级用户'];
|
|
$status_name = $this->customers_model->get_status();
|
|
$tip = $status_name[$row['status']] ? $status_name[$row['status']] : '';
|
|
// $other_data = ['客户等级' => $row['level']];
|
|
// $other_data['客户来源'] = $this->get_cfTitle($row);
|
|
$brand_name = '';
|
|
if ($row['brand_id']) {
|
|
$brand_row = $this->auto_brand_model->get(['id' => intval($row['brand_id'])]);
|
|
$brand_name = $brand_row['name'] ? $brand_row['name'] : '';
|
|
}
|
|
if ($row['series_id']) {
|
|
$series_row = $this->auto_series_model->get(['id' => intval($row['series_id'])]);
|
|
$series_name = $series_row['name'] ? $series_row['name'] : '';
|
|
$series_name && $brand_name .= '-' . $series_name;
|
|
}
|
|
$other_data['关注车型'] = $brand_name ?: '';
|
|
$other_data['建档时间'] = date('Y-m-d', strtotime($row['p_time']));
|
|
$other_data['车管家'] = isset($admin) ? $admin['uname'] : '';
|
|
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
|
|
$info = [
|
|
'id' => $row['id'],
|
|
'cid' => $row['cid'],
|
|
'name' => $row['name'],
|
|
'mobile' => $row['mobile'],
|
|
'tip' => $tip,
|
|
'is_top' => $row['is_top'],
|
|
'status' => $row['status'],
|
|
'defeat' => $jsondata['defeat'],
|
|
'other_data' => $other_data,
|
|
'is_weChat' => $row['wxqy'] == 1 ? true : false,
|
|
'generate_order' => $this->myuid == $row['admin_id'] ? true : false,
|
|
'level' => $row['level'],
|
|
'tags' => $tags,
|
|
'wxgr' => $row['wxgr'],
|
|
'wxgrimg' => $row['wxgrimg'],
|
|
'wxgrimg_url' => $row['wxgrimg'] ? build_qiniu_image_url($row['wxgrimg']) : '',
|
|
'time' => date('Y-m-d', strtotime($row['p_time'])),
|
|
];
|
|
$this->data['info'] = $info;
|
|
$this->data['_title'] = '详情';
|
|
$this->show_view('h5/paic/home/detail');
|
|
}
|
|
|
|
public function customerLogs()
|
|
{
|
|
$id = $this->input->get('id');
|
|
$page = $this->input->get('page');
|
|
$size = $this->input->get('size');
|
|
!$page && $page = 1;
|
|
!$size && $size = 20;
|
|
$where = [
|
|
'customer_id' => $id
|
|
];
|
|
$count = $this->customer_oplogs_model->count($where);
|
|
$lists = [];
|
|
if ($count) {
|
|
$rows = $this->customer_oplogs_model->select($where, 'id desc', $page, $size, 'id,log,uname,type,c_time,imgs,sub_type');
|
|
foreach ($rows as $key => $val) {
|
|
$record = '';
|
|
$second = 0;
|
|
$content = $val['log'];
|
|
$img_json = json_decode($val['imgs'], true);
|
|
$imgs = [];
|
|
if ($img_json) {
|
|
foreach ($img_json as $val2) {
|
|
$imgs[] = build_qiniu_image_url($val2);
|
|
}
|
|
}
|
|
if ($val['type'] == 2) {
|
|
$content = '拨打电话';
|
|
if ($val['sub_type'] == Receiver_customer_oplogs_model::SUB_TYPE_XZ) {
|
|
$rec_row = $this->receiver_xz_model->get(['id' => $val['log']], 'rec_url,duration');
|
|
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
|
|
$rec_row['duration'] && $second = intval($rec_row['duration'] / 1000);
|
|
} else {
|
|
$rec_row = $this->receiver_yx_model->get(['id' => $val['log']], 'rec_url,duration');
|
|
$rec_row['rec_url'] && $record = get_yx_video($rec_row['rec_url']);
|
|
$rec_row['duration'] && $second = intval($rec_row['duration']);
|
|
}
|
|
!$rec_row['duration'] && $content .= '(未接通)';
|
|
}
|
|
$lists[] = [
|
|
'id' => $val['id'],
|
|
'content' => "【{$val['uname']}】" . $content,
|
|
'record_url' => $record,
|
|
'second' => $second,
|
|
'imgs' => $imgs,
|
|
'type_name' => $this->customer_oplogs_model->typeAry($val['type']),
|
|
'c_time' => date('Y.m.d H:i', $val['c_time'])
|
|
];
|
|
}
|
|
}
|
|
$data = [
|
|
'list' => $lists,
|
|
'total' => $count
|
|
];
|
|
$this->success($data);
|
|
}
|
|
|
|
private function get_cfTitle($params)
|
|
{
|
|
$map_cfrom2 = $this->clues_cfrom_model->get(array('id' => $params['of2_id']));
|
|
$map_cfrom = $this->clues_cfrom_model->get(array('id' => $map_cfrom2['pid']));
|
|
$title = $map_cfrom['title'] . '-' . $map_cfrom2['title'];
|
|
|
|
return $title;
|
|
}
|
|
} |